Skip to content

Commit 814b827

Browse files
authored
Rollup merge of #102440 - sunfishcode:sunfishcode/wasm-no-export-tls-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.
2 parents ab88c19 + 2d9e61f commit 814b827

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

compiler/rustc_codegen_ssa/src/back/linker.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -1180,16 +1180,19 @@ impl<'a> WasmLd<'a> {
11801180
// sharing memory and instantiating the module multiple times. As a
11811181
// result if it were exported then we'd just have no sharing.
11821182
//
1183-
// * `--export=*tls*` - when `#[thread_local]` symbols are used these
1184-
// symbols are how the TLS segments are initialized and configured.
1183+
// On wasm32-unknown-unknown, we also export symbols for glue code to use:
1184+
// * `--export=*tls*` - when `#[thread_local]` symbols are used these
1185+
// symbols are how the TLS segments are initialized and configured.
11851186
if sess.target_features.contains(&sym::atomics) {
11861187
cmd.arg("--shared-memory");
11871188
cmd.arg("--max-memory=1073741824");
11881189
cmd.arg("--import-memory");
1189-
cmd.arg("--export=__wasm_init_tls");
1190-
cmd.arg("--export=__tls_size");
1191-
cmd.arg("--export=__tls_align");
1192-
cmd.arg("--export=__tls_base");
1190+
if sess.target.os == "unknown" {
1191+
cmd.arg("--export=__wasm_init_tls");
1192+
cmd.arg("--export=__tls_size");
1193+
cmd.arg("--export=__tls_align");
1194+
cmd.arg("--export=__tls_base");
1195+
}
11931196
}
11941197
WasmLd { cmd, sess }
11951198
}

0 commit comments

Comments
 (0)