Skip to content

Commit 00fa392

Browse files
committed
Fix for issue #28 filed by @carlocab
1 parent 8a93f15 commit 00fa392

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

wllvm/extraction.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,19 @@ def extract_section_darwin(inputFile):
127127
_logger.error('otool failed on %s', inputFile)
128128
sys.exit(-1)
129129

130-
lines = otoolOutput.splitlines()
130+
lines = otoolOutput.decode('utf8').splitlines()
131131
_logger.debug('otool extracted:\n%s\n', lines)
132+
# iam 03/06/2021: so otool prior to llvm-otool(1): Apple Inc. version cctools-977.1
133+
# would output 'Contents of (__WLLVM,__llvm_bc) section' as the first line
134+
# of the extraction. This seems to have disappeared so we need to be careful
135+
# here:
136+
if lines and lines[0] and lines[0].startswith('Contents'):
137+
_logger.debug('dropping header: "%s"', lines[0])
138+
lines = lines[1:]
132139
try:
133140
octets = []
134-
for line in lines[1:]:
135-
m = otool_hexdata.match(line.decode())
141+
for line in lines:
142+
m = otool_hexdata.match(line)
136143
if not m:
137144
_logger.debug('otool output:\n\t%s\nDID NOT match expectations.', line)
138145
continue
@@ -142,6 +149,7 @@ def extract_section_darwin(inputFile):
142149
retval = decode_hex(''.join(octets))[0].splitlines()
143150
# these have become bytes in the "evolution" of python
144151
retval = [ f.decode('utf8') for f in retval]
152+
_logger.debug('decoded:\n%s\n', retval)
145153
if not retval:
146154
_logger.error('%s contained no %s segment', inputFile, darwinSegmentName)
147155
except Exception as e:

wllvm/version.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@
8585
Eliminated "....".format(...) in favor of f'...{thingy}....' How many times did python try to get this right?
8686
e.g. handle -Wl,--start-group ... -Wl,--end-group properly.
8787
e.g. -W and -w don't trip the compile only flag.
88+
1.3.0 - 3/6/2021 otool seems to have changed its output format, so we need to tread more carefully.
89+
8890
"""
8991

90-
wllvm_version = '1.2.9'
91-
wllvm_date = 'February 20 2020'
92+
wllvm_version = '1.3.0'
93+
wllvm_date = 'March 6 2021'

0 commit comments

Comments
 (0)