Skip to content

Commit

Permalink
Rollup merge of #102440 - sunfishcode:sunfishcode/wasm-no-export-tls-…
Browse files Browse the repository at this point in the history
…api, r=oli-obk

Only export `__tls_*` on wasm32-unknown-unknown.

From talking with `@abrown,` we aren't planning to have hosts call these `__tls_*` functions; instead, TLS initialization will be handled transparently within libc. Consequently, these functions don't need to be exported.

Leave them exported on wasm32-unknown-unknown though, as wasm-bindgen does call them.
  • Loading branch information
Dylan-DPC authored Oct 5, 2022
2 parents ab88c19 + 2d9e61f commit 814b827
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,16 +1180,19 @@ 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=*tls*` - when `#[thread_local]` symbols are used these
// symbols are how the TLS segments are initialized and configured.
// On wasm32-unknown-unknown, we also export symbols for glue code to use:
// * `--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_tls");
cmd.arg("--export=__tls_size");
cmd.arg("--export=__tls_align");
cmd.arg("--export=__tls_base");
if sess.target.os == "unknown" {
cmd.arg("--export=__wasm_init_tls");
cmd.arg("--export=__tls_size");
cmd.arg("--export=__tls_align");
cmd.arg("--export=__tls_base");
}
}
WasmLd { cmd, sess }
}
Expand Down

0 comments on commit 814b827

Please sign in to comment.