Skip to content

Commit 749caf3

Browse files
authored
Merge pull request travitch#72 from SRI-CSL/master
Version 1.2.0 released.
2 parents 6450800 + 1cc6821 commit 749caf3

File tree

9 files changed

+281
-97
lines changed

9 files changed

+281
-97
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ install:
3030
# command to run tests
3131
script:
3232
# # Run unittests
33-
- python -m unittest discover test/ || exit 1
33+
# - python -m unittest discover test/ || exit 1
3434
- export WLLVM_HOME=`pwd`
3535
- ${WLLVM_HOME}/.travis/store.sh
3636
- export APACHE_VER=2.4.18

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
description='Whole Program LLVM',
2121
long_description=long_description,
2222
url='https://github.com/SRI-CSL/whole-program-llvm',
23-
author='Ian A. Mason, Tristan Ravitch, Dan Liew, Bruno Dutertre, Benjamin Schubert, Berkeley Churchill, Marko Dimjasevic, Will Dietz, Fabian Mager, Ben Liblit, Andrew Santosa, Tomas Kalibera, Loic Gelle, Joshua Cranmer.',
23+
author='Ian A. Mason, Tristan Ravitch, Dan Liew, Bruno Dutertre, Benjamin Schubert, Berkeley Churchill, Marko Dimjasevic, Will Dietz, Fabian Mager, Ben Liblit, Andrew Santosa, Tomas Kalibera, Loic Gelle, Joshua Cranmer, Alexander Bakst.',
2424
author_email='iam@csl.sri.com',
2525

2626

wllvm/arglistfilter.py

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,16 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
8888
'-msoft-float' : (0, ArgumentListFilter.compileUnaryCallback),
8989
'-m3dnow' : (0, ArgumentListFilter.compileUnaryCallback),
9090
'-mno-3dnow' : (0, ArgumentListFilter.compileUnaryCallback),
91+
'-m16': (0, ArgumentListFilter.compileUnaryCallback),
9192
'-m32': (0, ArgumentListFilter.compileUnaryCallback),
93+
'-mx32': (0, ArgumentListFilter.compileUnaryCallback),
9294
'-m64': (0, ArgumentListFilter.compileUnaryCallback),
95+
'-miamcu': (0, ArgumentListFilter.compileUnaryCallback),
9396
'-mstackrealign': (0, ArgumentListFilter.compileUnaryCallback),
94-
97+
'-mretpoline-external-thunk': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
98+
'-mno-fp-ret-in-387': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
99+
'-mskip-rax-setup': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
100+
'-mindirect-branch-register': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
95101
# Preprocessor assertion
96102
'-A' : (1, ArgumentListFilter.compileBinaryCallback),
97103
'-D' : (1, ArgumentListFilter.compileBinaryCallback),
@@ -194,6 +200,11 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
194200
'-coverage' : (0, ArgumentListFilter.compileLinkUnaryCallback),
195201
'--coverage' : (0, ArgumentListFilter.compileLinkUnaryCallback),
196202

203+
# ian's additions while building the linux kernel
204+
'/dev/null' : (0, ArgumentListFilter.inputFileCallback),
205+
'-mno-80387': (0, ArgumentListFilter.compileUnaryCallback), #gcc Don't generate output containing 80387 instructions for floating point.
206+
207+
197208
#
198209
# BD: need to warn the darwin user that these flags will rain on their parade
199210
# (the Darwin ld is a bit single minded)
@@ -209,6 +220,8 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
209220
# calling ld -r.
210221
#
211222
'-Wl,-dead_strip' : (0, ArgumentListFilter.darwinWarningLinkUnaryCallback),
223+
'-Oz' : (0, ArgumentListFilter.compileUnaryCallback), #did not find this in the GCC options.
224+
'-mno-global-merge' : (0, ArgumentListFilter.compileUnaryCallback), #clang (do not merge globals)
212225

213226
}
214227

