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.
This commit is contained in:
parent
8a7b2035f8
commit
e5b76892cc
17 changed files with 71 additions and 28 deletions
|
@ -1283,7 +1283,7 @@ fn default_configuration(sess: &Session) -> Cfg {
|
|||
ret.insert((sym::relocation_model, Some(relocation_model)));
|
||||
}
|
||||
ret.insert((sym::target_vendor, Some(Symbol::intern(vendor))));
|
||||
if sess.target.has_thread_local {
|
||||
if sess.opts.unstable_opts.has_thread_local.unwrap_or(sess.target.has_thread_local) {
|
||||
ret.insert((sym::target_thread_local, None));
|
||||
}
|
||||
let mut has_atomic = false;
|
||||
|
|
|
@ -1624,6 +1624,8 @@ options! {
|
|||
graphviz_font: String = ("Courier, monospace".to_string(), parse_string, [UNTRACKED],
|
||||
"use the given `fontname` in graphviz output; can be overridden by setting \
|
||||
environment variable `RUSTC_GRAPHVIZ_FONT` (default: `Courier, monospace`)"),
|
||||
has_thread_local: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
||||
"explicitly enable the `cfg(target_thread_local)` directive"),
|
||||
hir_stats: bool = (false, parse_bool, [UNTRACKED],
|
||||
"print some statistics about AST and HIR (default: no)"),
|
||||
human_readable_cgu_names: bool = (false, parse_bool, [TRACKED],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue