Enable thread_local for OpenHarmony#158750
Conversation
|
These commits modify compiler targets. |
|
r? @oli-obk rustbot has assigned @oli-obk. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| // Cygwin don't need this as PE/Coff don't have weak symbols | ||
| if self.sess.target.tls_model == TlsModel::Emulated | ||
| && self.sess.target.binary_format == BinaryFormat::Elf | ||
| { | ||
| let has_tls = symbols.iter().any(|s| s.kind == SymbolExportKind::Tls); | ||
| if has_tls { | ||
| // use `*` wildcard to avoid error with `--no-undefined-version` | ||
| debug!(" __emutls_get_address*;"); | ||
| writeln!(f, " __emutls_get_address*;")?; | ||
| } | ||
| } |
There was a problem hiding this comment.
Is this necessary?
There's several other Rust targets that are TlsModel::Emulated && BinaryFormat::Elf and they have been working... uh, I can't say perfectly, but the problems we have with them not working aren't caused by this symbol being non-exported, as far as I know.
There was a problem hiding this comment.
tls-dylib-access.rs will fail without this symbol being exported (at least on Android and OHOS, not sure about OpenBSD): #147590 (comment)
|
ELF TLS should work fine, the only concern I have is ABI compatibility with /// Tests whether the target uses emulated TLS as default.
///
/// Note: Android API level 29 (10) introduced ELF TLS.
bool hasDefaultEmulatedTLS() const {
return (isAndroid() && isAndroidVersionLT(29)) || isOSOpenBSD() ||
isWindowsCygwinEnvironment() || isOHOSFamily();
} |
|
Hm. Do we have any tests that would cover interactions with such things across the FFI boundary? |
|
The only test that conver TLS FFI is https://github.com/rust-lang/rust/blob/main/tests/run-make/raw-dylib-elf/main.rs |
I have run ui test on OpenHarmony 6.1.1 (HarmonyOS 6.1.0.130 SP15) and no regression was found.
A small performance test shows some improvement:
This also fix potential
fatal runtime error: out of TLS keys, abortingissues