Skip to content

doc: document wasm import symbol mangling - #159138

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
kn1g78:doc-wasm-symbol-mangling
Jul 24, 2026
Merged

doc: document wasm import symbol mangling#159138
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
kn1g78:doc-wasm-symbol-mangling

Conversation

@kn1g78

Copy link
Copy Markdown
Contributor

Document that foreign items from wasm_import_module extern blocks are mangled even with #[no_mangle] or #[link_name], so same-named imports from different WebAssembly modules remain distinct.

@rustbotrustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 11, 2026
@rustbot

Copy link
Copy Markdown
Collaborator

r? @tiif

rustbot has assigned @tiif.
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: @ehuss, compiler
  • @ehuss, compiler expanded to 76 candidates
  • Random selection from 20 candidates

@bjorn3

Copy link
Copy Markdown
Member

The fact that there even is a mangled name is an implementation detail, right? There wouldn't be a need to specify a name in the symbol table in the linking section given a small modification to the wasm object file linking tool convention to allow an external import to be identified by import location rather than symbol name, which would then result in no symbol name being assigned to it at all. I don't think this modification is planned, but there is nothing stopping such a modification from being made afaik.

@kn1g78

Copy link
Copy Markdown
ContributorAuthor

The fact that there even is a mangled name is an implementation detail, right? There wouldn't be a need to specify a name in the symbol table in the linking section given a small modification to the wasm object file linking tool convention to allow an external import to be identified by import location rather than symbol name, which would then result in no symbol name being assigned to it at all. I don't think this modification is planned, but there is nothing stopping such a modification from being made afaik.

Thanks, that makes sense. I was presenting the current mangled linker symbol as if it were part of wasm_import_module's semantics. I’ll clarify that this is an implementation detail of the current wasm codegen/linker setup and may change.

Comment threadsrc/doc/rustc/src/symbol-mangling/index.md Outdated
@tiif

tiif commented Jul 20, 2026

Copy link
Copy Markdown
Member

@rustbot reroll

@rustbotrustbot assigned adwinwhite and unassigned tiifJul 20, 2026
@adwinwhite

Copy link
Copy Markdown
Contributor

@rustbot reroll

@rustbotrustbot assigned davidtwco and unassigned adwinwhiteJul 21, 2026
@davidtwco

Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors

rust-borsBot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

📌 Commit f266337 has been approved by davidtwco

It is now in the queue for this repository.

