Skip to content

Commit 2af7a03

Browse files
author
Tristan Ravitch
committed
Do not make bitcode when in assemble-only mode (-S)
If we let the second compilation stage make bitcode, the driver will dump the result into an assembly file (overwriting the real assembly output from the first stage). The result will be LLVM assembly, which will make the rest of the compilation fail.
1 parent e65308d commit 2af7a03

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

driver/utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
3434
'-o' : (1, ArgumentListFilter.outputFileCallback),
3535
'-c' : (0, ArgumentListFilter.compileOnlyCallback),
3636
'-E' : (0, ArgumentListFilter.preprocessOnlyCallback),
37+
'-S' : (0, ArgumentListFilter.assembleOnlyCallback),
3738
'--verbose' : (0, ArgumentListFilter.verboseFlagCallback),
3839
'--param' : (1, ArgumentListFilter.defaultOneArgument),
3940
'-aux-info' : (1, ArgumentListFilter.defaultOneArgument),
@@ -83,6 +84,7 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
8384
self.outputFilename = None
8485
self.isVerbose = False
8586
self.isPreprocessOnly = False
87+
self.isAssembleOnly = False
8688
self.isAssembly = False
8789
self.isCompileOnly = False
8890

@@ -135,6 +137,10 @@ def preprocessOnlyCallback(self, flag):
135137
self.isPreprocessOnly = True
136138
self.keepArgument(flag)
137139

140+
def assembleOnlyCallback(self, flag):
141+
self.isAssembleOnly = True
142+
self.keepArgument(flag)
143+
138144
def verboseFlagCallback(self, flag):
139145
self.isVerbose = True
140146

@@ -307,7 +313,7 @@ def isLinkOption(arg):
307313
# This command does not have the executable with it
308314
def buildAndAttachBitcode(builder):
309315
af = builder.getBitcodeArglistFilter()
310-
if len(af.inputFiles) == 0 or af.isAssembly:
316+
if len(af.inputFiles) == 0 or af.isAssembly or af.isAssembleOnly:
311317
return
312318
bcc = builder.getBitcodeCompiler()
313319
bcc.extend(af.filteredArgs)

0 commit comments

Comments
 (0)