32
32
# Internal logger
33
33
_logger = logging .getLogger (__name__ )
34
34
35
- # Flag for debugging
36
- DEBUG = False
35
+ # Flag for dumping
36
+ DUMPING = False
37
37
38
38
39
39
# This class applies filters to GCC argument lists. It has a few
@@ -179,11 +179,15 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
179
179
'-static' : (0 , ArgumentListFilter .linkUnaryCallback ),
180
180
'-nostdlib' : (0 , ArgumentListFilter .linkUnaryCallback ),
181
181
'-nodefaultlibs' : (0 , ArgumentListFilter .linkUnaryCallback ),
182
+ '-rdynamic' : (0 , ArgumentListFilter .linkUnaryCallback ),
182
183
# darwin flags
183
184
'-dynamiclib' : (0 , ArgumentListFilter .linkUnaryCallback ),
184
185
'-current_version' : (1 , ArgumentListFilter .linkBinaryCallback ),
185
186
'-compatibility_version' : (1 , ArgumentListFilter .linkBinaryCallback ),
186
187
188
+ # dragonegg mystery argument
189
+ '--64' : (0 , ArgumentListFilter .compileUnaryCallback ),
190
+
187
191
#
188
192
# BD: need to warn the darwin user that these flags will rain on their parade
189
193
# (the Darwin ld is a bit single minded)
@@ -278,7 +282,7 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
278
282
_logger .warning ('Did not recognize the compiler flag "{0}"' .format (currentItem ))
279
283
self .compileUnaryCallback (currentItem )
280
284
281
- if DEBUG :
285
+ if DUMPING :
282
286
self .dump ()
283
287
284
288
def _shiftArgs (self , nargs ):
@@ -296,7 +300,7 @@ def abortUnaryCallback(self, flag):
296
300
def inputFileCallback (self , infile ):
297
301
_logger .debug ('Input file: ' + infile )
298
302
self .inputFiles .append (infile )
299
- if re .search ('\\ .(s|S)' , infile ):
303
+ if re .search ('\\ .(s|S)$ ' , infile ):
300
304
self .isAssembly = True
301
305
302
306
def outputFileCallback (self , flag , filename ):
@@ -364,7 +368,7 @@ def getOutputFilename(self):
364
368
365
369
# iam: returns a pair [objectFilename, bitcodeFilename] i.e .o and .bc.
366
370
# the hidden flag determines whether the objectFile is hidden like the
367
- # bitcodeFile is (starts with a '.'), use the DEBUG flag to get a sense
371
+ # bitcodeFile is (starts with a '.'), use the logging level & DUMPING flag to get a sense
368
372
# of what is being written out.
369
373
def getArtifactNames (self , srcFile , hidden = False ):
370
374
(srcpath , srcbase ) = os .path .split (srcFile )
@@ -381,15 +385,15 @@ def getArtifactNames(self, srcFile, hidden=False):
381
385
382
386
#iam: for printing our partitioning of the args
383
387
def dump (self ):
384
- print ( " compileArgs: " , self .compileArgs )
385
- print ( " inputFiles: " , self .inputFiles )
386
- print ( " linkArgs: " , self .linkArgs )
387
- print ( " objectFiles: " , self .objectFiles )
388
- print ( " outputFilename: " , self .outputFilename )
388
+ _logger . debug ( ' compileArgs: {0}' . format ( self .compileArgs ) )
389
+ _logger . debug ( ' inputFiles: {0}' . format ( self .inputFiles ) )
390
+ _logger . debug ( ' linkArgs: {0}' . format ( self .linkArgs ) )
391
+ _logger . debug ( ' objectFiles: {0}' . format ( self .objectFiles ) )
392
+ _logger . debug ( ' outputFilename: {0}' . format ( self .outputFilename ) )
389
393
for srcFile in self .inputFiles :
390
- print ( " srcFile: " , srcFile )
394
+ _logger . debug ( ' srcFile: {0}' . format ( srcFile ) )
391
395
(objFile , bcFile ) = self .getArtifactNames (srcFile )
392
- print ( " {0} ===> ({1}, {2})" .format (srcFile , objFile , bcFile ))
396
+ _logger . debug ( ' {0} ===> ({1}, {2})' .format (srcFile , objFile , bcFile ))
393
397
394
398
395
399
@@ -455,6 +459,7 @@ def attachBitcodePathToObject(bcPath, outFileName):
455
459
# Don't try to attach a bitcode path to a binary. Unfortunately
456
460
# that won't work.
457
461
(root , ext ) = os .path .splitext (outFileName )
462
+ _logger .debug ('attachBitcodePathToObject: {0} ===> {1} [ext = {2}]\n ' .format (bcPath , outFileName , ext ))
458
463
#iam: this also looks very dodgey; we need a more reliable way to do this:
459
464
if ext not in ('.o' , '.lo' , '.os' , '.So' , '.po' ):
460
465
_logger .warning ('Cannot attach bitcode path to "{0} of type {1}"' .format (outFileName , FileType .getFileType (outFileName )))
@@ -520,6 +525,12 @@ def __init__(self, cmd, isCxx, prefixPath=None):
520
525
else :
521
526
self .prefixPath = ''
522
527
528
+ #clang and drogonegg share the same taste in bitcode filenames.
529
+ def getBitcodeFileName (self , argFilter ):
530
+ (dirs , baseFile ) = os .path .split (argFilter .getOutputFilename ())
531
+ bcfilename = os .path .join (dirs , '.{0}.bc' .format (baseFile ))
532
+ return bcfilename
533
+
523
534
class ClangBuilder (BuilderBase ):
524
535
def __init__ (self , cmd , isCxx , prefixPath = None ):
525
536
super (ClangBuilder , self ).__init__ (cmd , isCxx , prefixPath )
@@ -537,11 +548,6 @@ def getCompiler(self):
537
548
def getBitcodeArglistFilter (self ):
538
549
return ClangBitcodeArgumentListFilter (self .cmd )
539
550
540
- def getBitcodeFileName (self , argFilter ):
541
- (dirs , baseFile ) = os .path .split (argFilter .getOutputFilename ())
542
- bcfilename = os .path .join (dirs , '.{0}.bc' .format (baseFile ))
543
- return bcfilename
544
-
545
551
def extraBitcodeArgs (self , argFilter ):
546
552
bcPath = self .getBitcodeFileName (argFilter )
547
553
return ['-o' , bcPath ]
@@ -562,8 +568,9 @@ def getBitcodeCompiler(self):
562
568
# We use '-B' to tell gcc where to look for an assembler.
563
569
# When we build LLVM bitcode we do not want to use the GNU assembler,
564
570
# instead we want gcc to use our own assembler (see driver/as).
565
- return cc + ['-B' , driverDir , '-fplugin={0}' .format (pth ),
566
- '-fplugin-arg-dragonegg-emit-ir' ]
571
+ cmd = cc + ['-B' , driverDir , '-fplugin={0}' .format (pth ), '-fplugin-arg-dragonegg-emit-ir' ]
572
+ _logger .debug (cmd )
573
+ return cmd
567
574
568
575
def getCompiler (self ):
569
576
pfx = ''
@@ -687,6 +694,7 @@ def buildBitcodeFile(builder, srcFile, bcFile):
687
694
bcc .extend (af .compileArgs )
688
695
bcc .extend (['-c' , srcFile ])
689
696
bcc .extend (['-o' , bcFile ])
697
+ _logger .debug ('buildBitcodeFile: {0}\n ' .format (bcc ))
690
698
proc = Popen (bcc )
691
699
rc = proc .wait ()
692
700
if rc != 0 :
@@ -699,6 +707,7 @@ def buildObjectFile(builder, srcFile, objFile):
699
707
cc .extend (af .compileArgs )
700
708
cc .append (srcFile )
701
709
cc .extend (['-c' , '-o' , objFile ])
710
+ _logger .debug ('buildObjectFile: {0}\n ' .format (cc ))
702
711
proc = Popen (cc )
703
712
rc = proc .wait ()
704
713
if rc != 0 :
0 commit comments