[PATCH] D113167: [lld-macho] Allow exporting weak def private-extern symbols.
Vy Nguyen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 3 22:21:18 PDT 2021
oontvoo created this revision.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.
oontvoo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Currently lld-macho can't link our apps that use protobufs, which genereate a lot weak symbols, because they can't export symbols.
LD64 does allow exporting such symbols.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D113167
Files:
lld/MachO/Driver.cpp
lld/MachO/MarkLive.cpp
Index: lld/MachO/MarkLive.cpp
===================================================================
--- lld/MachO/MarkLive.cpp
+++ lld/MachO/MarkLive.cpp
@@ -67,7 +67,7 @@
// FIXME: Instead of doing this here, maybe the Driver code doing
// the matching should add them to explicitUndefineds? Then the
// explicitUndefineds code below would handle this automatically.
- assert(!defined->privateExtern &&
+ assert((!defined->privateExtern || defined->isWeakDef()) &&
"should have been rejected by driver");
addSym(defined);
continue;
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -1472,8 +1472,15 @@
StringRef symbolName = defined->getName();
if (config->exportedSymbols.match(symbolName)) {
if (defined->privateExtern) {
- warn("cannot export hidden symbol " + symbolName +
- "\n>>> defined in " + toString(defined->getFile()));
+ // If it's a weak, it's not "hidden".
+ if (!defined->isWeakDef())
+ warn("cannot export hidden symbol " + symbolName +
+ "\n>>> defined in " + toString(defined->getFile()));
+ else
+ // When a weakdef private extern symbol is exported,
+ // it becomes "non-private.
+ // This matches LD64's behaviour.
+ defined->privateExtern = false;
}
} else {
defined->privateExtern = true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113167.384662.patch
Type: text/x-patch
Size: 1623 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211104/2318b573/attachment.bin>
More information about the llvm-commits
mailing list