[dsymutil] Rewrite thumb triple names in user visible messages.

We autodetect triples from the input file(s) while reading the mach-o debug map.
As we need to create a Target from those triples, we always chose the thumb
variant (because the arm variant might not be 'instantiable' eg armv7m). The
user visible architecture names should still be 'arm' and not 'thumb' variants
though.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245960 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Frederic Riss 2015-08-25 18:19:48 +00:00
parent 909125ad03
commit 0e221a0b65
5 changed files with 33 additions and 2 deletions

View File

@ -5,4 +5,4 @@
triple: 'thumbv7-apple-darwin'
...
# CHECK: warning: no debug symbols in executable (-arch thumbv7)
# CHECK: warning: no debug symbols in executable (-arch armv7)

View File

@ -0,0 +1,21 @@
# REQUIRES: object-emission
# RUN: llvm-dsymutil %p/../Inputs/fat-test.arm.dylib -o %t.dSYM -verbose 2>&1 | FileCheck %s
# We detect thumb triples from the binaries, because those are the only ones
# that are guaranteed to be able to generate a Target instance (for example
# we would detect armv7m-apple-darwin as non-thumb triple, but you can't
# instantiate a Target from that). In the user-visible architecture names, and
# in the lipo invocation, we need to rewrite the thumb arch names to the arm
# ones.
# CHECK: warning: no debug symbols in executable (-arch armv7)
# CHECK: warning: no debug symbols in executable (-arch armv7s)
# CHECK: warning: no debug symbols in executable (-arch arm64)
# CHECK: Running lipo
# CHECK-NEXT: lipo -create
# CHECK-SAME: -segalign armv7
# CHECK-SAME: -segalign armv7s
# CHECK-SAME: -segalign arm64

View File

@ -17,6 +17,12 @@ namespace llvm {
namespace dsymutil {
namespace MachOUtils {
std::string getArchName(StringRef Arch) {
if (Arch.startswith("thumb"))
return (llvm::Twine("arm") + Arch.drop_front(5)).str();
return Arch;
}
static bool runLipo(SmallVectorImpl<const char *> &Args) {
auto Path = sys::findProgramByName("lipo");
@ -64,6 +70,7 @@ bool generateUniversalBinary(SmallVectorImpl<ArchAndFilename> &ArchFiles,
// Align segments to match dsymutil-classic alignment
for (auto &Thin : ArchFiles) {
Thin.Arch = getArchName(Thin.Arch);
Args.push_back("-segalign");
Args.push_back(Thin.Arch.c_str());
Args.push_back("20");

View File

@ -24,6 +24,8 @@ struct ArchAndFilename {
bool generateUniversalBinary(SmallVectorImpl<ArchAndFilename> &ArchFiles,
StringRef OutputFileName, const LinkOptions &);
std::string getArchName(StringRef Arch);
}
}
}

View File

@ -301,7 +301,8 @@ int main(int argc, char **argv) {
if (Map->begin() == Map->end())
llvm::errs() << "warning: no debug symbols in executable (-arch "
<< Map->getTriple().getArchName() << ")\n";
<< MachOUtils::getArchName(Map->getTriple().getArchName())
<< ")\n";
std::string OutputFile = getOutputFileName(InputFile, NeedsTempFiles);
if (OutputFile.empty() || !linkDwarf(OutputFile, *Map, Options))