aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xemcc27
-rw-r--r--tools/shared.py14
2 files changed, 26 insertions, 15 deletions
diff --git a/emcc b/emcc
index d4bbcebe..67c822e9 100755
--- a/emcc
+++ b/emcc
@@ -457,12 +457,25 @@ try:
except:
pass
+ if DEBUG:
+ print >> sys.stderr, 'emcc: saving intermediate processing steps to %s' % shared.EMSCRIPTEN_TEMP_DIR
+
+ intermediate_counter = 0
+ def save_intermediate(name=None):
+ global intermediate_counter
+ shutil.copyfile(final, os.path.join(shared.EMSCRIPTEN_TEMP_DIR, 'emcc-%d%s.js' % (intermediate_counter, '' if name is None else '-' + name)))
+ intermediate_counter += 1
+
if not LEAVE_INPUTS_RAW:
- emscripten_input = in_temp(target_basename + '.bc')
+ final = in_temp(target_basename + '.bc')
+ if DEBUG:
+ final = shared.Building.llvm_dis(final, final + '.ll')
+ save_intermediate('ll')
else:
assert len(input_files) == 1
- emscripten_input = input_files[0]
- final = shared.Building.emscripten(emscripten_input, append_ext=False)
+ final = input_files[0]
+
+ final = shared.Building.emscripten(final, append_ext=False)
# Apply a source code transformation, if requested
source_transform = os.environ.get('EMCC_JS_PROCESSOR')
@@ -473,14 +486,6 @@ try:
process(final)
if DEBUG:
- print >> sys.stderr, 'emcc: saving intermediate processing steps to %s' % shared.EMSCRIPTEN_TEMP_DIR
-
- intermediate_counter = 0
- def save_intermediate(name=None):
- global intermediate_counter
- shutil.copyfile(final, os.path.join(shared.EMSCRIPTEN_TEMP_DIR, 'emcc-%d%s.js' % (intermediate_counter, '' if name is None else '-' + name)))
- intermediate_counter += 1
-
save_intermediate('original')
final = shared.Building.js_optimizer(final, []) # Clean up the syntax a bit, so comparisons to later passes are simpler
save_intermediate('pretty')
diff --git a/tools/shared.py b/tools/shared.py
index 777566cc..b8f76a0d 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -445,11 +445,16 @@ class Building:
# shutil.move(filename + '.tmp.bc', filename + '.o')
@staticmethod
- def llvm_dis(filename):
+ def llvm_dis(input_filename, output_filename=None):
# LLVM binary ==> LLVM assembly
- try_delete(filename + '.o.ll')
- output = Popen([LLVM_DIS, filename + '.o'] + LLVM_DIS_OPTS + ['-o=' + filename + '.o.ll'], stdout=PIPE).communicate()[0]
- assert os.path.exists(filename + '.o.ll'), 'Could not create .ll file: ' + output
+ if output_filename is None:
+ # use test runner conventions
+ output_filename = input_filename + '.o.ll'
+ input_filename = input_filename + '.o'
+ try_delete(output_filename)
+ output = Popen([LLVM_DIS, input_filename ] + LLVM_DIS_OPTS + ['-o=' + output_filename], stdout=PIPE).communicate()[0]
+ assert os.path.exists(output_filename), 'Could not create .ll file: ' + output
+ return output_filename
@staticmethod
def llvm_as(input_filename, output_filename=None):
@@ -461,6 +466,7 @@ class Building:
try_delete(output_filename)
output = Popen([LLVM_AS, input_filename, '-o=' + output_filename], stdout=PIPE).communicate()[0]
assert os.path.exists(output_filename), 'Could not create bc file: ' + output
+ return output_filename
@staticmethod
def llvm_nm(filename, stdout=PIPE, stderr=None):