Rollup merge of #92042 - ChrisDenton:msvc-static-tls, r=nagisa
Enable `#[thread_local]` for all windows-msvc targets As it stands, `#[thread_local]` is enabled haphazardly for msvc. It seems all 64-bit targets have it enabled, but not 32-bit targets unless they're also UWP targets (perhaps because UWP was added more recently?). So this PR simply enables it for 32-bit targets as well. I can't think of a reason not to and I've confirmed by running tests locally which pass. See also #91659
This commit is contained in:
commit
4dbe966fdd
@ -880,7 +880,7 @@ fn default_configuration(sess: &Session) -> CrateConfig {
|
|||||||
ret.insert((sym::target_env, Some(Symbol::intern(env))));
|
ret.insert((sym::target_env, Some(Symbol::intern(env))));
|
||||||
ret.insert((sym::target_abi, Some(Symbol::intern(abi))));
|
ret.insert((sym::target_abi, Some(Symbol::intern(abi))));
|
||||||
ret.insert((sym::target_vendor, Some(Symbol::intern(vendor))));
|
ret.insert((sym::target_vendor, Some(Symbol::intern(vendor))));
|
||||||
if sess.target.has_elf_tls {
|
if sess.target.has_thread_local {
|
||||||
ret.insert((sym::target_thread_local, None));
|
ret.insert((sym::target_thread_local, None));
|
||||||
}
|
}
|
||||||
for (i, align) in [
|
for (i, align) in [
|
||||||
|
@ -3,7 +3,6 @@ use crate::spec::Target;
|
|||||||
pub fn target() -> Target {
|
pub fn target() -> Target {
|
||||||
let mut base = super::windows_msvc_base::opts();
|
let mut base = super::windows_msvc_base::opts();
|
||||||
base.max_atomic_width = Some(64);
|
base.max_atomic_width = Some(64);
|
||||||
base.has_elf_tls = true;
|
|
||||||
base.features = "+neon,+fp-armv8".to_string();
|
base.features = "+neon,+fp-armv8".to_string();
|
||||||
|
|
||||||
Target {
|
Target {
|
||||||
|
@ -3,7 +3,6 @@ use crate::spec::Target;
|
|||||||
pub fn target() -> Target {
|
pub fn target() -> Target {
|
||||||
let mut base = super::windows_uwp_msvc_base::opts();
|
let mut base = super::windows_uwp_msvc_base::opts();
|
||||||
base.max_atomic_width = Some(64);
|
base.max_atomic_width = Some(64);
|
||||||
base.has_elf_tls = true;
|
|
||||||
|
|
||||||
Target {
|
Target {
|
||||||
llvm_target: "aarch64-pc-windows-msvc".to_string(),
|
llvm_target: "aarch64-pc-windows-msvc".to_string(),
|
||||||
|
@ -11,7 +11,7 @@ pub fn opts() -> TargetOptions {
|
|||||||
.push("-Wl,--allow-multiple-definition".to_string());
|
.push("-Wl,--allow-multiple-definition".to_string());
|
||||||
base.dwarf_version = Some(2);
|
base.dwarf_version = Some(2);
|
||||||
base.position_independent_executables = true;
|
base.position_independent_executables = true;
|
||||||
base.has_elf_tls = false;
|
base.has_thread_local = false;
|
||||||
// This is for backward compatibility, see https://github.com/rust-lang/rust/issues/49867
|
// This is for backward compatibility, see https://github.com/rust-lang/rust/issues/49867
|
||||||
// for context. (At that time, there was no `-C force-unwind-tables`, so the only solution
|
// for context. (At that time, there was no `-C force-unwind-tables`, so the only solution
|
||||||
// was to always emit `uwtable`).
|
// was to always emit `uwtable`).
|
||||||
|
@ -16,7 +16,7 @@ pub fn opts(os: &str) -> TargetOptions {
|
|||||||
// TLS is flagged as enabled if it looks to be supported. The architecture
|
// TLS is flagged as enabled if it looks to be supported. The architecture
|
||||||
// only matters for default deployment target which is 11.0 for ARM64 and
|
// only matters for default deployment target which is 11.0 for ARM64 and
|
||||||
// 10.7 for everything else.
|
// 10.7 for everything else.
|
||||||
let has_elf_tls = macos_deployment_target("x86_64") >= (10, 7);
|
let has_thread_local = macos_deployment_target("x86_64") >= (10, 7);
|
||||||
|
|
||||||
TargetOptions {
|
TargetOptions {
|
||||||
os: os.to_string(),
|
os: os.to_string(),
|
||||||
@ -33,7 +33,7 @@ pub fn opts(os: &str) -> TargetOptions {
|
|||||||
has_rpath: true,
|
has_rpath: true,
|
||||||
dll_suffix: ".dylib".to_string(),
|
dll_suffix: ".dylib".to_string(),
|
||||||
archive_format: "darwin".to_string(),
|
archive_format: "darwin".to_string(),
|
||||||
has_elf_tls,
|
has_thread_local,
|
||||||
abi_return_struct_as_int: true,
|
abi_return_struct_as_int: true,
|
||||||
emit_debug_gdb_scripts: false,
|
emit_debug_gdb_scripts: false,
|
||||||
eh_frame_header: false,
|
eh_frame_header: false,
|
||||||
|
@ -53,7 +53,7 @@ pub fn opts(os: &str, arch: Arch) -> TargetOptions {
|
|||||||
dynamic_linking: false,
|
dynamic_linking: false,
|
||||||
executables: true,
|
executables: true,
|
||||||
link_env_remove: link_env_remove(arch),
|
link_env_remove: link_env_remove(arch),
|
||||||
has_elf_tls: false,
|
has_thread_local: false,
|
||||||
..super::apple_base::opts(os)
|
..super::apple_base::opts(os)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ pub fn opts() -> TargetOptions {
|
|||||||
(LinkOutputKind::StaticPicExe, &["Scrt1.o"]),
|
(LinkOutputKind::StaticPicExe, &["Scrt1.o"]),
|
||||||
]),
|
]),
|
||||||
position_independent_executables: true,
|
position_independent_executables: true,
|
||||||
has_elf_tls: true,
|
has_thread_local: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ pub fn opts() -> TargetOptions {
|
|||||||
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
|
||||||
linker: Some("rust-lld".to_owned()),
|
linker: Some("rust-lld".to_owned()),
|
||||||
executables: true,
|
executables: true,
|
||||||
has_elf_tls: true,
|
has_thread_local: true,
|
||||||
pre_link_args,
|
pre_link_args,
|
||||||
panic_strategy: PanicStrategy::Abort,
|
panic_strategy: PanicStrategy::Abort,
|
||||||
position_independent_executables: true,
|
position_independent_executables: true,
|
||||||
|
@ -4,7 +4,6 @@ pub fn target() -> Target {
|
|||||||
let mut base = super::windows_uwp_msvc_base::opts();
|
let mut base = super::windows_uwp_msvc_base::opts();
|
||||||
base.cpu = "pentium4".to_string();
|
base.cpu = "pentium4".to_string();
|
||||||
base.max_atomic_width = Some(64);
|
base.max_atomic_width = Some(64);
|
||||||
base.has_elf_tls = true;
|
|
||||||
|
|
||||||
Target {
|
Target {
|
||||||
llvm_target: "i686-pc-windows-msvc".to_string(),
|
llvm_target: "i686-pc-windows-msvc".to_string(),
|
||||||
|
@ -45,7 +45,7 @@ pub fn opts() -> TargetOptions {
|
|||||||
// (see src/libstd/sys/unix/fast_thread_local.rs) that is currently
|
// (see src/libstd/sys/unix/fast_thread_local.rs) that is currently
|
||||||
// missing in illumos. For now at least, we must fallback to using
|
// missing in illumos. For now at least, we must fallback to using
|
||||||
// pthread_{get,set}specific.
|
// pthread_{get,set}specific.
|
||||||
//has_elf_tls: true,
|
//has_thread_local: true,
|
||||||
|
|
||||||
// FIXME: Currently, rust is invoking cc to link, which ends up
|
// FIXME: Currently, rust is invoking cc to link, which ends up
|
||||||
// causing these to get included twice. We should eventually transition
|
// causing these to get included twice. We should eventually transition
|
||||||
|
@ -9,7 +9,7 @@ pub fn opts() -> TargetOptions {
|
|||||||
has_rpath: true,
|
has_rpath: true,
|
||||||
position_independent_executables: true,
|
position_independent_executables: true,
|
||||||
relro_level: RelroLevel::Full,
|
relro_level: RelroLevel::Full,
|
||||||
has_elf_tls: true,
|
has_thread_local: true,
|
||||||
crt_static_respected: true,
|
crt_static_respected: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
|
@ -1279,9 +1279,8 @@ pub struct TargetOptions {
|
|||||||
/// `argc` and `argv` values.
|
/// `argc` and `argv` values.
|
||||||
pub main_needs_argc_argv: bool,
|
pub main_needs_argc_argv: bool,
|
||||||
|
|
||||||
/// Flag indicating whether ELF TLS (e.g., #[thread_local]) is available for
|
/// Flag indicating whether #[thread_local] is available for this target.
|
||||||
/// this target.
|
pub has_thread_local: bool,
|
||||||
pub has_elf_tls: bool,
|
|
||||||
// This is mainly for easy compatibility with emscripten.
|
// This is mainly for easy compatibility with emscripten.
|
||||||
// If we give emcc .o files that are actually .bc files it
|
// If we give emcc .o files that are actually .bc files it
|
||||||
// will 'just work'.
|
// will 'just work'.
|
||||||
@ -1487,7 +1486,7 @@ impl Default for TargetOptions {
|
|||||||
archive_format: "gnu".to_string(),
|
archive_format: "gnu".to_string(),
|
||||||
main_needs_argc_argv: true,
|
main_needs_argc_argv: true,
|
||||||
allow_asm: true,
|
allow_asm: true,
|
||||||
has_elf_tls: false,
|
has_thread_local: false,
|
||||||
obj_is_bitcode: false,
|
obj_is_bitcode: false,
|
||||||
forces_embed_bitcode: false,
|
forces_embed_bitcode: false,
|
||||||
bitcode_llvm_cmdline: String::new(),
|
bitcode_llvm_cmdline: String::new(),
|
||||||
@ -2074,7 +2073,7 @@ impl Target {
|
|||||||
key!(archive_format);
|
key!(archive_format);
|
||||||
key!(allow_asm, bool);
|
key!(allow_asm, bool);
|
||||||
key!(main_needs_argc_argv, bool);
|
key!(main_needs_argc_argv, bool);
|
||||||
key!(has_elf_tls, bool);
|
key!(has_thread_local, bool);
|
||||||
key!(obj_is_bitcode, bool);
|
key!(obj_is_bitcode, bool);
|
||||||
key!(forces_embed_bitcode, bool);
|
key!(forces_embed_bitcode, bool);
|
||||||
key!(bitcode_llvm_cmdline);
|
key!(bitcode_llvm_cmdline);
|
||||||
@ -2315,7 +2314,7 @@ impl ToJson for Target {
|
|||||||
target_option_val!(archive_format);
|
target_option_val!(archive_format);
|
||||||
target_option_val!(allow_asm);
|
target_option_val!(allow_asm);
|
||||||
target_option_val!(main_needs_argc_argv);
|
target_option_val!(main_needs_argc_argv);
|
||||||
target_option_val!(has_elf_tls);
|
target_option_val!(has_thread_local);
|
||||||
target_option_val!(obj_is_bitcode);
|
target_option_val!(obj_is_bitcode);
|
||||||
target_option_val!(forces_embed_bitcode);
|
target_option_val!(forces_embed_bitcode);
|
||||||
target_option_val!(bitcode_llvm_cmdline);
|
target_option_val!(bitcode_llvm_cmdline);
|
||||||
|
@ -10,7 +10,7 @@ pub fn opts() -> TargetOptions {
|
|||||||
has_rpath: true,
|
has_rpath: true,
|
||||||
position_independent_executables: true,
|
position_independent_executables: true,
|
||||||
relro_level: RelroLevel::Full,
|
relro_level: RelroLevel::Full,
|
||||||
has_elf_tls: true,
|
has_thread_local: true,
|
||||||
crt_static_default: true,
|
crt_static_default: true,
|
||||||
crt_static_respected: true,
|
crt_static_respected: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -6,7 +6,7 @@ pub fn opts(kernel: &str) -> TargetOptions {
|
|||||||
os: format!("solid_{}", kernel),
|
os: format!("solid_{}", kernel),
|
||||||
vendor: "kmc".to_string(),
|
vendor: "kmc".to_string(),
|
||||||
frame_pointer: FramePointer::NonLeaf,
|
frame_pointer: FramePointer::NonLeaf,
|
||||||
has_elf_tls: true,
|
has_thread_local: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ pub fn target() -> Target {
|
|||||||
options: TargetOptions {
|
options: TargetOptions {
|
||||||
features: "+vfp3,+neon".to_string(),
|
features: "+vfp3,+neon".to_string(),
|
||||||
max_atomic_width: Some(64),
|
max_atomic_width: Some(64),
|
||||||
has_elf_tls: true,
|
|
||||||
// FIXME(jordanrh): use PanicStrategy::Unwind when SEH is
|
// FIXME(jordanrh): use PanicStrategy::Unwind when SEH is
|
||||||
// implemented for windows/arm in LLVM
|
// implemented for windows/arm in LLVM
|
||||||
panic_strategy: PanicStrategy::Abort,
|
panic_strategy: PanicStrategy::Abort,
|
||||||
|
@ -11,7 +11,7 @@ pub fn opts() -> TargetOptions {
|
|||||||
executables: true,
|
executables: true,
|
||||||
families: vec!["unix".to_string()],
|
families: vec!["unix".to_string()],
|
||||||
has_rpath: true,
|
has_rpath: true,
|
||||||
has_elf_tls: true,
|
has_thread_local: true,
|
||||||
crt_static_default: true,
|
crt_static_default: true,
|
||||||
crt_static_respected: true,
|
crt_static_respected: true,
|
||||||
crt_static_allows_dylibs: true,
|
crt_static_allows_dylibs: true,
|
||||||
|
@ -120,9 +120,9 @@ pub fn options() -> TargetOptions {
|
|||||||
// When the atomics feature is activated then these two keys matter,
|
// When the atomics feature is activated then these two keys matter,
|
||||||
// otherwise they're basically ignored by the standard library. In this
|
// otherwise they're basically ignored by the standard library. In this
|
||||||
// mode, however, the `#[thread_local]` attribute works (i.e.
|
// mode, however, the `#[thread_local]` attribute works (i.e.
|
||||||
// `has_elf_tls`) and we need to get it to work by specifying
|
// `has_thread_local`) and we need to get it to work by specifying
|
||||||
// `local-exec` as that's all that's implemented in LLVM today for wasm.
|
// `local-exec` as that's all that's implemented in LLVM today for wasm.
|
||||||
has_elf_tls: true,
|
has_thread_local: true,
|
||||||
tls_model: TlsModel::LocalExec,
|
tls_model: TlsModel::LocalExec,
|
||||||
|
|
||||||
// gdb scripts don't work on wasm blobs
|
// gdb scripts don't work on wasm blobs
|
||||||
|
@ -27,6 +27,7 @@ pub fn opts() -> TargetOptions {
|
|||||||
// linking some libraries which require a specific agreement, so it may
|
// linking some libraries which require a specific agreement, so it may
|
||||||
// not ever be possible for us to pass this flag.
|
// not ever be possible for us to pass this flag.
|
||||||
no_default_libraries: false,
|
no_default_libraries: false,
|
||||||
|
has_thread_local: true,
|
||||||
|
|
||||||
..base
|
..base
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ pub fn target() -> Target {
|
|||||||
let mut base = super::windows_msvc_base::opts();
|
let mut base = super::windows_msvc_base::opts();
|
||||||
base.cpu = "x86-64".to_string();
|
base.cpu = "x86-64".to_string();
|
||||||
base.max_atomic_width = Some(64);
|
base.max_atomic_width = Some(64);
|
||||||
base.has_elf_tls = true;
|
|
||||||
|
|
||||||
Target {
|
Target {
|
||||||
llvm_target: "x86_64-pc-windows-msvc".to_string(),
|
llvm_target: "x86_64-pc-windows-msvc".to_string(),
|
||||||
|
@ -8,7 +8,7 @@ pub fn target() -> Target {
|
|||||||
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-mx32".to_string());
|
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-mx32".to_string());
|
||||||
// don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
|
// don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
|
||||||
base.stack_probes = StackProbeType::Call;
|
base.stack_probes = StackProbeType::Call;
|
||||||
base.has_elf_tls = false;
|
base.has_thread_local = false;
|
||||||
// BUG(GabrielMajeri): disabling the PLT on x86_64 Linux with x32 ABI
|
// BUG(GabrielMajeri): disabling the PLT on x86_64 Linux with x32 ABI
|
||||||
// breaks code gen. See LLVM bug 36743
|
// breaks code gen. See LLVM bug 36743
|
||||||
base.needs_plt = true;
|
base.needs_plt = true;
|
||||||
|
@ -4,7 +4,6 @@ pub fn target() -> Target {
|
|||||||
let mut base = super::windows_uwp_msvc_base::opts();
|
let mut base = super::windows_uwp_msvc_base::opts();
|
||||||
base.cpu = "x86-64".to_string();
|
base.cpu = "x86-64".to_string();
|
||||||
base.max_atomic_width = Some(64);
|
base.max_atomic_width = Some(64);
|
||||||
base.has_elf_tls = true;
|
|
||||||
|
|
||||||
Target {
|
Target {
|
||||||
llvm_target: "x86_64-pc-windows-msvc".to_string(),
|
llvm_target: "x86_64-pc-windows-msvc".to_string(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user