Skip to content

Commit 4d9d1e0

Browse files
committed
Minor fixes to the FreeBSD contributions
On one code path, a reference to `af` should have been `self`. There is also a semantic change to handle odd uses of dependency-generation flags that arises in libtool/autotools-based build systems. These seem to sometimes include dependency flags (-MT and friends) during compilation (which probably has no effect). The problem is that when these flags are really used for dependency generation (and no code generation), we really should not invoke clang to generate bitcode since it will fail. On the other hand, we can't just bail out when we see these -M* flags, since they might be misused in a real compilation step. This change tries to compromise: we only skip bitcode generation when we see a -M* dependency flag and NO accompanying `-c` flag. This should work in the vast majority of cases, since real makefile dependency generation should never use the -c flag.
1 parent ff2a182 commit 4d9d1e0

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

driver/utils.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,12 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
234234

235235
#iam: parse the cmd line, bailing if we discover that there will be no second phase.
236236
while ( len(self._inputArgs) > 0 and
237-
not (af.isAssembly or
238-
af.isAssembleOnly or
239-
af.isDependencyOnly or
240-
af.isPreprocessOnly ) ):
237+
not (self.isAssembly or
238+
self.isAssembleOnly or
239+
self.isPreprocessOnly ) ):
241240
# Get the next argument
242241
currentItem = self._inputArgs.popleft()
242+
_logger.debug('Trying to match item ' + currentItem)
243243
# First, see if this exact flag has a handler in the table.
244244
# This is a cheap test. Otherwise, see if the input matches
245245
# some pattern with a handler that we recognize
@@ -277,6 +277,7 @@ def abortUnaryCallback(self, flag):
277277
sys.exit(1)
278278

279279
def inputFileCallback(self, infile):
280+
_logger.debug('Input file: ' + infile)
280281
self.inputFiles.append(infile)
281282
if re.search('\\.(s|S)', infile):
282283
self.isAssembly = True
@@ -292,6 +293,7 @@ def preprocessOnlyCallback(self, flag):
292293

293294
def dependencyOnlyCallback(self, flag):
294295
self.isDependencyOnly = True
296+
self.compileArgs.append(flag)
295297

296298
def assembleOnlyCallback(self, flag):
297299
self.isAssembleOnly = True
@@ -313,6 +315,8 @@ def defaultBinaryCallback(self, flag, arg):
313315

314316
def dependencyBinaryCallback(self, flag, arg):
315317
self.isDependencyOnly = True
318+
self.compileArgs.append(flag)
319+
self.compileArgs.append(arg)
316320

317321
def compileBinaryCallback(self, flag, arg):
318322
self.compileArgs.append(flag)
@@ -579,8 +583,10 @@ def buildAndAttachBitcode(builder):
579583
if ( len(af.inputFiles) == 0 or
580584
af.isAssembly or
581585
af.isAssembleOnly or
582-
af.isDependencyOnly or
586+
(af.isDependencyOnly and not af.isCompileOnly) or
583587
af.isPreprocessOnly ):
588+
_logger.debug('No work to do')
589+
_logger.debug(af.__dict__)
584590
return
585591

586592
#iam: when we have multiple input files we'll have to keep track of their object files.

0 commit comments

Comments
 (0)