Skip to content

Commit 4649b8b

Browse files
committed
Annual spring clean and apache version bump
1 parent 6d8955b commit 4649b8b

File tree

9 files changed

+99
-100
lines changed

9 files changed

+99
-100
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ python:
1414
install:
1515
- sudo apt-get update
1616
# apache prerequisites
17-
- sudo apt-get install -y libapr1-dev libaprutil1-dev
17+
- sudo apt-get install -y libapr1-dev libaprutil1-dev libpcre3-dev
1818
# for the clang build
1919
- sudo apt-get install -y llvm-3.5 clang-3.5
2020
# dragonegg prereqs. dragonegg and llvm-gcc use llvm 3.3
@@ -34,7 +34,7 @@ script:
3434
- export WLLVM_HOME=`pwd`
3535
- ${WLLVM_HOME}/.travis/store.sh
3636
- export APACHE_URL=https://www-us.apache.org/dist/httpd/
37-
- export APACHE_VER=2.4.43
37+
- export APACHE_VER=2.4.46
3838
# build apache with clang
3939
- ${WLLVM_HOME}/.travis/apache_clang.sh
4040
# build apache with gcc and dragonegg

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ install:
4343
pip install
4444

4545
check_clang:
46-
cd test; python -m unittest -v test_base_driver test_clang_driver
46+
cd test; python3 -m unittest -v test_base_driver test_clang_driver
4747

4848
check_dragonegg:
49-
cd test; python -m unittest -v test_base_driver test_dragonegg_driver
49+
cd test; python3 -m unittest -v test_base_driver test_dragonegg_driver
5050

