aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-12-16 21:55:39 -0800
committerAlon Zakai <alonzakai@gmail.com>2011-12-16 21:55:39 -0800
commit3c17526474d054acb9aa616d5af95103f040b2d2 (patch)
tree9ba00fff8d14d6943e891b35e951814f15680210
parent7bb863e24d5242cb9f31be0e7946e323a80d793a (diff)
make emcc and emar more robust against odd makefile inputs
-rwxr-xr-xemar3
-rwxr-xr-xemcc19
2 files changed, 15 insertions, 7 deletions
diff --git a/emar b/emar
index 5a627993..312bd4a4 100755
--- a/emar
+++ b/emar
@@ -17,5 +17,6 @@ newargs = [shared.EMLD] + sys.argv[3:] + ['-o='+sys.argv[2]]
if DEBUG:
print >> sys.stderr, 'emar:', sys.argv, ' ==> ', newargs
-os.execvp(shared.EMLD, newargs)
+if len(newargs) > 2:
+ os.execvp(shared.EMLD, newargs)
diff --git a/emcc b/emcc
index 14c96b01..951b8146 100755
--- a/emcc
+++ b/emcc
@@ -295,13 +295,16 @@ try:
# right now we just assume that what is left contains no more |-x OPT| things
arg = newargs[i]
if arg.endswith(SOURCE_SUFFIXES + BITCODE_SUFFIXES): # we already removed -o <target>, so all these should be inputs
- input_files.append(arg)
newargs[i] = ''
- if arg.endswith(SOURCE_SUFFIXES):
- has_source_inputs = True
+ if os.path.exists(arg):
+ input_files.append(arg)
+ if arg.endswith(SOURCE_SUFFIXES):
+ has_source_inputs = True
+ else:
+ print >> sys.stderr, 'emcc: %s: No such file or directory' % arg
newargs = [ arg for arg in newargs if arg is not '' ]
- assert len(input_files) > 0, 'emcc: no input files specified'
+ assert len(input_files) > 0, 'emcc: no input files'
newargs += CC_ADDITIONAL_ARGS
@@ -339,7 +342,7 @@ try:
## Compile source code to bitcode
- if DEBUG: print >> sys.stderr, 'emcc: compiling to bitcode'
+ if DEBUG: print >> sys.stderr, 'emcc: compiling to bitcode (%s)' % str(sys.argv)
# First, generate LLVM bitcode. For each input file, we get base.o with bitcode
for input_file in input_files:
@@ -357,7 +360,11 @@ try:
if llvm_opt_level > 0:
if DEBUG: print >> sys.stderr, 'emcc: LLVM opts'
for input_file in input_files:
- shared.Building.llvm_opt(in_temp(unsuffixed_basename(input_file) + '.o'), LLVM_INTERNAL_OPT_LEVEL, safe=llvm_opt_level < 2)
+ try:
+ shared.Building.llvm_opt(in_temp(unsuffixed_basename(input_file) + '.o'), LLVM_INTERNAL_OPT_LEVEL, safe=llvm_opt_level < 2)
+ except:
+ # This might be an invalid input, which will get ignored during linking later anyhow
+ print >> sys.stderr, 'emcc: warning: LLVM opt failed to run on %s, continuing without optimization' % input_file
# If we were just asked to generate bitcode, stop there
if final_suffix not in ['js', 'html']: