Skip to content

Commit

Permalink
Don't export __wasm_init_memory on WebAssembly.
Browse files Browse the repository at this point in the history
Since rust-lang#72889, the Rust wasm target doesn't use --passive-segments, so
remove the `--export=__wasm_init_memory`.

As documented in the [tool-conventions Linking convention],
`__wasm_init_memory` is not intended to be exported.

[tool-conventions Linking convention]: https://github.com/WebAssembly/tool-conventions/blob/7c064f304858f67ebf22964a84b7e9658e29557a/Linking.md#shared-memory-and-passive-segments
  • Loading branch information
sunfishcode committed Sep 28, 2022
1 parent 09ae784 commit 284c942
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,18 +1180,12 @@ impl<'a> WasmLd<'a> {
// sharing memory and instantiating the module multiple times. As a
// result if it were exported then we'd just have no sharing.
//
// * `--export=__wasm_init_memory` - when using `--passive-segments` the
// linker will synthesize this function, and so we need to make sure
// that our usage of `--export` below won't accidentally cause this
// function to get deleted.
//
// * `--export=*tls*` - when `#[thread_local]` symbols are used these
// symbols are how the TLS segments are initialized and configured.
if sess.target_features.contains(&sym::atomics) {
cmd.arg("--shared-memory");
cmd.arg("--max-memory=1073741824");
cmd.arg("--import-memory");
cmd.arg("--export=__wasm_init_memory");
cmd.arg("--export=__wasm_init_tls");
cmd.arg("--export=__tls_size");
cmd.arg("--export=__tls_align");
Expand Down

0 comments on commit 284c942

Please sign in to comment.