Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,15 @@ def uniquename(name):
seen_names[name] = str(len(seen_names))
return unsuffixed(name) + '_' + seen_names[name] + (('.' + suffix(name)) if suffix(name) else '')

def asciify(strings_list):
res = ''
for s in strings_list:
if isinstance(s, unicode):
res += s.encode('ascii','ignore')
else:
res += s
return res

# ---------------- End configs -------------

if len(sys.argv) == 1 or sys.argv[1] in ['x', 't']:
Expand Down Expand Up @@ -2131,7 +2140,7 @@ def do_minify(): # minifies the code. this is also when we do certain optimizati
if emit_symbol_map or shared.Settings.CYBERDWARF:
cmd += ['--symbolmap=' + target + '.symbols']
cmd += ['-o', wasm_binary_target]
logging.debug('asm2wasm (asm.js => WebAssembly): ' + ' '.join(cmd))
logging.debug('asm2wasm (asm.js => WebAssembly): ' + ' '.join(asciify(cmd)))
TimeLogger.update()
subprocess.check_call(cmd)
if import_mem_init:
Expand All @@ -2142,11 +2151,11 @@ def do_minify(): # minifies the code. this is also when we do certain optimizati
if shared.Settings.BINARYEN_PASSES:
shutil.move(wasm_binary_target, wasm_binary_target + '.pre')
cmd = [os.path.join(binaryen_bin, 'wasm-opt'), wasm_binary_target + '.pre', '-o', wasm_binary_target] + map(lambda p: '--' + p, shared.Settings.BINARYEN_PASSES.split(','))
logging.debug('wasm-opt on BINARYEN_PASSES: ' + ' '.join(cmd))
logging.debug('wasm-opt on BINARYEN_PASSES: ' + ' '.join(asciify(cmd)))
subprocess.check_call(cmd)
if 'interpret-s-expr' in shared.Settings.BINARYEN_METHOD:
cmd = [os.path.join(binaryen_bin, 'wasm-dis'), wasm_binary_target, '-o', wasm_text_target]
logging.debug('wasm-dis (binary => text): ' + ' '.join(cmd))
logging.debug('wasm-dis (binary => text): ' + ' '.join(asciify(cmd)))
subprocess.check_call(cmd)
if shared.Settings.BINARYEN_SCRIPTS:
binaryen_scripts = os.path.join(shared.Settings.BINARYEN_ROOT, 'scripts')
Expand Down
2 changes: 1 addition & 1 deletion emscripten.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def function_tables_and_exports(funcs, metadata, mem_init, glue, forwarded_data,

staticbump = metadata['staticBump']
while staticbump % 16 != 0: staticbump += 1
pre = pre.replace('STATICTOP = STATIC_BASE + 0;', '''STATICTOP = STATIC_BASE + %d;%s
pre = pre.replace('STATICTOP = STATIC_BASE + 0;', '''STATICTOP = Runtime.alignMemory(STATIC_BASE, 16) + %d;%s
/* global initializers */ %s __ATINIT__.push(%s);
%s''' % (staticbump,
'assert(STATICTOP < SPLIT_MEMORY, "SPLIT_MEMORY size must be big enough so the entire static memory, need " + STATICTOP);' if settings['SPLIT_MEMORY'] else '',
Expand Down
12 changes: 10 additions & 2 deletions tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -1633,8 +1633,16 @@ def llvm_opt(filename, opts, out=None):

logging.debug('emcc: LLVM opts: ' + ' '.join(opts) + ' [num inputs: ' + str(len(inputs)) + ']')
target = out or (filename + '.opt.bc')
output = Popen([LLVM_OPT] + inputs + opts + ['-o', target], stdout=PIPE).communicate()[0]
assert os.path.exists(target), 'Failed to run llvm optimizations: ' + output
proc = Popen([LLVM_OPT] + inputs + opts + ['-o', target], stdout=PIPE)
output = proc.communicate()[0]
if proc.returncode != 0 or not os.path.exists(target):
logging.error('Failed to run llvm optimizations: ' + output)
for i in inputs:
if not os.path.exists(i):
logging.warning('Note: Input file "' + i + '" did not exist.')
elif not Building.is_bitcode(i):
logging.warning('Note: Input file "' + i + '" exists but was not an LLVM bitcode file suitable for Emscripten. Perhaps accidentally mixing native built object files with Emscripten?')
sys.exit(1)
if not out:
shutil.move(filename + '.opt.bc', filename)
return target
Expand Down