From 54d2067cc1495ff9643abbdaf066ca0893d09b01 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Tue, 4 Apr 2023 02:40:31 +0100 Subject: [PATCH] Disable `has_thread_local` on OpenHarmony OpenHarmony uses emulated TLS, which doesn't link properly when using thread-local variables across crate boundaries with `-C prefer-dynamic`. This PR makes thread_local! use pthreads directly instead. --- compiler/rustc_target/src/spec/aarch64_unknown_linux_ohos.rs | 1 + compiler/rustc_target/src/spec/armv7_unknown_linux_ohos.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_linux_ohos.rs b/compiler/rustc_target/src/spec/aarch64_unknown_linux_ohos.rs index 0a5e654cf0d03..bf1b089f657b4 100644 --- a/compiler/rustc_target/src/spec/aarch64_unknown_linux_ohos.rs +++ b/compiler/rustc_target/src/spec/aarch64_unknown_linux_ohos.rs @@ -18,6 +18,7 @@ pub fn target() -> Target { features: "+reserve-x18".into(), mcount: "\u{1}_mcount".into(), force_emulated_tls: true, + has_thread_local: false, supported_sanitizers: SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::LEAK diff --git a/compiler/rustc_target/src/spec/armv7_unknown_linux_ohos.rs b/compiler/rustc_target/src/spec/armv7_unknown_linux_ohos.rs index a64f3a4f0493e..16da245336773 100644 --- a/compiler/rustc_target/src/spec/armv7_unknown_linux_ohos.rs +++ b/compiler/rustc_target/src/spec/armv7_unknown_linux_ohos.rs @@ -21,6 +21,7 @@ pub fn target() -> Target { crt_static_default: false, mcount: "\u{1}mcount".into(), force_emulated_tls: true, + has_thread_local: false, ..super::linux_musl_base::opts() }, }