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
4 changes: 3 additions & 1 deletion test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,11 @@ def test_log_subcommands(self):

def test_skip_subcommands(self):
# The -### flag is like `-v` but it doesn't actaully execute the sub-commands
proc = self.run_process([EMCC, '-###', test_file('hello_world.c')], stdout=PIPE, stderr=PIPE)
proc = self.run_process([EMCC, '-###', '-O3', test_file('hello_world.c')], stdout=PIPE, stderr=PIPE)
self.assertContained(CLANG_CC, proc.stderr)
self.assertContained(WASM_LD, proc.stderr)
self.assertContained('wasm-opt', proc.stderr)
self.assertContained('acorn-optimizer.mjs', proc.stderr)
self.assertNotExists('a.out.js')

def test_emcc_check(self):
Expand Down
14 changes: 13 additions & 1 deletion tools/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def js_optimizer(filename, passes):
def acorn_optimizer(filename, passes, extra_info=None, return_output=False, worker_js=False):
optimizer = path_from_root('tools/acorn-optimizer.mjs')
original_filename = filename
if extra_info is not None:
if extra_info is not None and not shared.SKIP_SUBPROCS:
temp_files = shared.get_temp_files()
temp = temp_files.get('.js', prefix='emcc_acorn_info_').name
shutil.copyfile(filename, temp)
Expand All @@ -366,6 +366,9 @@ def acorn_optimizer(filename, passes, extra_info=None, return_output=False, work
if settings.VERBOSE:
cmd += ['--verbose']
if return_output:
shared.print_compiler_stage(cmd)
if shared.SKIP_SUBPROCS:
return ''
return check_call(cmd, stdout=PIPE).stdout

acorn_optimizer.counter += 1
Expand All @@ -375,6 +378,9 @@ def acorn_optimizer(filename, passes, extra_info=None, return_output=False, work
output_file = basename + '.jso%d.js' % acorn_optimizer.counter
shared.get_temp_files().note(output_file)
cmd += ['-o', output_file]
shared.print_compiler_stage(cmd)
if shared.SKIP_SUBPROCS:
return output_file
check_call(cmd)
save_intermediate(output_file, '%s.js' % passes[0])
return output_file
Expand Down Expand Up @@ -780,6 +786,9 @@ def metadce(js_file, wasm_file, debug_info, last):
extra_info = '{ "exports": [' + ','.join(f'["{asmjs_mangle(x)}", "{x}"]' for x in exports) + ']}'

txt = acorn_optimizer(js_file, ['emitDCEGraph', '--no-print'], return_output=True, extra_info=extra_info)
if shared.SKIP_SUBPROCS:
# The next steps depend on the output from this step, so we can't do them if we aren't actually running.
return js_file
graph = json.loads(txt)
# ensure that functions expected to be exported to the outside are roots
required_symbols = user_requested_exports.union(set(settings.SIDE_MODULE_IMPORTS))
Expand Down Expand Up @@ -1209,6 +1218,9 @@ def run_binaryen_command(tool, infile, outfile=None, args=None, debug=False, std
if settings.GENERATE_SOURCE_MAP and outfile and tool in ['wasm-opt', 'wasm-emscripten-finalize']:
cmd += [f'--input-source-map={infile}.map']
cmd += [f'--output-source-map={outfile}.map']
shared.print_compiler_stage(cmd)
if shared.SKIP_SUBPROCS:
return ''
ret = check_call(cmd, stdout=stdout).stdout
if outfile:
save_intermediate(outfile, '%s.wasm' % tool)
Expand Down
Loading