Skip to content

Commit c2014e7

Browse files
committed
2 parents 13d064d + fcd62a0 commit c2014e7

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

wllvm/arglistfilter.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -404,17 +404,20 @@ def getOutputFilename(self):
404404
# bitcodeFile is (starts with a '.'), use the logging level & DUMPING flag to get a sense
405405
# of what is being written out.
406406
def getArtifactNames(self, srcFile, hidden=False):
407-
(_, srcbase) = os.path.split(srcFile)
408-
(srcroot, _) = os.path.splitext(srcbase)
409-
if hidden:
410-
objbase = '.{0}.o'.format(srcroot)
411-
else:
412-
objbase = '{0}.o'.format(srcroot)
413-
bcbase = '.{0}.o.bc'.format(srcroot)
414-
path = ''
415407
if self.outputFilename is not None:
416-
path = os.path.dirname(self.outputFilename)
417-
return [os.path.join(path, objbase), os.path.join(path, bcbase)]
408+
objFile = self.outputFilename
409+
(dirs, baseFile) = os.path.split(objFile)
410+
bcFile = os.path.join(dirs, '.{0}.bc'.format(baseFile))
411+
return [objFile, bcFile]
412+
else:
413+
(_, srcbase) = os.path.split(srcFile)
414+
(srcroot, _) = os.path.splitext(srcbase)
415+
if hidden:
416+
objbase = '.{0}.o'.format(srcroot)
417+
else:
418+
objbase = '{0}.o'.format(srcroot)
419+
bcbase = '.{0}.o.bc'.format(srcroot)
420+
return [objbase, bcbase]
418421

419422
#iam: for printing our partitioning of the args
420423
def dump(self):

wllvm/compilers.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ def attachBitcodePathToObject(bcPath, outFileName):
106106
objcopyCmd = ['objcopy', '--add-section', '{0}={1}'.format(elfSectionName, f.name), outFileName]
107107
orc = 0
108108

109+
# loicg: If the environment variable WLLVM_BC_STORE is set, copy the bitcode
110+
# file to that location, using a hash of the original bitcode path as a name
111+
storeEnv = os.getenv('WLLVM_BC_STORE')
112+
if storeEnv:
113+
hashName = hashlib.sha256(absBcPath).hexdigest()
114+
copyfile(absBcPath, os.path.join(storeEnv, hashName))
115+
109116
try:
110117
if os.path.getsize(outFileName) > 0:
111118
objProc = Popen(objcopyCmd)
@@ -122,13 +129,6 @@ def attachBitcodePathToObject(bcPath, outFileName):
122129
_logger.error('objcopy failed with %s', orc)
123130
sys.exit(-1)
124131

125-
# loicg: If the environment variable WLLVM_BC_STORE is set, copy the bitcode
126-
# file to that location, using a hash of the original bitcode path as a name
127-
storeEnv = os.getenv('WLLVM_BC_STORE')
128-
if storeEnv:
129-
hashName = hashlib.sha256(absBcPath).hexdigest()
130-
copyfile(absBcPath, os.path.join(storeEnv, hashName))
131-
132132
class BuilderBase(object):
133133
def __init__(self, cmd, isCxx, prefixPath=None):
134134
self.cmd = cmd

wllvm/extraction.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def getStorePath(bcPath):
163163
def getBitcodePath(bcPath):
164164
"""Tries to resolve the whereabouts of the bitcode.
165165
166-
First, ihecks if the given path points to an existing bitcode file.
166+
First, checks if the given path points to an existing bitcode file.
167167
If it does not, it tries to look for the bitcode file in the store directory given
168168
by the environment variable WLLVM_BC_STORE.
169169
"""
@@ -298,6 +298,7 @@ def handleArchive(pArgs):
298298

299299
for bcFile in contents:
300300
if bcFile != '':
301+
bcFile = getBitcodePath(bcFile)
301302
if not os.path.exists(bcFile):
302303
_logger.warning('%s lists bitcode library "%s" but it could not be found', f, bcFile)
303304
else:

0 commit comments

Comments
 (0)