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

@kn1g78 kn1g78 commented Jul 11, 2026

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.

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

rustbot commented Jul 11, 2026

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

bjorn3 commented Jul 12, 2026

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

kn1g78 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

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 thread src/doc/rustc/src/symbol-mangling/index.md Outdated
@tiif

tiif commented Jul 20, 2026

Copy link
Copy Markdown
Member

@rustbot reroll

@rustbot rustbot assigned adwinwhite and unassigned tiif Jul 20, 2026
@adwinwhite

Copy link
Copy Markdown
Contributor

@rustbot reroll

@rustbot rustbot assigned davidtwco and unassigned adwinwhite Jul 21, 2026
@davidtwco

Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors

rust-bors Bot 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-bors rust-bors Bot 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
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.
rust-bors Bot 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.
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.
rust-bors Bot 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.
rust-bors Bot 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-bors Bot merged commit 9497ae7 into rust-lang:main Jul 24, 2026
13 checks passed
@rustbot rustbot 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-actions Bot 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 free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: 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