]> git.lizzy.rs Git - rust.git/blob - src/doc/unstable-book/src/compiler-flags/tls-model.md
Rollup merge of #85957 - BoxyUwU:rustdoc-const-generic-defaults, r=oli-obk
[rust.git] / src / doc / unstable-book / src / compiler-flags / tls-model.md
1 # `tls_model`
2
3 The tracking issue for this feature is: None.
4
5 ------------------------
6
7 Option `-Z tls-model` controls [TLS model](https://www.akkadia.org/drepper/tls.pdf) used to
8 generate code for accessing `#[thread_local]` `static` items.
9
10 Supported values for this option are:
11
12 - `global-dynamic` - General Dynamic TLS Model (alternatively called Global Dynamic) is the most
13 general option usable in all circumstances, even if the TLS data is defined in a shared library
14 loaded at runtime and is accessed from code outside of that library.
15 This is the default for most targets.
16 - `local-dynamic` - model usable if the TLS data is only accessed from the shared library or
17 executable it is defined in. The TLS data may be in a library loaded after startup (via `dlopen`).
18 - `initial-exec` - model usable if the TLS data is defined in the executable or in a shared library
19 loaded at program startup.
20 The TLS data must not be in a library loaded after startup (via `dlopen`).
21 - `local-exec` - model usable only if the TLS data is defined directly in the executable,
22 but not in a shared library, and is accessed only from that executable.
23
24 `rustc` and LLVM may use a more optimized model than specified if they know that we are producing
25 an executable rather than a library, or that the `static` item is private enough.