Skip to content

[emld] Add emld tool and use clang to drive linking - #27866

Open
sbc100 wants to merge 1 commit into
emscripten-core:mainfrom
sbc100:link_emld
Open

sbc100 wants to merge 1 commit into
emscripten-core:mainfrom
sbc100:link_emld

Conversation

@sbc100

@sbc100 sbc100 commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

Add a new emld linker entry point and delegate linking from emcc to clang with -fuse-ld=emld.

Previously, emcc acted as both compiler driver and linker driver, manually compiling multiple source inputs to temporary object files in Python before running tools/link.py. With this change:

  1. emld acts as a drop-in linker replacement that wraps link.run and invokes wasm-ld followed by Emscripten's post-link steps.
  2. emcc in link mode delegates to clang -fuse-ld=<path-to-emld>, allowing clang to handle source compilation, temporary files, and calling the linker.
  3. Emscripten-specific linker arguments and -s settings are forwarded through clang to emld via -Wl, or -Xlinker.
  4. tools/link.py extracts linker_setup_minimal so minimal linker settings can be determined before system libraries are calculated in emcc.

See: #15703

Add a new `emld` linker entry point and delegate linking from `emcc` to
`clang` with `-fuse-ld=emld`.

Previously, `emcc` acted as both compiler driver and linker driver,
manually compiling multiple source inputs to temporary object files in
Python before running `tools/link.py`. With this change:

1. `emld` acts as a drop-in linker replacement that wraps `link.run` and
   invokes `wasm-ld` followed by Emscripten's post-link steps.
2. `emcc` in link mode delegates to `clang -fuse-ld=<path-to-emld>`,
   allowing `clang` to handle source compilation, temporary files, and
   calling the linker.
3. Emscripten-specific linker arguments and `-s` settings are forwarded
   through `clang` to `emld` via `-Wl,` or `-Xlinker`.
4. `tools/link.py` extracts `linker_setup_minimal` so minimal linker
   settings can be determined before system libraries are calculated in
   `emcc`.

See: emscripten-core#15703

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant