diff --git a/emcc.py b/emcc.py index d82537d2438e0..d64e48f779939 100755 --- a/emcc.py +++ b/emcc.py @@ -1600,6 +1600,11 @@ def parse_passes(string): passes += ['--log-execution'] passes += ['--instrument-memory'] passes += ['--legalize-js-interface'] + if shared.Settings.EMULATE_FUNCTION_POINTER_CASTS: + # note that this pass must run before asyncify, as if it runs afterwards we only + # generate the byn$fpcast_emu functions after asyncify runs, and so we wouldn't + # be able to whitelist them etc. + passes += ['--fpcast-emu'] if shared.Settings.ASYNCIFY: # TODO: allow whitelist as in asyncify passes += ['--asyncify'] @@ -1647,13 +1652,12 @@ def check_human_readable_list(items): # run safe-heap as a binaryen pass if shared.Settings.SAFE_HEAP and shared.Building.is_wasm_only(): options.binaryen_passes += ['--safe-heap'] - if shared.Settings.EMULATE_FUNCTION_POINTER_CASTS: - # emulated function pointer casts is emulated in wasm using a binaryen pass + if shared.Settings.EMULATE_FUNCTION_POINTER_CASTS and not shared.Settings.WASM_BACKEND: + # emulated function pointer casts is emulated in fastcomp wasm using a binaryen pass options.binaryen_passes += ['--fpcast-emu'] - if not shared.Settings.WASM_BACKEND: - # we also need emulated function pointers for that, as we need a single flat - # table, as is standard in wasm, and not asm.js split ones. - shared.Settings.EMULATED_FUNCTION_POINTERS = 1 + # we also need emulated function pointers for that, as we need a single flat + # table, as is standard in wasm, and not asm.js split ones. + shared.Settings.EMULATED_FUNCTION_POINTERS = 1 if shared.Settings.WASM2JS: if not shared.Settings.WASM_BACKEND: