[PATCH] D99125: [dsymutil] Fix spurious warnings for missing symbols with thinLTO

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 22 16:34:29 PDT 2021


JDevlieghere created this revision.
JDevlieghere added reviewers: steven_wu, friss.
Herald added subscribers: hiraditya, inglorion.
JDevlieghere requested review of this revision.
Herald added a project: LLVM.

Fix spurious warnings for missing symbols with thinLTO. The latter appends a unique suffix to avoid collisions for exported private symbols, resulting in dsymutil complaining it couldn't find the symbol in the object file.

rdar://75434058


https://reviews.llvm.org/D99125

Files:
  llvm/test/tools/dsymutil/Inputs/private/tmp/thinlto/bar.o
  llvm/test/tools/dsymutil/Inputs/private/tmp/thinlto/foo.o
  llvm/test/tools/dsymutil/Inputs/private/tmp/thinlto/foobar.dylib
  llvm/test/tools/dsymutil/Inputs/private/tmp/thinlto/lto/0.x86_64.thinlto.o
  llvm/test/tools/dsymutil/Inputs/private/tmp/thinlto/lto/1.x86_64.thinlto.o
  llvm/test/tools/dsymutil/X86/thinlto.test
  llvm/tools/dsymutil/MachODebugMapParser.cpp


Index: llvm/tools/dsymutil/MachODebugMapParser.cpp
===================================================================
--- llvm/tools/dsymutil/MachODebugMapParser.cpp
+++ llvm/tools/dsymutil/MachODebugMapParser.cpp
@@ -462,6 +462,17 @@
     }
   }
 
+  // ThinLTO adds a unique suffix to exported private symbols.
+  for (auto Iter = CurrentObjectAddresses.begin();
+       Iter != CurrentObjectAddresses.end(); ++Iter) {
+    llvm::StringRef SymbolName = Iter->getKey();
+    auto Pos = SymbolName.rfind(".llvm.");
+    if (Pos != llvm::StringRef::npos && SymbolName.substr(0, Pos) == Name) {
+      ObjectSymIt = Iter;
+      break;
+    }
+  }
+
   if (ObjectSymIt == CurrentObjectAddresses.end()) {
     Warning("could not find object file symbol for symbol " + Twine(Name));
     return;
Index: llvm/test/tools/dsymutil/X86/thinlto.test
===================================================================
--- /dev/null
+++ llvm/test/tools/dsymutil/X86/thinlto.test
@@ -0,0 +1,24 @@
+$ cat foo.cpp
+struct nontrivial {
+  nontrivial() { }
+};
+
+void function2()
+{
+  static const nontrivial magic_static;
+}
+
+$ cat bar.cpp
+void function2();
+
+void function1()
+{
+  function2();
+}
+
+$ xcrun clang++ -g -flto=thin -O2 foo.cpp bar.cpp -c
+$ xcrun clang++ -flto=thin foo.o bar.o -Xlinker -object_path_lto -Xlinker lto -shared -o foobar.dylib
+
+RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/thinlto/foobar.dylib -o %t.dSYM 2>&1 | FileCheck %s --allow-empty
+CHECK-NOT: could not find object file symbol for symbol __ZZ9function2vE12magic_static
+CHECK-NOT: could not find object file symbol for symbol __ZGVZ9function2vE12magic_static


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99125.332471.patch
Type: text/x-patch
Size: 1668 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210322/1b3a1441/attachment.bin>


More information about the llvm-commits mailing list