Skip to content

Commit c204c72

Browse files
committed
handle -Wl,--start-group ... -Wl,--end-group properly etc
1 parent 30dd4cf commit c204c72

File tree

6 files changed

+56
-7
lines changed

6 files changed

+56
-7
lines changed

.pylintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ max-returns=6
357357
max-branches=20
358358

359359
# Maximum number of statements in function / method body
360-
max-statements=50
360+
max-statements=60
361361

362362
# Maximum number of parents for a class (see R0901).
363363
max-parents=7

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ all:
2222

2323
#local editable install for developing
2424
develop:
25-
pip install -e .
25+
pip3 install -e .
2626

2727

2828
dist: clean
@@ -40,7 +40,7 @@ publish: dist
4040

4141

4242
install:
43-
pip install
43+
pip3 install
4444

4545
check_clang:
4646
cd test; python3 -m unittest -v test_base_driver test_clang_driver

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
'wfortran = wllvm.wfortran:main',
3838
'wllvm-sanity-checker = wllvm.sanity:main',
3939
'extract-bc = wllvm.extractor:main',
40+
'wparse-args = wllvm.wparser:main',
4041
],
4142
},
4243

wllvm/arglistfilter.py

+18-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
4747
'-v' : (0, ArgumentListFilter.compileOnlyCallback),
4848

4949
#warnings (apart from the regex below)
50-
'-w' : (0, ArgumentListFilter.compileUnaryCallback),
51-
'-W' : (0, ArgumentListFilter.compileUnaryCallback),
50+
'-w' : (0, ArgumentListFilter.compileOnlyCallback),
51+
'-W' : (0, ArgumentListFilter.compileOnlyCallback),
5252

5353

5454
#iam: if this happens, then we need to stop and think.
@@ -330,6 +330,18 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
330330
(arity, handler) = argExactMatches[currentItem]
331331
flagArgs = self._shiftArgs(arity)
332332
handler(self, currentItem, *flagArgs)
333+
elif currentItem == '-Wl,--start-group':
334+
linkingGroup = [currentItem]
335+
terminated = False
336+
while self._inputArgs:
337+
groupCurrent = self._inputArgs.popleft()
338+
linkingGroup.append(groupCurrent)
339+
if groupCurrent == "-Wl,--end-group":
340+
terminated = True
341+
break
342+
if not terminated:
343+
_logger.warning('Did not find a closing "-Wl,--end-group" to match "-Wl,--start-group"')
344+
self.linkingGroupCallback(linkingGroup)
333345
else:
334346
matched = False
335347
for pattern, (arity, handler) in argPatterns.items():
@@ -456,6 +468,10 @@ def linkBinaryCallback(self, flag, arg):
456468
self.linkArgs.append(flag)
457469
self.linkArgs.append(arg)
458470

471+
def linkingGroupCallback(self, args):
472+
_logger.debug('linkingGroupCallback: %s', args)
473+
self.linkArgs.extend(args)
474+
459475
#flags common to both linking and compiling (coverage for example)
460476
def compileLinkUnaryCallback(self, flag):
461477
_logger.debug('compileLinkUnaryCallback: %s', flag)

wllvm/version.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@
7979
1.2.7 - 3/23/2020 Added the LLVM_BITCODE_GENERATION_FLAGS to allow LTO support.
8080
8181
1.2.8 - 3/23/2020 Added the LLVM_BITCODE_GENERATION_FLAGS to allow LTO support. (pip uploading issues)
82+
83+
1.2.9 - 2/20/2021 Various fixes:
84+
wllvm-sanity-checker prints correctly now we are python3
85+
Eliminated "....".format(...) in favor of f'...{thingy}....' How many times did python try to get this right?
86+
e.g. handle -Wl,--start-group ... -Wl,--end-group properly.
87+
e.g. -W and -w don't trip the compile only flag.
8288
"""
8389

84-
wllvm_version = '1.2.8'
85-
wllvm_date = 'March 23 2020'
90+
wllvm_version = '1.2.9'
91+
wllvm_date = 'February 20 2020'

wllvm/wparser.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python
2+
"""This is a wrapper around the real compiler.
3+
4+
It first invokes a real compiler to generate
5+
an object file. Then it invokes a bitcode
6+
compiler to generate a parallel bitcode file.
7+
It records the location of the bitcode in an
8+
ELF section of the object file so that it can be
9+
found later after all of the objects are
10+
linked into a library or executable.
11+
"""
12+
13+
import sys
14+
15+
from .arglistfilter import ArgumentListFilter
16+
17+
def main():
18+
cmd = list(sys.argv)
19+
cmd = cmd[1:]
20+
args = ArgumentListFilter(cmd)
21+
args.dump()
22+
return 0
23+
24+
25+
if __name__ == '__main__':
26+
sys.exit(main())

0 commit comments

Comments
 (0)