Skip to content

Commit 09d2181

Browse files
committed
Since clang is more common than llvm-ar and llvm-link on a mac, make an effort to help user.
1 parent 9ec0f11 commit 09d2181

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

extract-bc

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,19 @@ def handleExecutable(inputFile, outputFile, extractor, llvmLinker):
150150

151151
linkCmd.extend([x for x in fileNames if x != ''])
152152
logging.info('Writing output to {0}'.format(outputFile))
153-
linkProc = Popen(linkCmd)
154-
exitCode = linkProc.wait()
155-
logging.info('{0} returned {1}'.format(llvmLinker, str(exitCode)))
153+
try:
154+
linkProc = Popen(linkCmd)
155+
except OSError as e:
156+
if e.errno == 2:
157+
errorMsg = "Your llvm-link doesn't seem to be easy to find.\nEither install it or use the -l llvmLinker option."
158+
else:
159+
errorMsg = "OS error({0}): {1}".format(e.errno, e.strerror)
160+
logging.error(errorMsg)
161+
raise Exception(errorMsg)
162+
163+
else:
164+
exitCode = linkProc.wait()
165+
logging.info('{0} returned {1}'.format(llvmLinker, str(exitCode)))
156166
return exitCode
157167

158168

@@ -173,7 +183,16 @@ def handleArchive(inputFile, outputFile, arCmd, fileType, extractor, llvmArchive
173183
os.chdir(tempDir)
174184

175185
# Extract objects from archive
176-
arP = Popen(arCmd)
186+
try:
187+
arP = Popen(arCmd)
188+
except OSError as e:
189+
if e.errno == 2:
190+
errorMsg = "Your llvm-ar doesn't seem to be easy to find.\nEither install it or use the -a llvmArchiver option."
191+
else:
192+
errorMsg = "OS error({0}): {1}".format(e.errno, e.strerror)
193+
logging.error(errorMsg)
194+
raise Exception(errorMsg)
195+
177196
arPE = arP.wait()
178197

179198
if arPE != 0:
@@ -294,6 +313,7 @@ def extract_bc_args(args):
294313

295314
inputFile = parsedArgs.wllvm_binary
296315
llvmLinker = parsedArgs.linker
316+
llvmArchiver = parsedArgs.archiver
297317
verboseFlag = parsedArgs.verbose
298318

299319
# Check file exists

0 commit comments

Comments
 (0)