5151
clean:
5252
rm -f wllvm/*.pyc wllvm/*~

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
setup(
1818
name='wllvm',
1919
version=wllvm_version,
20+
python_requires='>=3.6',
2021
description='Whole Program LLVM',
2122
long_description=long_description,
2223
url='https://github.com/SRI-CSL/whole-program-llvm',

wllvm/arglistfilter.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# recognized by regular expressions. All regular expressions must be
2828
# tried, obviously. The first one that matches is taken, and no order
2929
# is specified. Try to avoid overlapping patterns.
30-
class ArgumentListFilter(object):
30+
class ArgumentListFilter:
3131
def __init__(self, inputList, exactMatches={}, patternMatches={}):
3232
defaultArgExactMatches = {
3333

@@ -465,16 +465,16 @@ def compileLinkUnaryCallback(self, flag):
465465
def getOutputFilename(self):
466466
if self.outputFilename is not None:
467467
return self.outputFilename
468-
elif self.isCompileOnly:
468+
if self.isCompileOnly:
469469
#iam: -c but no -o, therefore the obj should end up in the cwd.
470470
(_, base) = os.path.split(self.inputFiles[0])
471471
(root, _) = os.path.splitext(base)
472-
return '{0}.o'.format(root)
472+
return f'{root}.o'
473473
return 'a.out'
474474

475475
def getBitcodeFileName(self):
476476
(dirs, baseFile) = os.path.split(self.getOutputFilename())
477-
bcfilename = os.path.join(dirs, '.{0}.bc'.format(baseFile))
477+
bcfilename = os.path.join(dirs, f'.{baseFile}.bc')
478478
return bcfilename
479479

480480
# iam: returns a pair [objectFilename, bitcodeFilename] i.e .o and .bc.
@@ -485,18 +485,18 @@ def getArtifactNames(self, srcFile, hidden=False):
485485
(_, srcbase) = os.path.split(srcFile)
486486
(srcroot, _) = os.path.splitext(srcbase)
487487
if hidden:
488-
objbase = '.{0}.o'.format(srcroot)
488+
objbase = f'.{srcroot}.o'
489489
else:
490-
objbase = '{0}.o'.format(srcroot)
491-
bcbase = '.{0}.o.bc'.format(srcroot)
490+
objbase = f'{srcroot}.o'
491+
bcbase = f'.{srcroot}.o.bc'
492492
return [objbase, bcbase]
493493

494494
#iam: for printing our partitioning of the args
495495
def dump(self):
496496
efn = sys.stderr.write
497-
efn('\ncompileArgs: {0}\ninputFiles: {1}\nlinkArgs: {2}\n'.format(self.compileArgs, self.inputFiles, self.linkArgs))
498-
efn('\nobjectFiles: {0}\noutputFilename: {1}\n'.format(self.objectFiles, self.outputFilename))
497+
efn(f'\ncompileArgs: {self.compileArgs}\ninputFiles: {self.inputFiles}\nlinkArgs: {self.linkArgs}\n')
498+
efn(f'\nobjectFiles: {self.objectFiles}\noutputFilename: {self.outputFilename}\n')
499499
for srcFile in self.inputFiles:
500-
efn('\nsrcFile: {0}\n'.format(srcFile))
500+
efn(f'\nsrcFile: {srcFile}\n')
501501
(objFile, bcFile) = self.getArtifactNames(srcFile)
502-
efn('\n{0} ===> ({1}, {2})\n'.format(srcFile, objFile, bcFile))
502+
efn(f'\n{srcFile} ===> ({objFile}, {bcFile})\n')

wllvm/as.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def __init__(self, arglist):
5353
self.bcName = None
5454
self.outFileName = None
5555
localCallbacks = {'-o' : (1, BCFilter.outFileCallback)}
56-
super(BCFilter, self).__init__(arglist, exactMatches=localCallbacks)
56+
super().__init__(arglist, exactMatches=localCallbacks)
5757

5858
def outFileCallback(self, flag, name):
5959
""" Callback for the -o flag.

wllvm/checker.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
7676
"""
7777

78-
class Checker(object):
78+
class Checker:
7979
def __init__(self):
8080
path = os.getenv('LLVM_COMPILER_PATH')
8181

@@ -112,17 +112,17 @@ def check(self):
112112
return 0 if success else 1
113113

114114
def checkSelf(self):
115-
print('wllvm version: {0}'.format(wllvm_version))
116-
print('wllvm released: {0}\n'.format(wllvm_date))
115+
print(f'wllvm version: {wllvm_version}')
116+
print(f'wllvm released: {wllvm_date}\n')
117117

118118

119119
def checkLogging(self):
120120
(destination, level) = loggingConfiguration()
121-
print('Logging output to {0}.'.format(destination if destination else 'standard error'))
121+
print(f'Logging output to {destination if destination else "standard error"}.')
122122
if not level:
123-
print('Logging level not set, defaulting to WARNING\n')
123+
print('Logging level not set, defaulting to WARNING.')
124124
else:
125-
print('Logging level set to {0}.\n'.format(level))
125+
print(f'Logging level set to {level}.')
126126

127127

128128
def checkOS(self):
@@ -137,7 +137,7 @@ def checkSwitch(self):
137137
compiler_type = os.getenv('LLVM_COMPILER')
138138
if compiler_type == 'clang':
139139
return (1, '\nWe are using clang.\n')
140-
elif compiler_type == 'dragonegg':
140+
if compiler_type == 'dragonegg':
141141
return (2, '\nWe are using dragonegg.\n')
142142
return (0, explain_LLVM_COMPILER)
143143

@@ -147,8 +147,8 @@ def checkClang(self):
147147
cc_name = os.getenv('LLVM_CC_NAME')
148148
cxx_name = os.getenv('LLVM_CXX_NAME')
149149

150-
cc = '{0}{1}'.format(self.path, cc_name if cc_name else 'clang')
151-
cxx = '{0}{1}'.format(self.path, cxx_name if cxx_name else 'clang++')
150+
cc = f'{self.path}{cc_name if cc_name else "clang"}'
151+
cxx = f'{self.path}{cxx_name if cxx_name else "clang++"}'
152152

153153
return self.checkCompilers(cc, cxx)
154154

@@ -162,8 +162,8 @@ def checkDragonegg(self):
162162
if os.getenv('LLVM_GCC_PREFIX') is not None:
163163
pfx = os.getenv('LLVM_GCC_PREFIX')
164164

165-
cc = '{0}{1}gcc'.format(self.path, pfx)
166-
cxx = '{0}{1}g++'.format(self.path, pfx)
165+
cc = f'{self.path}{pfx}gcc'
166+
cxx = f'{self.path}{pfx}g++'
167167

168168
return self.checkCompilers(cc, cxx)
169169

@@ -180,11 +180,11 @@ def checkDragoneggPlugin(self):
180180
try:
181181
open(plugin)
182182
except IOError as e:
183-
print("Unable to open {0}: {1}".format(plugin, str(e)))
183+
print(f'Unable to open {plugin}: {str(e)}')
184184
else:
185185
return True
186186
else:
187-
print("Could not find {0}".format(plugin))
187+
print(f'Could not find {plugin}')
188188
return False
189189

190190

@@ -195,10 +195,10 @@ def checkCompiler(self):
195195
if code == 0:
196196
print(comment)
197197
return False
198-
elif code == 1:
198+
if code == 1:
199199
print(comment)
200200
return self.checkClang()
201-
elif code == 2:
201+
if code == 2:
202202
print(comment)
203203
return self.checkDragonegg()
204204
print('Insane')
@@ -212,14 +212,14 @@ def checkCompilers(self, cc, cxx):
212212
(cxxOk, cxxVersion) = self.checkExecutable(cxx)
213213

214214
if not ccOk:
215-
print('The C compiler {0} was not found or not executable.\nBetter not try using wllvm!\n'.format(cc))
215+
print(f'The C compiler {cc} was not found or not executable.\nBetter not try using wllvm!\n')
216216
else:
217-
print('The C compiler {0} is:\n\n\t{1}\n'.format(cc, extractLine(ccVersion, 0)))
217+
print(f'The C compiler {cc} is:\n\n\t{extractLine(ccVersion, 0)}\n')
218218

219219
if not cxxOk:
220-
print('The CXX compiler {0} was not found or not executable.\nBetter not try using wllvm++!\n'.format(cxx))
220+
print(f'The CXX compiler {cxx} was not found or not executable.\nBetter not try using wllvm++!\n')
221221
else:
222-
print('The C++ compiler {0} is:\n\n\t{1}\n'.format(cxx, extractLine(cxxVersion, 0)))
222+
print(f'The C++ compiler {cxx} is:\n\n\t{extractLine(cxxVersion, 0)}\n')
223223

224224
if not ccOk or not cxxOk:
225225
print(explain_LLVM_COMPILER_PATH)
@@ -239,13 +239,13 @@ def checkExecutable(self, exe, version_switch='-v'):
239239
try:
240240
compiler = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE)
241241
output = compiler.communicate()
242-
compilerOutput = '{0}{1}'.format(output[0], output[1])
242+
compilerOutput = f'{output[0].decode()}{output[1].decode()}'
243243
except OSError as e:
244244
if e.errno == errno.EPERM:
245-
return (False, '{0} not executable'.format(exe))
246-
elif e.errno == errno.ENOENT:
247-
return (False, '{0} not found'.format(exe))
248-
return (False, '{0} not sure why, errno is {1}'.format(exe, e.errno))
245+
return (False, f'{exe} not executable')
246+
if e.errno == errno.ENOENT:
247+
return (False, f'{exe} not found')
248+
return (False, f'{exe} not sure why, errno is {e.errno}')
249249
else:
250250
return (True, compilerOutput)
251251

@@ -262,34 +262,34 @@ def checkAuxiliaries(self):
262262
if not ar_name:
263263
ar_name = 'llvm-ar'
264264

265-
link = '{0}{1}'.format(self.path, link_name) if self.path else link_name
266-
ar = '{0}{1}'.format(self.path, ar_name) if self.path else ar_name
265+
link = f'{self.path}{link_name}' if self.path else link_name
266+
ar = f'{self.path}{ar_name}' if self.path else ar_name
267267

268268
(linkOk, linkVersion) = self.checkExecutable(link, '-version')
269269

270270
(arOk, arVersion) = self.checkExecutable(ar, '-version')
271271

272272
if not linkOk:
273-
print('The bitcode linker {0} was not found or not executable.\nBetter not try using extract-bc!\n'.format(link))
273+
print(f'The bitcode linker {link} was not found or not executable.\nBetter not try using extract-bc!\n')
274274
print(explain_LLVM_LINK_NAME)
275275
else:
276-
print('The bitcode linker {0} is:\n\n\t{1}\n'.format(link, extractLine(linkVersion, 1)))
276+
print(f'The bitcode linker {link} is:\n\n\t{extractLine(linkVersion, 1)}\n')
277277

278278
if not arOk:
279-
print('The bitcode archiver {0} was not found or not executable.\nBetter not try using extract-bc!\n'.format(ar))
279+
print(f'The bitcode archiver {ar} was not found or not executable.\nBetter not try using extract-bc!\n')
280280
print(explain_LLVM_AR_NAME)
281281
else:
282-
print('The bitcode archiver {0} is:\n\n\t{1}\n'.format(ar, extractLine(arVersion, 1)))
282+
print(f'The bitcode archiver {ar} is:\n\n\t{extractLine(arVersion, 1)}\n')
283283

284284

285285
def checkStore(self):
286286
"""Checks that the bitcode store, if set, makes sense."""
287287
store_dir = os.getenv('WLLVM_BC_STORE')
288288
if store_dir:
289289
if os.path.exists(store_dir) and os.path.isdir(store_dir) and os.path.isabs(store_dir):
290-
print('Using the bitcode store:\n\n\t{0}\n\n'.format(store_dir))
290+
print(f'Using the bitcode store:\n\n\t{store_dir}\n\n')
291291
else:
292-
print('The bitcode store:\n\n\t{0}\n\nis either not absolute, does not exist, or is not a directory.\n\n'.format(store_dir))
292+
print(f'The bitcode store:\n\n\t{store_dir}\n\nis either not absolute, does not exist, or is not a directory.\n\n')
293293
else:
294294
print('Not using a bitcode store.\n\n')
295295

wllvm/compilers.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ def wcompile(mode):
9292
class ClangBitcodeArgumentListFilter(ArgumentListFilter):
9393
def __init__(self, arglist):
9494
localCallbacks = {'-o' : (1, ClangBitcodeArgumentListFilter.outputFileCallback)}
95-
super(ClangBitcodeArgumentListFilter, self).__init__(arglist, exactMatches=localCallbacks)
95+
#super(ClangBitcodeArgumentListFilter, self).__init__(arglist, exactMatches=localCallbacks)
96+
super().__init__(arglist, exactMatches=localCallbacks)
9697

9798
def outputFileCallback(self, flag, filename):
9899
self.outputFilename = filename
@@ -138,11 +139,11 @@ def attachBitcodePathToObject(bcPath, outFileName):
138139

139140
# Now write our bitcode section
140141
if sys.platform.startswith('darwin'):
141-
objcopyBin = '{}-{}'.format(binUtilsTargetPrefix, 'ld') if binUtilsTargetPrefix else 'ld'
142+
objcopyBin = f'{binUtilsTargetPrefix}-{"ld"}' if binUtilsTargetPrefix else 'ld'
142143
objcopyCmd = [objcopyBin, '-r', '-keep_private_externs', outFileName, '-sectcreate', darwinSegmentName, darwinSectionName, f.name, '-o', outFileName]
143144
else:
144-
objcopyBin = '{}-{}'.format(binUtilsTargetPrefix, 'objcopy') if binUtilsTargetPrefix else 'objcopy'
145-
objcopyCmd = [objcopyBin, '--add-section', '{0}={1}'.format(elfSectionName, f.name), outFileName]
145+
objcopyBin = f'{binUtilsTargetPrefix}-{"objcopy"}' if binUtilsTargetPrefix else 'objcopy'
146+
objcopyCmd = [objcopyBin, '--add-section', f'{elfSectionName}={f.name}', outFileName]
146147
orc = 0
147148

148149
# loicg: If the environment variable WLLVM_BC_STORE is set, copy the bitcode
@@ -168,7 +169,7 @@ def attachBitcodePathToObject(bcPath, outFileName):
168169
_logger.error('objcopy failed with %s', orc)
169170
sys.exit(-1)
170171

171-
class BuilderBase(object):
172+
class BuilderBase:
172173
def __init__(self, cmd, mode, prefixPath=None):
173174
self.af = None #memoize the arglist filter
174175
self.cmd = cmd
@@ -221,8 +222,8 @@ def getCompiler(self):
221222
elif self.mode == "wfortran":
222223
env, prog = 'LLVM_F77_NAME', 'flang'
223224
else:
224-
raise Exception("Unknown mode {0}".format(self.mode))
225-
return ['{0}{1}'.format(self.prefixPath, os.getenv(env) or prog)]
225+
raise Exception(f'Unknown mode {self.mode}')
226+
return [f'{self.prefixPath}{os.getenv(env) or prog}']
226227

227228
def getBitcodeArglistFilter(self):
228229
if self.af is None:
@@ -236,7 +237,7 @@ def getBitcodeCompiler(self):
236237
# We use '-B' to tell gcc where to look for an assembler.
237238
# When we build LLVM bitcode we do not want to use the GNU assembler,
238239
# instead we want gcc to use our own assembler (see as.py).
239-
cmd = cc + ['-B', asDir, '-fplugin={0}'.format(pth), '-fplugin-arg-dragonegg-emit-ir']
240+
cmd = cc + ['-B', asDir, f'-fplugin={pth}', '-fplugin-arg-dragonegg-emit-ir']
240241
_logger.debug(cmd)
241242
return cmd
242243

@@ -252,8 +253,8 @@ def getCompiler(self):
252253
elif self.mode == "wfortran":
253254
mode = 'gfortran'
254255
else:
255-
raise Exception("Unknown mode {0}".format(self.mode))
256-
return ['{0}{1}{2}'.format(self.prefixPath, pfx, mode)]
256+
raise Exception(f'Unknown mode {self.mode}')
257+
return [f'{self.prefixPath}{pfx}{mode}']
257258

258259
def getBitcodeArglistFilter(self):
259260
if self.af is None:
@@ -271,16 +272,15 @@ def getBuilder(cmd, mode):
271272

272273
if cstring == 'clang':
273274
return ClangBuilder(cmd, mode, pathPrefix)
274-
elif cstring == 'dragonegg':
275+
if cstring == 'dragonegg':
275276
return DragoneggBuilder(cmd, mode, pathPrefix)
276-
elif cstring is None:
277+
if cstring is None:
277278
errorMsg = ' No compiler set. Please set environment variable %s'
278279
_logger.critical(errorMsg, compilerEnv)
279280
raise Exception(errorMsg)
280-
else:
281-
errorMsg = '%s = %s : Invalid compiler type'
282-
_logger.critical(errorMsg, compilerEnv, str(cstring))
283-
raise Exception(errorMsg)
281+
errorMsg = '%s = %s : Invalid compiler type'
282+
_logger.critical(errorMsg, compilerEnv, str(cstring))
283+
raise Exception(errorMsg)
284284

285285
def buildObject(builder):
286286
objCompiler = builder.getCompiler()

0 commit comments

Comments
 (0)