@@ -760,7 +760,9 @@ def create_sending(metadata, library_symbols):
760
760
return '{\n ' + ',\n ' .join (f'{ prefix } { k } : { v } ' for k , v in sorted_items ) + '\n }'
761
761
762
762
763
- def make_export_wrappers (function_exports , delay_assignment ):
763
+ def make_export_wrappers (function_exports ):
764
+ assert (!settings .MINIMAL_RUNTIME )
765
+
764
766
wrappers = []
765
767
766
768
# The emscripten stack functions are called very early (by writeStackCookie) before
@@ -794,8 +796,8 @@ def install_wrapper(sym):
794
796
# With assertions enabled we create a wrapper that are calls get routed through, for
795
797
# the lifetime of the program.
796
798
wrapper += "createExportWrapper('%s');" % name
797
- elif delay_assignment :
798
- # With assertions disabled the wrapper will replace the global var and Module var on
799
+ elif settings . WASM_ASYNC_COMPILATION :
800
+ # With WASM_ASYNC_COMPILATION wrapper will replace the global var and Module var on
799
801
# first use.
800
802
args = [f'a{ i } ' for i in range (nargs )]
801
803
args = ', ' .join (args )
@@ -815,32 +817,26 @@ def create_receiving(function_exports):
815
817
816
818
receiving = []
817
819
818
- # with WASM_ASYNC_COMPILATION that asm object may not exist at this point in time
819
- # so we need to support delayed assignment.
820
- delay_assignment = settings .WASM_ASYNC_COMPILATION and not settings .MINIMAL_RUNTIME
821
- if not delay_assignment :
822
- if settings .MINIMAL_RUNTIME :
823
- # In Wasm exports are assigned inside a function to variables
824
- # existing in top level JS scope, i.e.
825
- # var _main;
826
- # WebAssembly.instantiate(Module['wasm'], imports).then((output) => {
827
- # var wasmExports = output.instance.exports;
828
- # _main = wasmExports["_main"];
829
- generate_dyncall_assignment = settings .DYNCALLS and '$dynCall' in settings .DEFAULT_LIBRARY_FUNCS_TO_INCLUDE
830
- exports_that_are_not_initializers = [x for x in function_exports if x != building .WASM_CALL_CTORS ]
831
-
832
- for s in exports_that_are_not_initializers :
833
- mangled = asmjs_mangle (s )
834
- dynCallAssignment = ('dynCalls["' + s .replace ('dynCall_' , '' ) + '"] = ' ) if generate_dyncall_assignment and mangled .startswith ('dynCall_' ) else ''
835
- should_export = settings .EXPORT_ALL or (settings .EXPORT_KEEPALIVE and mangled in settings .EXPORTED_FUNCTIONS )
836
- export_assignment = ''
837
- if settings .MODULARIZE and should_export :
838
- export_assignment = f"Module['{ mangled } '] = "
839
- receiving += [f'{ export_assignment } { dynCallAssignment } { mangled } = wasmExports["{ s } "]' ]
840
- else :
841
- receiving += make_export_wrappers (function_exports , delay_assignment )
820
+ if settings .MINIMAL_RUNTIME :
821
+ # In Wasm exports are assigned inside a function to variables
822
+ # existing in top level JS scope, i.e.
823
+ # var _main;
824
+ # WebAssembly.instantiate(Module['wasm'], imports).then((output) => {
825
+ # var wasmExports = output.instance.exports;
826
+ # _main = wasmExports["_main"];
827
+ generate_dyncall_assignment = settings .DYNCALLS and '$dynCall' in settings .DEFAULT_LIBRARY_FUNCS_TO_INCLUDE
828
+ exports_that_are_not_initializers = [x for x in function_exports if x != building .WASM_CALL_CTORS ]
829
+
830
+ for s in exports_that_are_not_initializers :
831
+ mangled = asmjs_mangle (s )
832
+ dynCallAssignment = ('dynCalls["' + s .replace ('dynCall_' , '' ) + '"] = ' ) if generate_dyncall_assignment and mangled .startswith ('dynCall_' ) else ''
833
+ should_export = settings .EXPORT_ALL or (settings .EXPORT_KEEPALIVE and mangled in settings .EXPORTED_FUNCTIONS )
834
+ export_assignment = ''
835
+ if settings .MODULARIZE and should_export :
836
+ export_assignment = f"Module['{ mangled } '] = "
837
+ receiving += [f'{ export_assignment } { dynCallAssignment } { mangled } = wasmExports["{ s } "]' ]
842
838
else :
843
- receiving += make_export_wrappers (function_exports , delay_assignment )
839
+ receiving += make_export_wrappers (function_exports )
844
840
845
841
if settings .MINIMAL_RUNTIME :
846
842
return '\n ' .join (receiving ) + '\n '
0 commit comments