[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 18:36:56 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3d6c7d6e8e44: [dsymutil] Fix spurious warnings for missing symbols with thinLTO (authored by JDevlieghere).

Repository:
  rG LLVM Github Monorepo

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

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.332494.patch
Type: text/x-patch
Size: 1668 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210323/a7fea8e2/attachment.bin>


More information about the llvm-commits mailing list