diff options
| author | Dan Gohman <dev@sunfishcode.online> | 2022-09-28 14:40:53 -0700 |
|---|---|---|
| committer | Dan Gohman <dev@sunfishcode.online> | 2022-09-29 16:28:03 -0700 |
| commit | 2d9e61f0c7ae23f485a0dd55c73bcaf5302953dd (patch) | |
| tree | 1b9316f54405d80f9deedfcef8458805b36cf3aa | |
| parent | 9c56d9d6fec6262bbb1549cfe466a812ae2c6523 (diff) | |
| download | rust-2d9e61f0c7ae23f485a0dd55c73bcaf5302953dd.tar.gz rust-2d9e61f0c7ae23f485a0dd55c73bcaf5302953dd.zip | |
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.
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/linker.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index f59a753a5ce..2cd746ccb6a 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -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 } } |
