about summary refs log tree commit diff
path: root/src/doc
diff options
context:
space:
mode:
authorquininer <quininer@live.com>2023-11-13 20:48:23 +0800
committerquininer <quininer@live.com>2023-12-07 00:21:32 +0800
commite5b76892cc5e6fbfb495bf6a7339962a287849a7 (patch)
tree81bfe340a76ab385e4631c2ef51e5c5db55385a0 /src/doc
parent8a7b2035f816f6d27003a9326d6bd3a3d739fcc3 (diff)
downloadrust-e5b76892cc5e6fbfb495bf6a7339962a287849a7.tar.gz
rust-e5b76892cc5e6fbfb495bf6a7339962a287849a7.zip
Add emulated TLS support
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.
Diffstat (limited to 'src/doc')
-rw-r--r--src/doc/unstable-book/src/compiler-flags/tls-model.md2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/doc/unstable-book/src/compiler-flags/tls-model.md b/src/doc/unstable-book/src/compiler-flags/tls-model.md
index 8b19e785c6a..b7024ba88de 100644
--- a/src/doc/unstable-book/src/compiler-flags/tls-model.md
+++ b/src/doc/unstable-book/src/compiler-flags/tls-model.md
@@ -20,6 +20,8 @@ loaded at program startup.
 The TLS data must not be in a library loaded after startup (via `dlopen`).
 - `local-exec` - model usable only if the TLS data is defined directly in the executable,
 but not in a shared library, and is accessed only from that executable.
+- `emulated` - Uses thread-specific data keys to implement emulated TLS.
+It is like using a general-dynamic TLS model for all modes.
 
 `rustc` and LLVM may use a more optimized model than specified if they know that we are producing
 an executable rather than a library, or that the `static` item is private enough.