Auto merge of #117873 - quininer:android-emutls, r=Amanieu
Add emulated TLS support This is a reopen of https://github.com/rust-lang/rust/pull/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`
This commit is contained in:
commit
608f32435a
17 changed files with 71 additions and 28 deletions
|
@ -929,6 +929,7 @@ pub enum TlsModel {
|
|||
LocalDynamic,
|
||||
InitialExec,
|
||||
LocalExec,
|
||||
Emulated,
|
||||
}
|
||||
|
||||
impl FromStr for TlsModel {
|
||||
|
@ -942,6 +943,7 @@ impl FromStr for TlsModel {
|
|||
"local-dynamic" => TlsModel::LocalDynamic,
|
||||
"initial-exec" => TlsModel::InitialExec,
|
||||
"local-exec" => TlsModel::LocalExec,
|
||||
"emulated" => TlsModel::Emulated,
|
||||
_ => return Err(()),
|
||||
})
|
||||
}
|
||||
|
@ -954,6 +956,7 @@ impl ToJson for TlsModel {
|
|||
TlsModel::LocalDynamic => "local-dynamic",
|
||||
TlsModel::InitialExec => "initial-exec",
|
||||
TlsModel::LocalExec => "local-exec",
|
||||
TlsModel::Emulated => "emulated",
|
||||
}
|
||||
.to_json()
|
||||
}
|
||||
|
@ -2191,9 +2194,6 @@ pub struct TargetOptions {
|
|||
|
||||
/// Whether the target supports XRay instrumentation.
|
||||
pub supports_xray: bool,
|
||||
|
||||
/// Forces the use of emulated TLS (__emutls_get_address)
|
||||
pub force_emulated_tls: bool,
|
||||
}
|
||||
|
||||
/// Add arguments for the given flavor and also for its "twin" flavors
|
||||
|
@ -2409,7 +2409,6 @@ impl Default for TargetOptions {
|
|||
entry_name: "main".into(),
|
||||
entry_abi: Conv::C,
|
||||
supports_xray: false,
|
||||
force_emulated_tls: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3113,7 +3112,6 @@ impl Target {
|
|||
key!(entry_name);
|
||||
key!(entry_abi, Conv)?;
|
||||
key!(supports_xray, bool);
|
||||
key!(force_emulated_tls, bool);
|
||||
|
||||
if base.is_builtin {
|
||||
// This can cause unfortunate ICEs later down the line.
|
||||
|
@ -3369,7 +3367,6 @@ impl ToJson for Target {
|
|||
target_option_val!(entry_name);
|
||||
target_option_val!(entry_abi);
|
||||
target_option_val!(supports_xray);
|
||||
target_option_val!(force_emulated_tls);
|
||||
|
||||
if let Some(abi) = self.default_adjusted_cabi {
|
||||
d.insert("default-adjusted-cabi".into(), Abi::name(abi).to_json());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue