@@ -118,6 +118,7 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
118
118
'-m3dnow' : (0 , ArgumentListFilter .compileUnaryCallback ),
119
119
'-mno-3dnow' : (0 , ArgumentListFilter .compileUnaryCallback ),
120
120
121
+
121
122
# Preprocessor assertion
122
123
'-A' : (1 , ArgumentListFilter .compileBinaryCallback ),
123
124
'-D' : (1 , ArgumentListFilter .compileBinaryCallback ),
@@ -192,7 +193,8 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
192
193
'-current_version' : (1 , ArgumentListFilter .linkBinaryCallback ),
193
194
'-compatibility_version' : (1 , ArgumentListFilter .linkBinaryCallback ),
194
195
195
- # bd: need to warn the darwin user that these flags will rain on their parade
196
+ #
197
+ # BD: need to warn the darwin user that these flags will rain on their parade
196
198
# (the Darwin ld is a bit single minded)
197
199
#
198
200
# 1) compilation with -fvisibility=hidden causes trouble when we try to
@@ -202,7 +204,9 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
202
204
# 2) all stripping commands (e.g., -dead_strip) remove the __LLVM segment after
203
205
# linking
204
206
#
205
- '-fvisibility=hidden' : (0 , ArgumentListFilter .darwinWarningCompileUnaryCallback ),
207
+ # Update: found a fix for problem 1: add flag -keep_private_externs when
208
+ # calling ld -r.
209
+ #
206
210
'-Wl,-dead_strip' : (0 , ArgumentListFilter .darwinWarningLinkUnaryCallback ),
207
211
208
212
}
@@ -333,13 +337,6 @@ def linkUnaryCallback(self, flag):
333
337
def compileUnaryCallback (self , flag ):
334
338
self .compileArgs .append (flag )
335
339
336
- def darwinWarningCompileUnaryCallback (self , flag ):
337
- if sys .platform .startswith ('darwin' ):
338
- _logger .warning ('The flag "{0}" cannot be used with this tool' .format (flag ))
339
- sys .exit (1 )
340
- else :
341
- self .compileArgs .append (flag )
342
-
343
340
def darwinWarningLinkUnaryCallback (self , flag ):
344
341
if sys .platform .startswith ('darwin' ):
345
342
_logger .warning ('The flag "{0}" cannot be used with this tool' .format (flag ))
@@ -490,7 +487,7 @@ def attachBitcodePathToObject(bcPath, outFileName):
490
487
491
488
# Now write our bitcode section
492
489
if (sys .platform .startswith ('darwin' )):
493
- objcopyCmd = ['ld' , '-r' , outFileName , '-sectcreate' , darwinSegmentName , darwinSectionName , f .name , '-o' , outFileName ]
490
+ objcopyCmd = ['ld' , '-r' , '-keep_private_externs' , outFileName , '-sectcreate' , darwinSegmentName , darwinSectionName , f .name , '-o' , outFileName ]
494
491
else :
495
492
objcopyCmd = ['objcopy' , '--add-section' , '{0}={1}' .format (elfSectionName , f .name ), outFileName ]
496
493
orc = 0
@@ -683,8 +680,8 @@ def linkFiles(builder, objectFiles):
683
680
af = builder .getBitcodeArglistFilter ()
684
681
outputFile = af .getOutputFilename ()
685
682
cc = builder .getCompiler ()
686
- cc .extend (af .objectFiles )
687
683
cc .extend (objectFiles )
684
+ cc .extend (af .objectFiles )
688
685
cc .extend (af .linkArgs )
689
686
cc .extend (['-o' , outputFile ])
690
687
proc = Popen (cc )
0 commit comments