Skip to content

Commit b5cbb65

Browse files
authored
Merge pull request travitch#57 from SRI-CSL/master
-emit-llvm fix
2 parents 16e4fa6 + 1d9b553 commit b5cbb65

File tree

6 files changed

+51
-17
lines changed

6 files changed

+51
-17
lines changed

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ max-attributes=20
369369
min-public-methods=0
370370

371371
# Maximum number of public methods for a class (see R0904).
372-
max-public-methods=20
372+
max-public-methods=30
373373

374374
# Maximum number of boolean expressions in a if statement
375375
max-bool-expr=10

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ check_clang:
5858
check_dragonegg:
5959
cd test; python -m unittest -v test_base_driver test_dragonegg_driver
6060

61-
6261
zippity:
6362
rm -rf doczip*; mkdir doczip;
6463
cat README.md | pandoc -f markdown_github > doczip/index.html

test/test_files/Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,39 @@
44
zero:
55
${CXX} hello.cc -o hello
66

7+
zero_e:
8+
${CXX} hello.cc -emit-llvm -c
9+
${CXX} hello.bc -o hello
10+
11+
12+
e:
13+
${CC} -emit-llvm foo.c -c
14+
${CC} -emit-llvm bar.c -c
15+
${CC} -emit-llvm baz.c -c
16+
${CC} -emit-llvm main.c -c
17+
${CC} foo.bc bar.bc baz.bc main.bc -o main
18+
19+
720
one:
821
${CC} foo.c bar.c baz.c main.c -o main
922

1023
two:
1124
${CC} foo.c bar.c baz.c main.c -c
1225
${CC} foo.o bar.o baz.o main.o -o main
1326

27+
two_e:
28+
${CC} -emit-llvm foo.c bar.c baz.c main.c -c
29+
${CC} foo.bc bar.bc baz.bc main.bc -o main
30+
1431
mix:
1532
${CC} foo.c bar.c -c
1633
${CC} foo.o bar.o baz.c main.c -o main
1734

35+
mix_e:
36+
${CC} -emit-llvm foo.c bar.c -c
37+
${CC} foo.bc bar.bc baz.c main.c -o main
38+
39+
1840
objects:
1941
${CC} foo.c -c
2042
${CC} bar.c -c

wllvm/arglistfilter.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
5050

5151

5252
#iam: if this happens, then we need to stop and think.
53-
'-emit-llvm' : (0, ArgumentListFilter.abortUnaryCallback),
53+
'-emit-llvm' : (0, ArgumentListFilter.emitLLVMCallback),
5454

