@@ -282,10 +282,7 @@ def lld_flags_for_executable(external_symbols):
282282 return cmd
283283
284284
285- def link_lld (args , target , external_symbols = None ):
286- if not os .path .exists (WASM_LD ):
287- exit_with_error ('linker binary not found in LLVM directory: %s' , WASM_LD )
288- # runs lld to link things.
285+ def lld_flags (args ):
289286 # lld doesn't currently support --start-group/--end-group since the
290287 # semantics are more like the windows linker where there is no need for
291288 # grouping.
@@ -305,29 +302,34 @@ def link_lld(args, target, external_symbols=None):
305302 # is passed.
306303 args .append ('--keep-section=target_features' )
307304
308- cmd = [WASM_LD , '-o' , target ]
305+ if settings .MEMORY64 :
306+ args .append ('-mwasm64' )
307+
309308 for a in llvm_backend_args ():
310- cmd += ['-mllvm' , a ]
309+ args += ['-mllvm' , a ]
311310
312311 if settings .WASM_EXCEPTIONS :
313- cmd += ['-mllvm' , '-wasm-enable-eh' ]
312+ args += ['-mllvm' , '-wasm-enable-eh' ]
314313 if settings .WASM_LEGACY_EXCEPTIONS :
315- cmd += ['-mllvm' , '-wasm-use-legacy-eh' ]
314+ args += ['-mllvm' , '-wasm-use-legacy-eh' ]
316315 else :
317- cmd += ['-mllvm' , '-wasm-use-legacy-eh=0' ]
316+ args += ['-mllvm' , '-wasm-use-legacy-eh=0' ]
318317 if settings .WASM_EXCEPTIONS or settings .SUPPORT_LONGJMP == 'wasm' :
319- cmd += ['-mllvm' , '-exception-model=wasm' ]
318+ args += ['-mllvm' , '-exception-model=wasm' ]
320319
321- if settings .MEMORY64 :
322- cmd .append ('-mwasm64' )
320+ return args
323321
322+
323+ def link_lld (args , target , external_symbols = None ):
324+ # runs lld to link things.
325+ if not os .path .exists (WASM_LD ):
326+ exit_with_error ('linker binary not found in LLVM directory: %s' , WASM_LD )
327+ cmd = [WASM_LD , '-o' , target ]
324328 # For relocatable output (generating an object file) we don't pass any of the
325329 # normal linker flags that are used when building and executable
326330 if '--relocatable' not in args and '-r' not in args :
327331 cmd += lld_flags_for_executable (external_symbols )
328-
329- cmd += args
330-
332+ cmd += lld_flags (args )
331333 cmd = get_command_with_possible_response_file (cmd )
332334 check_call (cmd )
333335
0 commit comments