Skip to content

Commit

Permalink
[dsymutil] Fix spurious warnings for missing symbols with thinLTO
Browse files Browse the repository at this point in the history
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

Differential revision: https://reviews.llvm.org/D99125
  • Loading branch information
JDevlieghere committed Mar 23, 2021
1 parent b37d0a4 commit 3d6c7d6
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
24 changes: 24 additions & 0 deletions llvm/test/tools/dsymutil/X86/thinlto.test
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions llvm/tools/dsymutil/MachODebugMapParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,17 @@ void MachODebugMapParser::handleStabSymbolTableEntry(uint32_t StringIndex,
}
}

// 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;
Expand Down

0 comments on commit 3d6c7d6

Please sign in to comment.