[PATCH] D68319: [llvm-lipo] Relax the check of the specified input file architecture

Alexander Shaposhnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 2 02:16:37 PDT 2019


alexshap updated this revision to Diff 222775.
alexshap added a comment.

fix formatting


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68319/new/

https://reviews.llvm.org/D68319

Files:
  llvm-lipo.cpp


Index: llvm-lipo.cpp
===================================================================
--- llvm-lipo.cpp
+++ llvm-lipo.cpp
@@ -23,6 +23,7 @@
 #include "llvm/Support/FileOutputBuffer.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/WithColor.h"
+#include "llvm/TextAPI/MachO/Architecture.h"
 
 using namespace llvm;
 using namespace llvm::object;
@@ -438,14 +439,19 @@
     if (!B->isArchive() && !B->isMachO() && !B->isMachOUniversalBinary())
       reportError("File " + IF.FileName + " has unsupported binary format");
     if (IF.ArchType && (B->isMachO() || B->isArchive())) {
-      const auto ArchType =
-          B->isMachO() ? Slice(cast<MachOObjectFile>(B)).getArchString()
-                       : Slice(cast<Archive>(B)).getArchString();
-      if (Triple(*IF.ArchType).getArch() != Triple(ArchType).getArch())
+      const auto S = B->isMachO() ? Slice(cast<MachOObjectFile>(B))
+                                  : Slice(cast<Archive>(B));
+      const auto SpecifiedCPUType =
+          MachO::getCPUTypeFromArchitecture(
+              MachO::mapToArchitecture(Triple(*IF.ArchType)))
+              .first;
+      // For compatibility with cctools' lipo the comparison is relaxed just to
+      // checking cputypes.
+      if (S.getCPUType() != SpecifiedCPUType)
         reportError("specified architecture: " + *IF.ArchType +
                     " for file: " + B->getFileName() +
-                    " does not match the file's architecture (" + ArchType +
-                    ")");
+                    " does not match the file's architecture (" +
+                    S.getArchString() + ")");
     }
     InputBinaries.push_back(std::move(*BinaryOrErr));
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68319.222775.patch
Type: text/x-patch
Size: 1704 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191002/14e5fdde/attachment.bin>


More information about the llvm-commits mailing list