summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Shaposhnikov <shal1t712@gmail.com>2019-10-07 21:14:22 +0000
committerAlexander Shaposhnikov <shal1t712@gmail.com>2019-10-07 21:14:22 +0000
commitf5d700ac05cb3b3fdb22619186ce9f0376dcca10 (patch)
tree0c98c4ced47e9faf471652a272f2c9422f352f29
parent1097fab1cf41e786a659b1fe45a1494170be6952 (diff)
downloadbcm5719-llvm-f5d700ac05cb3b3fdb22619186ce9f0376dcca10.tar.gz
bcm5719-llvm-f5d700ac05cb3b3fdb22619186ce9f0376dcca10.zip
[llvm-lipo] Relax the check of the specified input file architecture
cctools lipo only compares the cputypes when it verifies that the specified (via -arch) input file and the architecture match. This diff adjusts the behavior of llvm-lipo accordingly. Differential revision: https://reviews.llvm.org/D68319 Test plan: make check-all llvm-svn: 373966
-rw-r--r--llvm/tools/llvm-lipo/llvm-lipo.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/llvm/tools/llvm-lipo/llvm-lipo.cpp b/llvm/tools/llvm-lipo/llvm-lipo.cpp
index 5eb3332c02e..e746db41405 100644
--- a/llvm/tools/llvm-lipo/llvm-lipo.cpp
+++ b/llvm/tools/llvm-lipo/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 @@ readInputBinaries(ArrayRef<InputFile> InputFiles) {
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));
}
OpenPOWER on IntegriCloud