@@ -208,6 +208,7 @@ def lld_flags_for_executable(external_symbols):
208208 c_exports = [e for e in c_exports if e not in external_symbols ]
209209 c_exports += settings .REQUIRED_EXPORTS
210210 if settings .MAIN_MODULE :
211+ cmd .append ('-Bdynamic' )
211212 c_exports += side_module_external_deps (external_symbols )
212213 for export in c_exports :
213214 if settings .ERROR_ON_UNDEFINED_SYMBOLS :
@@ -296,9 +297,6 @@ def link_lld(args, target, external_symbols=None):
296297 args .insert (0 , '--whole-archive' )
297298 args .append ('--no-whole-archive' )
298299
299- if settings .MAIN_MODULE :
300- args .insert (0 , '-Bdynamic' )
301-
302300 if settings .STRICT and '--no-fatal-warnings' not in args :
303301 args .append ('--fatal-warnings' )
304302
@@ -307,7 +305,7 @@ def link_lld(args, target, external_symbols=None):
307305 # is passed.
308306 args .append ('--keep-section=target_features' )
309307
310- cmd = [WASM_LD , '-o' , target ] + args
308+ cmd = [WASM_LD , '-o' , target ]
311309 for a in llvm_backend_args ():
312310 cmd += ['-mllvm' , a ]
313311
@@ -328,6 +326,8 @@ def link_lld(args, target, external_symbols=None):
328326 if '--relocatable' not in args and '-r' not in args :
329327 cmd += lld_flags_for_executable (external_symbols )
330328
329+ cmd += args
330+
331331 cmd = get_command_with_possible_response_file (cmd )
332332 check_call (cmd )
333333
0 commit comments