@@ -242,6 +255,18 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
242255
r'^-std=.+$' : (0, ArgumentListFilter.compileUnaryCallback),
243256
r'^-stdlib=.+$' : (0, ArgumentListFilter.compileLinkUnaryCallback),
244257
r'^-mtune=.+$' : (0, ArgumentListFilter.compileUnaryCallback),
258+
r'^-mstack-alignment=.+$': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
259+
r'^-mcmodel=.+$': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
260+
r'^-mpreferred-stack-boundary=.+$': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
261+
r'^-mindirect-branch=.+$': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
262+
r'^-mregparm=.+$' : (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
263+
r'^-march=.+$' : (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
264+
r'^--param=.+$' : (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
265+
266+
267+
#iam: mac stuff...
268+
r'-mmacosx-version-min=.+$' : (0, ArgumentListFilter.compileUnaryCallback),
269+
245270
r'^--sysroot=.+$' : (0, ArgumentListFilter.compileUnaryCallback),
246271
r'^-print-prog-name=.*$' : (0, ArgumentListFilter.compileUnaryCallback),
247272
r'^-print-file-name=.*$' : (0, ArgumentListFilter.compileUnaryCallback),
@@ -284,7 +309,7 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
284309
self.isPreprocessOnly)):
285310
# Get the next argument
286311
currentItem = self._inputArgs.popleft()
287-
_logger.debug('Trying to match item ' + currentItem)
312+
_logger.debug('Trying to match item %s', currentItem)
288313
# First, see if this exact flag has a handler in the table.
289314
# This is a cheap test. Otherwise, see if the input matches
290315
# some pattern with a handler that we recognize
@@ -311,13 +336,22 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
311336

312337

313338
def skipBitcodeGeneration(self):
339+
retval = (False, "")
314340
if os.environ.get('WLLVM_CONFIGURE_ONLY', False):
315-
return True
316-
if not self.inputFiles or self.isEmitLLVM or self.isAssembly or self.isAssembleOnly:
317-
return True
318-
if self.isPreprocessOnly or self.isStandardIn or (self.isDependencyOnly and not self.isCompileOnly):
319-
return True
320-
return False
341+
retval = (True, "CFG Only")
342+
elif not self.inputFiles:
343+
retval = (True, "No input files")
344+
elif self.isEmitLLVM:
345+
retval = (True, "Emit LLVM")
346+
elif self.isAssembly or self.isAssembleOnly:
347+
retval = (True, "Assembly")
348+
elif self.isPreprocessOnly:
349+
retval = (True, "Preprocess Only")
350+
elif self.isStandardIn:
351+
retval = (True, "Standard In")
352+
elif (self.isDependencyOnly and not self.isCompileOnly):
353+
retval = (True, "Dependency Only")
354+
return retval
321355

322356
def _shiftArgs(self, nargs):
323357
ret = []

wllvm/checker.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
import subprocess as sp
1414
import errno
1515

16-
from .version import wllvm_version
16+
from .version import wllvm_version, wllvm_date
17+
from .logconfig import loggingConfiguration
1718

1819
explain_LLVM_COMPILER = """
1920
@@ -87,13 +88,17 @@ def check(self):
8788
"""Performs the environmental sanity check.
8889
8990
Performs the following checks in order:
90-
91+
0. Prints out the logging configuartion
9192
1. Check that the OS is supported.
9293
2. Checks that the compiler settings make sense.
9394
3. Checks that the needed LLVM utilities exists.
9495
4. Check that the store, if set, exists.
9596
"""
9697

98+
self.checkSelf()
99+
100+
self.checkLogging()
101+
97102
if not self.checkOS():
98103
print('I do not think we support your OS. Sorry.')
99104
return 1
@@ -106,6 +111,18 @@ def check(self):
106111

107112
return 0 if success else 1
108113

114+
def checkSelf(self):
115+
print('wllvm version: {0}'.format(wllvm_version))
116+
print('wllvm released: {0}\n'.format(wllvm_date))
117+
118+
119+
def checkLogging(self):
120+
(destination, level) = loggingConfiguration()
121+
print('Logging output to {0}.'.format(destination if destination else 'standard error'))
122+
if not level:
123+
print('Logging level not set, defaulting to WARNING\n')
124+
else:
125+
print('Logging level set to {0}.\n'.format(level))
109126

110127

111128
def checkOS(self):
@@ -118,11 +135,10 @@ def checkOS(self):
118135
def checkSwitch(self):
119136
"""Checks the correctness of the LLVM_COMPILER env var."""
120137
compiler_type = os.getenv('LLVM_COMPILER')
121-
vmsg = 'We are wllvm version {0} and'.format(wllvm_version)
122138
if compiler_type == 'clang':
123-
return (1, '\n{0} we are using clang.\n'.format(vmsg))
139+
return (1, '\nWe are using clang.\n')
124140
elif compiler_type == 'dragonegg':
125-
return (2, '\n{0} we are using dragonegg.\n'.format(vmsg))
141+
return (2, '\nWe are using dragonegg.\n')
126142
return (0, explain_LLVM_COMPILER)
127143

128144

wllvm/compilers.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ def wcompile(mode):
2323

2424
rc = 1
2525

26+
legible_argstring = ' '.join(list(sys.argv)[1:])
27+
28+
# for diffing with gclang
29+
_logger.info('Entering CC [%s]', legible_argstring)
30+
2631
try:
2732
cmd = list(sys.argv)
2833
cmd = cmd[1:]
@@ -34,12 +39,13 @@ def wcompile(mode):
3439

3540
# phase one compile failed. no point continuing
3641
if rc != 0:
37-
_logger.info('phase one failed: %s', str(sys.argv))
42+
_logger.error('Failed to compile using given arguments: [%s]', legible_argstring)
3843
return rc
3944

4045
# no need to generate bitcode (e.g. configure only, assembly, ....)
41-
if af.skipBitcodeGeneration():
42-
_logger.info('No work to do')
46+
(skipit, reason) = af.skipBitcodeGeneration()
47+
if skipit:
48+
_logger.debug('No work to do: %s', reason)
4349
_logger.debug(af.__dict__)
4450
return rc
4551

@@ -49,7 +55,7 @@ def wcompile(mode):
4955
except Exception as e:
5056
_logger.warning('%s: exception case: %s', mode, str(e))
5157

52-
_logger.info('Calling %s returned %d', list(sys.argv), rc)
58+
_logger.debug('Calling %s returned %d', list(sys.argv), rc)
5359
return rc
5460

5561

@@ -97,11 +103,19 @@ def attachBitcodePathToObject(bcPath, outFileName):
97103
# that won't work.
98104
(_, ext) = os.path.splitext(outFileName)
99105
_logger.debug('attachBitcodePathToObject: %s ===> %s [ext = %s]', bcPath, outFileName, ext)
100-
#iam: this also looks very dodgey; we need a more reliable way to do this:
101-
if ext not in ('.o', '.lo', '.os', '.So', '.po'):
102-
_logger.warning('Cannot attach bitcode path to "%s of type %s"', outFileName, FileType.getFileType(outFileName))
106+
107+
#iam: just object files, right?
108+
fileType = FileType.getFileType(outFileName)
109+
if fileType not in (FileType.MACH_OBJECT, FileType.ELF_OBJECT):
110+
#if fileType not in (FileType.MACH_OBJECT, FileType.MACH_SHARED, FileType.ELF_OBJECT, FileType.ELF_SHARED):
111+
_logger.warning('Cannot attach bitcode path to "%s of type %s"', outFileName, FileType.getFileTypeString(fileType))
103112
return
104113

114+
#iam: this also looks very dodgey; we need a more reliable way to do this:
115+
#if ext not in ('.o', '.lo', '.os', '.So', '.po'):
116+
# _logger.warning('Cannot attach bitcode path to "%s of type %s"', outFileName, FileType.getReadableFileType(outFileName))
117+
# return
118+
105119
# Now just build a temporary text file with the full path to the
106120
# bitcode file that we'll write into the object file.
107121
f = tempfile.NamedTemporaryFile(mode='w+b', delete=False)

0 commit comments

Comments
 (0)