Skip to content

Commit ef21020

Browse files
committed
Trying to unify the behavior of wllvm and gllvm when compiling the linux kernel.
1 parent cd362e1 commit ef21020

File tree

6 files changed

+56
-24
lines changed

6 files changed

+56
-24
lines changed

wllvm/arglistfilter.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
9797
'-mretpoline-external-thunk': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
9898
'-mno-fp-ret-in-387': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
9999
'-mskip-rax-setup': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
100-
100+
'-mindirect-branch-register': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
101101
# Preprocessor assertion
102102
'-A' : (1, ArgumentListFilter.compileBinaryCallback),
103103
'-D' : (1, ArgumentListFilter.compileBinaryCallback),
@@ -201,13 +201,10 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
201201
'--coverage' : (0, ArgumentListFilter.compileLinkUnaryCallback),
202202

203203
# ian's additions while building the linux kernel
204-
205204
'/dev/null' : (0, ArgumentListFilter.inputFileCallback),
206205
'-mno-80387': (0, ArgumentListFilter.compileUnaryCallback), #gcc Don't generate output containing 80387 instructions for floating point.
207-
"-mregparm=3"
208-
"-march=i386"
209206

210-
207+
211208
#
212209
# BD: need to warn the darwin user that these flags will rain on their parade
213210
# (the Darwin ld is a bit single minded)
@@ -258,14 +255,17 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
258255
r'^-std=.+$' : (0, ArgumentListFilter.compileUnaryCallback),
259256
r'^-stdlib=.+$' : (0, ArgumentListFilter.compileLinkUnaryCallback),
260257
r'^-mtune=.+$' : (0, ArgumentListFilter.compileUnaryCallback),
261-
r'^-mstack-alignment=.+$': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
262-
r'^-march=.+$': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
263-
r'^-mregparm=.+$': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
264-
r'^-mcmodel=.+$': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
265-
r'^-mpreferred-stack-boundary=.+$': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
266-
r'^-mindirect-branch=.+$': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
267-
268-
258+
r'^-mstack-alignment=.+$': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
259+
r'^-march=.+$': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
260+
r'^-mregparm=.+$': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
261+
r'^-mcmodel=.+$': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
262+
r'^-mpreferred-stack-boundary=.+$': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
263+
r'^-mindirect-branch=.+$': (0, ArgumentListFilter.compileUnaryCallback), #iam: linux kernel stuff
264+
r'^-mregparm=.+$' : (0, ArgumentListFilter.compileLinkUnaryCallback), #iam: linux kernel stuff
265+
r'^-march=.+$' : (0, ArgumentListFilter.compileLinkUnaryCallback), #iam: linux kernel stuff
266+
r'^--param=.+$' : (0, ArgumentListFilter.compileLinkUnaryCallback), #iam: linux kernel stuff
267+
268+
269269
#iam: mac stuff...
270270
r'-mmacosx-version-min=.+$' : (0, ArgumentListFilter.compileUnaryCallback),
271271

@@ -353,7 +353,7 @@ def skipBitcodeGeneration(self):
353353
if (self.isDependencyOnly and not self.isCompileOnly):
354354
return (True, "Dependency Only")
355355
return (False, "")
356-
356+
357357
def _shiftArgs(self, nargs):
358358
ret = []
359359
while nargs > 0:

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'.format(destination if destination else 'standard error'))
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: 8 additions & 3 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,13 +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, ....)
4146
(skipit, reason) = af.skipBitcodeGeneration()
4247
if skipit:
43-
_logger.info('No work to do: %s', reason)
48+
_logger.debug('No work to do: %s', reason)
4449
_logger.debug(af.__dict__)
4550
return rc
4651

@@ -50,7 +55,7 @@ def wcompile(mode):
5055
except Exception as e:
5156
_logger.warning('%s: exception case: %s', mode, str(e))
5257

53-
_logger.info('Calling %s returned %d', list(sys.argv), rc)
58+
_logger.debug('Calling %s returned %d', list(sys.argv), rc)
5459
return rc
5560

5661

wllvm/extraction.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,13 @@ def buildArchive(pArgs, bitCodeFiles):
340340

341341
# Pick output file path if outputFile not set
342342
if pArgs.outputFile is None:
343+
bcaExtension = '.' + bitCodeArchiveExtension
343344
if pArgs.inputFile.endswith('.a'):
344345
# Strip off .a suffix
345346
pArgs.outputFile = pArgs.inputFile[:-2]
346-
pArgs.outputFile += '.' + bitCodeArchiveExtension
347+
pArgs.outputFile += bcaExtension
348+
else:
349+
pArgs.outputFile = pArgs.inputFile + bcaExtension
347350

348351
_logger.info('Writing output to %s', pArgs.outputFile)
349352

wllvm/logconfig.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,8 @@ def logConfig(name):
4545
h.setFormatter(formatter)
4646

4747
return retval
48+
49+
def loggingConfiguration():
50+
destination = os.getenv(_loggingDestination)
51+
level = os.getenv(_loggingEnvLevel_new)
52+
return (destination, level)

wllvm/version.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@
6060
6161
1.1.5 - 3/14/2018 fixes suggested by Alexander Bakst
6262
63+
1.1.6 - 4/24/2018 fixes suggested by building the Linux kernel and trying to harmonize with gllvm.
64+
6365
6466
"""
6567

66-
wllvm_version = '1.1.5'
68+
wllvm_version = '1.1.6'
69+
wllvm_date = 'April 24th 2018'

0 commit comments

Comments
 (0)