@rust-borsrust-borsBot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 23, 2026
@jhprattjhpratt mentioned this pull request Jul 23, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 23, 2026
…=davidtwco
doc: document wasm import symbol mangling
Document that foreign items from wasm_import_module extern blocks are mangled even with #[no_mangle] or #[link_name], so same-named imports from different WebAssembly modules remain distinct.
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 23, 2026
…=davidtwco
doc: document wasm import symbol mangling
Document that foreign items from wasm_import_module extern blocks are mangled even with #[no_mangle] or #[link_name], so same-named imports from different WebAssembly modules remain distinct.
@jhprattjhpratt mentioned this pull request Jul 23, 2026
rust-borsBot pushed a commit that referenced this pull request Jul 23, 2026
Rollup of 18 pull requests
Successful merges:
- #138618 (Support using const pointers in asm `const` operand)
- #150161 (Remove 'static requirement on try_as_dyn)
- #158362 (trait solver: account for universes from replace_bound_vars)
- #159173 (Add allowed list check on EII implementations attributes)
- #159466 (cmse: clear variant-dependent padding in `enum`s)
- #159718 (Make `DocLinkResMap` an `FxIndexMap`)
- #155795 (constify `vec![1, 2, 3]` macro)
- #157776 (ci: Enable autodiff tests on x86_64 linux)
- #157905 (Update comments and add tests for `-Zrandomize-layout` for some guaranteed ZSTs)
- #159041 (Reorganize `tests/ui/issues` [22/N])
- #159108 (Reorganize `tests/ui/issues` [23/N])
- #159138 (doc: document wasm import symbol mangling)
- #159531 (Reorganize `tests/ui/issues` [28/N])
- #159608 (early_otherwise: Don't hoist dereferences when the otherwise branch is reachable)
- #159612 (Reorganize `tests/ui/issues` [29/N])
- #159653 (run `tests/assembly-llvm/asm/aarch64-types.rs` for `aarch64_be`)
- #159759 (rustc-dev-guide subtree update)
- #159761 (Remove outdated comment for resolve_vars_with_obligations)
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 23, 2026
…=davidtwco
doc: document wasm import symbol mangling
Document that foreign items from wasm_import_module extern blocks are mangled even with #[no_mangle] or #[link_name], so same-named imports from different WebAssembly modules remain distinct.
@jhprattjhpratt mentioned this pull request Jul 23, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 23, 2026
…=davidtwco
doc: document wasm import symbol mangling
Document that foreign items from wasm_import_module extern blocks are mangled even with #[no_mangle] or #[link_name], so same-named imports from different WebAssembly modules remain distinct.
@jhprattjhpratt mentioned this pull request Jul 23, 2026
rust-borsBot pushed a commit that referenced this pull request Jul 23, 2026
Rollup of 19 pull requests
Successful merges:
- #150161 (Remove 'static requirement on try_as_dyn)
- #158362 (trait solver: account for universes from replace_bound_vars)
- #159173 (Add allowed list check on EII implementations attributes)
- #159466 (cmse: clear variant-dependent padding in `enum`s)
- #159718 (Make `DocLinkResMap` an `FxIndexMap`)
- #155795 (constify `vec![1, 2, 3]` macro)
- #157776 (ci: Enable autodiff tests on x86_64 linux)
- #157905 (Update comments and add tests for `-Zrandomize-layout` for some guaranteed ZSTs)
- #158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools)
- #159041 (Reorganize `tests/ui/issues` [22/N])
- #159108 (Reorganize `tests/ui/issues` [23/N])
- #159138 (doc: document wasm import symbol mangling)
- #159531 (Reorganize `tests/ui/issues` [28/N])
- #159608 (early_otherwise: Don't hoist dereferences when the otherwise branch is reachable)
- #159612 (Reorganize `tests/ui/issues` [29/N])
- #159653 (run `tests/assembly-llvm/asm/aarch64-types.rs` for `aarch64_be`)
- #159667 (Make some parser structured suggestions verbose and tweak their wording)
- #159759 (rustc-dev-guide subtree update)
- #159761 (Remove outdated comment for resolve_vars_with_obligations)
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 23, 2026
…=davidtwco
doc: document wasm import symbol mangling
Document that foreign items from wasm_import_module extern blocks are mangled even with #[no_mangle] or #[link_name], so same-named imports from different WebAssembly modules remain distinct.
This was referenced Jul 23, 2026
rust-borsBot pushed a commit that referenced this pull request Jul 24, 2026
Rollup of 20 pull requests
Successful merges:
- #150161 (Remove 'static requirement on try_as_dyn)
- #159412 (Reorganize `tests/ui/issues` [26/N])
- #159466 (cmse: clear variant-dependent padding in `enum`s)
- #157905 (Update comments and add tests for `-Zrandomize-layout` for some guaranteed ZSTs)
- #158479 (Reject static item as direct const generic arg)
- #159041 (Reorganize `tests/ui/issues` [22/N])
- #159108 (Reorganize `tests/ui/issues` [23/N])
- #159138 (doc: document wasm import symbol mangling)
- #159531 (Reorganize `tests/ui/issues` [28/N])
- #159608 (early_otherwise: Don't hoist dereferences when the otherwise branch is reachable)
- #159612 (Reorganize `tests/ui/issues` [29/N])
- #159653 (run `tests/assembly-llvm/asm/aarch64-types.rs` for `aarch64_be`)
- #159719 (tests: add UI test for `.swap()` suggestion)
- #159737 (rustfmt fix: allow file not found errors for external mods annotated with `#[my_macro]`)
- #159759 (rustc-dev-guide subtree update)
- #159761 (Remove outdated comment for resolve_vars_with_obligations)
- #159764 (use `minicore::simd::Simd` more)
- #159773 (Remove outdated workaround for `P` type)
- #159778 (use lowest edition the test accepts)
- #159788 (Avoid ICEing in RPIT method chain suggestion)
@rust-bors
rust-borsBot merged commit 9497ae7 into rust-lang:mainJul 24, 2026
13 checks passed
@rustbotrustbot added this to the 1.99.0 milestone Jul 24, 2026
rust-timer added a commit that referenced this pull request Jul 24, 2026
Rollup merge of #159138 - kn1g78:doc-wasm-symbol-mangling, r=davidtwco
doc: document wasm import symbol mangling
Document that foreign items from wasm_import_module extern blocks are mangled even with #[no_mangle] or #[link_name], so same-named imports from different WebAssembly modules remain distinct.
github-actionsBot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Jul 25, 2026
Rollup of 20 pull requests
Successful merges:
- rust-lang/rust#150161 (Remove 'static requirement on try_as_dyn)
- rust-lang/rust#159412 (Reorganize `tests/ui/issues` [26/N])
- rust-lang/rust#159466 (cmse: clear variant-dependent padding in `enum`s)
- rust-lang/rust#157905 (Update comments and add tests for `-Zrandomize-layout` for some guaranteed ZSTs)
- rust-lang/rust#158479 (Reject static item as direct const generic arg)
- rust-lang/rust#159041 (Reorganize `tests/ui/issues` [22/N])
- rust-lang/rust#159108 (Reorganize `tests/ui/issues` [23/N])
- rust-lang/rust#159138 (doc: document wasm import symbol mangling)
- rust-lang/rust#159531 (Reorganize `tests/ui/issues` [28/N])
- rust-lang/rust#159608 (early_otherwise: Don't hoist dereferences when the otherwise branch is reachable)
- rust-lang/rust#159612 (Reorganize `tests/ui/issues` [29/N])
- rust-lang/rust#159653 (run `tests/assembly-llvm/asm/aarch64-types.rs` for `aarch64_be`)
- rust-lang/rust#159719 (tests: add UI test for `.swap()` suggestion)
- rust-lang/rust#159737 (rustfmt fix: allow file not found errors for external mods annotated with `#[my_macro]`)
- rust-lang/rust#159759 (rustc-dev-guide subtree update)
- rust-lang/rust#159761 (Remove outdated comment for resolve_vars_with_obligations)
- rust-lang/rust#159764 (use `minicore::simd::Simd` more)
- rust-lang/rust#159773 (Remove outdated workaround for `P` type)
- rust-lang/rust#159778 (use lowest edition the test accepts)
- rust-lang/rust#159788 (Avoid ICEing in RPIT method chain suggestion)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@kn1g78@rustbot@bjorn3@tiif@adwinwhite@davidtwco