Skip to content

Commit 8b5dfbf

Browse files
committed
Fix for the -fvisibility=hidden problem.
'man ld' revealed the secret. Flag -keep_private_externs seems to do what we want.
1 parent da7b0cc commit 8b5dfbf

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

driver/utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
192192
'-current_version' : (1, ArgumentListFilter.linkBinaryCallback),
193193
'-compatibility_version' : (1, ArgumentListFilter.linkBinaryCallback),
194194

195-
# bd: need to warn the darwin user that these flags will rain on their parade
195+
#
196+
# BD: need to warn the darwin user that these flags will rain on their parade
196197
# (the Darwin ld is a bit single minded)
197198
#
198199
# 1) compilation with -fvisibility=hidden causes trouble when we try to
@@ -202,7 +203,9 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
202203
# 2) all stripping commands (e.g., -dead_strip) remove the __LLVM segment after
203204
# linking
204205
#
205-
'-fvisibility=hidden' : (0, ArgumentListFilter.darwinWarningCompileUnaryCallback),
206+
# Update: found a fix for problem 1: add flag -keep_private_externs when
207+
# calling ld -r.
208+
#
206209
'-Wl,-dead_strip' : (0, ArgumentListFilter.darwinWarningLinkUnaryCallback),
207210

208211
}
@@ -490,7 +493,7 @@ def attachBitcodePathToObject(bcPath, outFileName):
490493

491494
# Now write our bitcode section
492495
if (sys.platform.startswith('darwin')):
493-
objcopyCmd = ['ld', '-r', outFileName, '-sectcreate', darwinSegmentName, darwinSectionName, f.name, '-o', outFileName]
496+
objcopyCmd = ['ld', '-r', '-keep_private_externs', outFileName, '-sectcreate', darwinSegmentName, darwinSectionName, f.name, '-o', outFileName]
494497
else:
495498
objcopyCmd = ['objcopy', '--add-section', '{0}={1}'.format(elfSectionName, f.name), outFileName]
496499
orc = 0

0 commit comments

Comments
 (0)