Skip to content

Commit 0c2b701

Browse files
committed
Auto merge of rust-lang#117873 - quininer:android-emutls, r=Amanieu
Add emulated TLS support This is a reopen of rust-lang#96317 . many android devices still only use 128 pthread keys, so using emutls can be helpful. Currently LLVM uses emutls by default for some targets (such as android, openbsd), but rust does not use it, because `has_thread_local` is false. This commit has some changes to allow users to enable emutls: 1. add `-Zhas-thread-local` flag to specify that std uses `#[thread_local]` instead of pthread key. 2. when using emutls, decorate symbol names to find thread local symbol correctly. 3. change `-Zforce-emulated-tls` to `-Ztls-model=emulated` to explicitly specify whether to generate emutls. r? `@Amanieu`
2 parents 1f94db9 + e7b87a7 commit 0c2b701

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

std/src/sys/unix/thread_local_dtor.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212
// compiling from a newer linux to an older linux, so we also have a
1313
// fallback implementation to use as well.
1414
#[allow(unexpected_cfgs)]
15-
#[cfg(any(target_os = "linux", target_os = "fuchsia", target_os = "redox", target_os = "hurd"))]
15+
#[cfg(any(
16+
target_os = "linux",
17+
target_os = "android",
18+
target_os = "fuchsia",
19+
target_os = "redox",
20+
target_os = "hurd"
21+
))]
1622
// FIXME: The Rust compiler currently omits weakly function definitions (i.e.,
1723
// __cxa_thread_atexit_impl) and its metadata from LLVM IR.
1824
#[no_sanitize(cfi, kcfi)]

0 commit comments

Comments
 (0)