5555
#iam: buildworld and buildkernel use these flags
5656
'-pipe' : (0, ArgumentListFilter.compileUnaryCallback),
@@ -212,7 +212,7 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
212212
# - optimiziation and other flags: -f...
213213
#
214214
defaultArgPatterns = {
215-
r'^.+\.(c|cc|cpp|C|cxx|i|s|S)$' : (0, ArgumentListFilter.inputFileCallback),
215+
r'^.+\.(c|cc|cpp|C|cxx|i|s|S|bc)$' : (0, ArgumentListFilter.inputFileCallback),
216216
#iam: the object file recogition is not really very robust, object files
217217
# should be determined by their existance and contents...
218218
r'^.+\.(o|lo|So|so|po|a|dylib)$' : (0, ArgumentListFilter.objectFileCallback),
@@ -226,6 +226,7 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
226226
r'^-Wl,.+$' : (0, ArgumentListFilter.linkUnaryCallback),
227227
r'^-W(?!l,).*$' : (0, ArgumentListFilter.compileUnaryCallback),
228228
r'^-f.+$' : (0, ArgumentListFilter.compileUnaryCallback),
229+
r'^-rtlib=.+$' : (0, ArgumentListFilter.linkUnaryCallback),
229230
r'^-std=.+$' : (0, ArgumentListFilter.compileUnaryCallback),
230231
r'^-stdlib=.+$' : (0, ArgumentListFilter.compileLinkUnaryCallback),
231232
r'^-mtune=.+$' : (0, ArgumentListFilter.compileUnaryCallback),
@@ -252,6 +253,8 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
252253
self.isAssembleOnly = False
253254
self.isAssembly = False
254255
self.isCompileOnly = False
256+
self.isEmitLLVM = False
257+
255258

256259
argExactMatches = dict(defaultArgExactMatches)
257260
argExactMatches.update(exactMatches)
@@ -339,6 +342,11 @@ def compileOnlyCallback(self, flag):
339342
_logger.debug('compileOnlyCallback: %s', flag)
340343
self.isCompileOnly = True
341344

345+
def emitLLVMCallback(self, flag):
346+
_logger.debug('emitLLVMCallback: %s', flag)
347+
self.isEmitLLVM = True
348+
self.isCompileOnly = True
349+
342350
def linkUnaryCallback(self, flag):
343351
_logger.debug('linkUnaryCallback: %s', flag)
344352
self.linkArgs.append(flag)
@@ -411,11 +419,10 @@ def getArtifactNames(self, srcFile, hidden=False):
411419

412420
#iam: for printing our partitioning of the args
413421
def dump(self):
414-
_logger.debug('compileArgs: %s\ninputFiles: %s\nlinkArgs: %s',
415-
self.compileArgs, self.inputFiles, self.linkArgs)
416-
_logger.debug('objectFiles: %s\noutputFilename: %s',
417-
self.objectFiles, self.outputFilename)
422+
efn = sys.stderr.write
423+
efn('\ncompileArgs: {0}\ninputFiles: {1}\nlinkArgs: {2}\n'.format(self.compileArgs, self.inputFiles, self.linkArgs))
424+
efn('\nobjectFiles: {0}\noutputFilename: {1}\n'.format(self.objectFiles, self.outputFilename))
418425
for srcFile in self.inputFiles:
419-
_logger.debug('srcFile: %s', srcFile)
426+
efn('\nsrcFile: {0}\n'.format(srcFile))
420427
(objFile, bcFile) = self.getArtifactNames(srcFile)
421-
_logger.debug('%s ===> (%s, %s)', srcFile, objFile, bcFile)
428+
efn('\n{0} ===> ({1}, {2})\n'.format(srcFile, objFile, bcFile))

wllvm/compilers.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ def wcompile(isCXX):
2828
builder = getBuilder(cmd, isCXX)
2929
rc = buildObject(builder)
3030

31-
3231
if rc == 0 and not os.environ.get('WLLVM_CONFIGURE_ONLY', False):
3332
buildAndAttachBitcode(builder)
3433
except Exception as e:
35-
_logger.debug('wllvm++: exception case: %s', str(e))
34+
_logger.debug('%s: exception case: %s', "wllvm++" if isCXX else "wllvm", str(e))
3635

3736
return rc
3837

@@ -141,7 +140,7 @@ def __init__(self, cmd, isCxx, prefixPath=None):
141140
else:
142141
self.prefixPath = ''
143142

144-
#clang and drogonegg share the same taste in bitcode filenames.
143+
#clang and dragonegg share the same taste in bitcode filenames.
145144
def getBitcodeFileName(self, argFilter):
146145
(dirs, baseFile) = os.path.split(argFilter.getOutputFilename())
147146
bcfilename = os.path.join(dirs, '.{0}.bc'.format(baseFile))
@@ -252,7 +251,7 @@ def buildAndAttachBitcode(builder):
252251

253252
af = builder.getBitcodeArglistFilter()
254253

255-
if len(af.inputFiles) == 0 or af.isAssembly or af.isAssembleOnly or (af.isDependencyOnly and not af.isCompileOnly) or af.isPreprocessOnly:
254+
if len(af.inputFiles) == 0 or af.isEmitLLVM or af.isAssembly or af.isAssembleOnly or (af.isDependencyOnly and not af.isCompileOnly) or af.isPreprocessOnly:
256255
_logger.debug('No work to do')
257256
_logger.debug(af.__dict__)
258257
return
@@ -281,12 +280,19 @@ def buildAndAttachBitcode(builder):
281280
else:
282281

283282
for srcFile in af.inputFiles:
283+
_logger.debug('Not compile only case: %s', srcFile)
284284
(objFile, bcFile) = af.getArtifactNames(srcFile, hidden)
285285
if hidden:
286286
buildObjectFile(builder, srcFile, objFile)
287287
newObjectFiles.append(objFile)
288-
buildBitcodeFile(builder, srcFile, bcFile)
289-
attachBitcodePathToObject(bcFile, objFile)
288+
289+
if srcFile.endswith('.bc'):
290+
_logger.debug('attaching %s to %s', srcFile, objFile)
291+
attachBitcodePathToObject(srcFile, objFile)
292+
else:
293+
_logger.debug('building and attaching %s to %s', bcFile, objFile)
294+
buildBitcodeFile(builder, srcFile, bcFile)
295+
attachBitcodePathToObject(bcFile, objFile)
290296

291297

292298
if not af.isCompileOnly:

wllvm/wllvm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
def main():
19-
""" The entry point to wllvm++.
19+
""" The entry point to wllvm.
2020
"""
2121
return wcompile(False)
2222

0 commit comments

Comments
 (0)