[dsymutil] Reapply r245960.
authorFrederic Riss <friss@apple.com>
Tue, 25 Aug 2015 23:15:26 +0000 (23:15 +0000)
committerFrederic Riss <friss@apple.com>
Tue, 25 Aug 2015 23:15:26 +0000 (23:15 +0000)
There was an issue in the test setup because the test requires an arch that
wasn't filtered by the lit.local.cfg, but given the set of bots that failed,
I'm not confident this is the (only) issue. So this commit also adds more
output to the test to help me track down the failure if it happens again.

Original commit message:
[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@245988 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/dsymutil/ARM/empty-map.test
test/tools/dsymutil/ARM/fat-arch-name.test [new file with mode: 0644]
test/tools/dsymutil/ARM/lit.local.cfg
tools/dsymutil/MachOUtils.cpp
tools/dsymutil/MachOUtils.h
tools/dsymutil/dsymutil.cpp

index 4cc0e5f67b5adae0aa3cf3b9c4916043fe9db93b..54d9a35cc6e44ae7b40644acfa9feb3e30e811b0 100644 (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)
diff --git a/test/tools/dsymutil/ARM/fat-arch-name.test b/test/tools/dsymutil/ARM/fat-arch-name.test
new file mode 100644 (file)
index 0000000..433f530
--- /dev/null
@@ -0,0 +1,22 @@
+# REQUIRES: object-emission
+# RUN: llvm-dsymutil %p/../Inputs/fat-test.arm.dylib -o %t1.dSYM -verbose
+# 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
index 236e1d34416659068d4434bd878989a4165d35c4..b704ac4031fe781c576eff4417ec6131e6f083ac 100644 (file)
@@ -1,2 +1,4 @@
 if not 'ARM' in config.root.targets:
     config.unsupported = True
+if not 'AArch64' in config.root.targets:
+    config.unsupported = True
index 15605fe00ebf4301ecc74f875ec3b980e4dadcc3..8f4d2610b8f5196610e021553df8614554aca7b8 100644 (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");
index f1b2ad9dadd1faf8ecedc9549f87998cacab93bd..d6b6f3d61c39551b600ec035773a91032f1859bb 100644 (file)
@@ -24,6 +24,8 @@ struct ArchAndFilename {
 
 bool generateUniversalBinary(SmallVectorImpl<ArchAndFilename> &ArchFiles,
                              StringRef OutputFileName, const LinkOptions &);
+
+std::string getArchName(StringRef Arch);
 }
 }
 }
index 3d9851eca7ef491b274ef5cd8ffa9adadcaf2b37..9e112ba0727984d2953fd46fe7e21d7a8875d7fc 100644 (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))