Skip to content

Commit 3246eae

Browse files
committed
Auto merge of #30678 - Amanieu:no_elf_tls, r=alexcrichton
I also re-enabled the use of `#[thread_local]` on AArch64. It was originally disabled in the PR that introduced AArch64 (#19790), but the reasons for this were not explained. `#[thread_local]` seems to work fine in my tests on AArch64, so I don't think this should be an issue. cc @alexcrichton @akiss77
2 parents d6cb279 + e304fb4 commit 3246eae

File tree

5 files changed

+5
-45
lines changed

5 files changed

+5
-45
lines changed

mk/crates.mk

-4
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,5 @@ endef
175175

176176
$(foreach crate,$(TOOLS),$(eval $(call RUST_TOOL,$(crate))))
177177

178-
ifdef CFG_DISABLE_ELF_TLS
179-
RUSTFLAGS_std := --cfg no_elf_tls
180-
endif
181-
182178
CRATEFILE_libc := $(SREL)src/liblibc/src/lib.rs
183179
RUSTFLAGS_libc := --cfg stdbuild

src/librustc_back/target/aarch64_unknown_linux_gnu.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
use target::Target;
1212

1313
pub fn target() -> Target {
14-
let mut base = super::linux_base::opts();
15-
base.has_elf_tls = false;
14+
let base = super::linux_base::opts();
1615
Target {
1716
llvm_target: "aarch64-unknown-linux-gnu".to_string(),
1817
target_endian: "little".to_string(),

src/librustc_back/target/android_base.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ pub fn opts() -> TargetOptions {
1717
base.pre_link_args.push("-Wl,--allow-multiple-definition".to_string());
1818
base.is_like_android = true;
1919
base.position_independent_executables = true;
20+
base.has_elf_tls = false;
2021
base
2122
}

src/librustc_back/target/arm_linux_androideabi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use target::Target;
1313
pub fn target() -> Target {
1414
let mut base = super::android_base::opts();
1515
base.features = "+v7".to_string();
16-
base.has_elf_tls = false;
1716

1817
Target {
1918
llvm_target: "arm-linux-androideabi".to_string(),

src/libstd/thread/scoped_tls.rs

+3-38
Original file line numberDiff line numberDiff line change
@@ -87,32 +87,9 @@ macro_rules! scoped_thread_local {
8787
issue = "0")]
8888
#[macro_export]
8989
#[allow_internal_unstable]
90-
#[cfg(no_elf_tls)]
9190
macro_rules! __scoped_thread_local_inner {
9291
($t:ty) => {{
93-
static _KEY: $crate::thread::__ScopedKeyInner<$t> =
94-
$crate::thread::__ScopedKeyInner::new();
95-
fn _getit() -> &'static $crate::thread::__ScopedKeyInner<$t> { &_KEY }
96-
$crate::thread::ScopedKey::new(_getit)
97-
}}
98-
}
99-
100-
#[doc(hidden)]
101-
#[unstable(feature = "thread_local_internals",
102-
reason = "should not be necessary",
103-
issue = "0")]
104-
#[macro_export]
105-
#[allow_internal_unstable]
106-
#[cfg(not(no_elf_tls))]
107-
macro_rules! __scoped_thread_local_inner {
108-
($t:ty) => {{
109-
#[cfg_attr(not(any(windows,
110-
target_os = "android",
111-
target_os = "ios",
112-
target_os = "netbsd",
113-
target_os = "openbsd",
114-
target_arch = "aarch64")),
115-
thread_local)]
92+
#[cfg_attr(target_thread_local, thread_local)]
11693
static _KEY: $crate::thread::__ScopedKeyInner<$t> =
11794
$crate::thread::__ScopedKeyInner::new();
11895
fn _getit() -> &'static $crate::thread::__ScopedKeyInner<$t> { &_KEY }
@@ -221,13 +198,7 @@ impl<T> ScopedKey<T> {
221198
}
222199
}
223200

224-
#[cfg(not(any(windows,
225-
target_os = "android",
226-
target_os = "ios",
227-
target_os = "netbsd",
228-
target_os = "openbsd",
229-
target_arch = "aarch64",
230-
no_elf_tls)))]
201+
#[cfg(target_thread_local)]
231202
#[doc(hidden)]
232203
mod imp {
233204
use cell::Cell;
@@ -246,13 +217,7 @@ mod imp {
246217
}
247218
}
248219

249-
#[cfg(any(windows,
250-
target_os = "android",
251-
target_os = "ios",
252-
target_os = "netbsd",
253-
target_os = "openbsd",
254-
target_arch = "aarch64",
255-
no_elf_tls))]
220+
#[cfg(not(target_thread_local))]
256221
#[doc(hidden)]
257222
mod imp {
258223
use cell::Cell;

0 commit comments

Comments
 (0)