Skip to content

Commit b8fd9a0

Browse files
authored
Remove WASM_BACKEND usage in building, cache, ctor_evaller, gen_struct_info (#11969)
See #11860
1 parent 9c4f14c commit b8fd9a0

File tree

4 files changed

+22
-54
lines changed

4 files changed

+22
-54
lines changed

tools/building.py

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ def link_to_object(linker_inputs, target):
452452
# other otherwise for linking of bitcode we must use our python
453453
# code (necessary for asm.js, for wasm bitcode see
454454
# https://bugs.llvm.org/show_bug.cgi?id=40654)
455-
if Settings.WASM_BACKEND and not Settings.LTO:
455+
if not Settings.LTO:
456456
link_lld(linker_inputs + ['--relocatable'], target)
457457
else:
458458
link(linker_inputs, target)
@@ -743,13 +743,6 @@ def llvm_opt(filename, opts, out=None):
743743
assert out, 'must provide out if llvm_opt on a list of inputs'
744744
assert len(opts), 'should not call opt with nothing to do'
745745
opts = opts[:]
746-
# TODO: disable inlining when needed
747-
# if not can_inline():
748-
# opts.append('-disable-inlining')
749-
# opts += ['-debug-pass=Arguments']
750-
# TODO: move vectorization logic to clang/LLVM?
751-
if not Settings.WASM_BACKEND:
752-
opts += ['-disable-loop-vectorization', '-disable-slp-vectorization', '-vectorize-loops=false', '-vectorize-slp=false']
753746

754747
target = out or (filename + '.opt.bc')
755748
cmd = [LLVM_OPT] + inputs + opts + ['-o', target]
@@ -868,19 +861,6 @@ def is_wasm_only():
868861
if not Settings.WASM:
869862
return False
870863
# llvm backend can only ever produce wasm
871-
if Settings.WASM_BACKEND:
872-
return True
873-
# fastcomp can emit wasm-only code.
874-
# also disable this mode if it depends on special optimizations that are not yet
875-
# compatible with it.
876-
if not Settings.LEGALIZE_JS_FFI:
877-
# the user has requested no legalization for JS, and so we are not
878-
# emitting code compatible with JS, and there is no reason not to
879-
# be wasm-only, regardless of everything else
880-
return True
881-
if Settings.RUNNING_JS_OPTS:
882-
# if the JS optimizer runs, it must run on valid asm.js
883-
return False
884864
return True
885865

886866

@@ -962,14 +942,14 @@ def acorn_optimizer(filename, passes, extra_info=None, return_output=False):
962942
# evals ctors. if binaryen_bin is provided, it is the dir of the binaryen tool
963943
# for this, and we are in wasm mode
964944
def eval_ctors(js_file, binary_file, binaryen_bin='', debug_info=False):
965-
if Settings.WASM_BACKEND:
966-
logger.debug('Ctor evalling in the wasm backend is disabled due to https://github.com/emscripten-core/emscripten/issues/9527')
967-
return
968-
cmd = [PYTHON, path_from_root('tools', 'ctor_evaller.py'), js_file, binary_file, str(Settings.INITIAL_MEMORY), str(Settings.TOTAL_STACK), str(Settings.GLOBAL_BASE), binaryen_bin, str(int(debug_info))]
969-
if binaryen_bin:
970-
cmd += get_binaryen_feature_flags()
971-
print_compiler_stage(cmd)
972-
check_call(cmd)
945+
logger.debug('Ctor evalling in the wasm backend is disabled due to https://github.com/emscripten-core/emscripten/issues/9527')
946+
return
947+
# TODO re-enable
948+
# cmd = [PYTHON, path_from_root('tools', 'ctor_evaller.py'), js_file, binary_file, str(Settings.INITIAL_MEMORY), str(Settings.TOTAL_STACK), str(Settings.GLOBAL_BASE), binaryen_bin, str(int(debug_info))]
949+
# if binaryen_bin:
950+
# cmd += get_binaryen_feature_flags()
951+
# print_compiler_stage(cmd)
952+
# check_call(cmd)
973953

974954

975955
def calculate_reachable_functions(infile, initial_list, can_reach=True):
@@ -1235,8 +1215,7 @@ def metadce(js_file, wasm_file, minify_whitespace, debug_info):
12351215
if 'export' in item:
12361216
export = item['export']
12371217
# wasm backend's exports are prefixed differently inside the wasm
1238-
if Settings.WASM_BACKEND:
1239-
export = asmjs_mangle(export)
1218+
export = asmjs_mangle(export)
12401219
if export in user_requested_exports or Settings.EXPORT_ALL:
12411220
item['root'] = True
12421221
# in standalone wasm, always export the memory
@@ -1266,12 +1245,11 @@ def metadce(js_file, wasm_file, minify_whitespace, debug_info):
12661245
for item in graph:
12671246
if 'import' in item and item['import'][1][1:] in WASI_IMPORTS:
12681247
item['import'][0] = Settings.WASI_MODULE_NAME
1269-
if Settings.WASM_BACKEND:
1270-
# wasm backend's imports are prefixed differently inside the wasm
1271-
for item in graph:
1272-
if 'import' in item:
1273-
if item['import'][1][0] == '_':
1274-
item['import'][1] = item['import'][1][1:]
1248+
# fixup wasm backend prefixing
1249+
for item in graph:
1250+
if 'import' in item:
1251+
if item['import'][1][0] == '_':
1252+
item['import'][1] = item['import'][1][1:]
12751253
# map import names from wasm to JS, using the actual name the wasm uses for the import
12761254
import_name_map = {}
12771255
for item in graph:
@@ -1579,9 +1557,6 @@ def path_to_system_js_libraries(library_name):
15791557

15801558
elif library_name.endswith('.js') and os.path.isfile(path_from_root('src', 'library_' + library_name)):
15811559
library_files += ['library_' + library_name]
1582-
elif not Settings.WASM_BACKEND:
1583-
# The wasm backend will report these when wasm-ld runs
1584-
exit_with_error('emcc: cannot find library "%s"', library_name)
15851560

15861561
return library_files
15871562

tools/cache.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,11 @@ def __init__(self, dirname, use_subdir=True):
3232

3333
# if relevant, use a subdir of the cache
3434
if use_subdir:
35-
if shared.Settings.WASM_BACKEND:
36-
subdir = 'wasm'
37-
if shared.Settings.LTO:
38-
subdir += '-lto'
39-
if shared.Settings.RELOCATABLE:
40-
subdir += '-pic'
41-
else:
42-
subdir = 'asmjs'
35+
subdir = 'wasm'
36+
if shared.Settings.LTO:
37+
subdir += '-lto'
38+
if shared.Settings.RELOCATABLE:
39+
subdir += '-pic'
4340
dirname = os.path.join(dirname, subdir)
4441

4542
self.dirname = dirname

tools/ctor_evaller.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ def find_ctors_data(js, num):
6161
ctors_text = js[ctors_start:ctors_end]
6262
all_ctors = [ctor for ctor in ctors_text.split(' ') if ctor.endswith('()') and not ctor == 'function()' and '.' not in ctor]
6363
all_ctors = [ctor.replace('()', '') for ctor in all_ctors]
64-
if shared.Settings.WASM_BACKEND:
65-
assert all(ctor.startswith('_') for ctor in all_ctors)
66-
all_ctors = [ctor[1:] for ctor in all_ctors]
64+
assert all(ctor.startswith('_') for ctor in all_ctors)
65+
all_ctors = [ctor[1:] for ctor in all_ctors]
6766
assert len(all_ctors)
6867
ctors = all_ctors[:num]
6968
return ctors_start, ctors_end, all_ctors, ctors

tools/gen_struct_info.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,6 @@ def inspect_code(headers, cpp_opts, structs, defines):
408408
# TODO(sbc): Remove this one we remove the test_em_config_env_var test
409409
cmd += ['-Wno-deprecated']
410410

411-
if not shared.Settings.WASM_BACKEND:
412-
# Avoid the binaryen dependency if we are only using fastcomp
413-
cmd += ['-s', 'WASM=0', '-Wno-fastcomp']
414411
if shared.Settings.LTO:
415412
cmd += ['-flto=' + shared.Settings.LTO]
416413

0 commit comments

Comments
 (0)