Skip to content

Commit 55aef98

Browse files
authored
Move emscripten lld flags to start start of cmd line (emscripten-core#25803)
This allows the `-Bdynamic` flag to be moved there which is its logical place. It also theoretically allows user flags to override any system flags.
1 parent 664d3fe commit 55aef98

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

ChangeLog.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ See docs/process.md for more on how version tagging works.
2020

2121
4.0.20 (in development)
2222
-----------------------
23-
- Added `emscripten_html5_remove_event_listener` function in `html5.h` in order to be
24-
able to remove a single callback. (#25535)
23+
- Linker flags specified on the command line are now passed to `wasm-ld` after
24+
the internal emscripten linker flags. This means that users can now override
25+
emscripten defaults with things `-Wl,--stack-first`. (#25803)
26+
- Added `emscripten_html5_remove_event_listener` function in `html5.h` in order
27+
to be able to remove a single callback. (#25535)
2528
- The standalone `file_packager.py` script no longer supports `--embed` with JS
2629
output (use `--obj-output` is now required for embedding data). This usage
2730
has been producing a warning since #16050 which is now an error. (#25049)

tools/building.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)