Skip to content

Commit e1381d5

Browse files
authored
Don't use in when checking WASM_CALL_CTORS since its a string. NFC (#21842)
It happens to work because `x in `__wasm_call_ctors` does a substring comparison, but its not correct.
1 parent 1d1133a commit e1381d5

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

tools/emscripten.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,14 @@ def compute_minimal_runtime_initializer_and_exports(post, exports, receiving):
5757
# Declare all exports out to global JS scope so that JS library functions can access them in a
5858
# way that minifies well with Closure
5959
# e.g. var a,b,c,d,e,f;
60-
exports_that_are_not_initializers = [x for x in exports if x not in building.WASM_CALL_CTORS]
61-
# In Wasm backend the exports are still unmangled at this point, so mangle the names here
62-
exports_that_are_not_initializers = [asmjs_mangle(x) for x in exports_that_are_not_initializers]
60+
61+
exports = [asmjs_mangle(x) for x in exports if x != building.WASM_CALL_CTORS]
6362

6463
# Decide whether we should generate the global dynCalls dictionary for the dynCall() function?
65-
if settings.DYNCALLS and '$dynCall' in settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE and len([x for x in exports_that_are_not_initializers if x.startswith('dynCall_')]) > 0:
66-
exports_that_are_not_initializers += ['dynCalls = {}']
64+
if settings.DYNCALLS and '$dynCall' in settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE and len([x for x in exports if x.startswith('dynCall_')]) > 0:
65+
exports += ['dynCalls = {}']
6766

68-
declares = 'var ' + ',\n '.join(exports_that_are_not_initializers) + ';'
67+
declares = 'var ' + ',\n '.join(exports) + ';'
6968
post = shared.do_replace(post, '<<< WASM_MODULE_EXPORTS_DECLARES >>>', declares)
7069

7170
# Generate assignments from all wasm exports out to the JS variables above: e.g. a = wasmExports['a']; b = wasmExports['b'];

0 commit comments

Comments
 (0)