Skip to content

Pass --no-entry to emcc when linking emscripten cdylib/dylib#157985

Open
guybedford wants to merge 1 commit into
rust-lang:mainfrom
guybedford:emscripten-cdylib-no-entry
Open

Pass --no-entry to emcc when linking emscripten cdylib/dylib#157985
guybedford wants to merge 1 commit into
rust-lang:mainfrom
guybedford:emscripten-cdylib-no-entry

Conversation

@guybedford

Copy link
Copy Markdown
Contributor

A cdylib/dylib has no main, but rustc invokes emcc in its default executable mode, which links in emscripten's standalone-wasm entry shim and then fails with undefined symbol: main.

Mirror the WasmLd linker: emit --no-entry for DynamicDylib/ StaticDylib output kinds in EmLinker::set_output_kind, conditioned on LinkOutputKind so executables keep their entry.

Extends the emscripten cdylib run-make test to also link a bin crate with main, guarding against regressing the executable entry path.

A cdylib/dylib has no `main`, but rustc invokes emcc in its default
executable mode, which links in emscripten's standalone-wasm entry shim
and then fails with `undefined symbol: main`.

Mirror the WasmLd linker: emit `--no-entry` for `DynamicDylib`/
`StaticDylib` output kinds in EmLinker::set_output_kind, conditioned on
LinkOutputKind so executables keep their entry.

Extend the emscripten cdylib run-make test to also link a bin crate with
`main`, guarding against regressing the executable entry path.
@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 16, 2026
@rustbot

rustbot commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

r? @camelid

rustbot has assigned @camelid.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 21 candidates

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

Labels

A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants