Skip to content

Commit 26d129c

Browse files
authored
Rollup merge of rust-lang#47110 - EdSchouten:cloudabi-tls, r=kennytm
Use the right TLS model for CloudABI. CloudABI doesn't do dynamic linking. For this reason, there is no need to handle any other TLS model than local-exec. CloudABI's C library doesn't provide a __tls_get_addr() function to do Dynamic TLS. By forcing local-exec to be used here, we ensure that we don't generate function calls to __tls_get_addr().
2 parents 016f7f4 + 05949b0 commit 26d129c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/librustc_back/target/cloudabi_base.rs

+12
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ pub fn opts() -> TargetOptions {
2727
linker_is_gnu: true,
2828
pre_link_args: args,
2929
position_independent_executables: true,
30+
// As CloudABI only supports static linkage, there is no need
31+
// for dynamic TLS. The C library therefore does not provide
32+
// __tls_get_addr(), which is normally used to perform dynamic
33+
// TLS lookups by programs that make use of dlopen(). Only the
34+
// "local-exec" and "initial-exec" TLS models can be used.
35+
//
36+
// "local-exec" is more efficient than "initial-exec", as the
37+
// latter has one more level of indirection: it accesses the GOT
38+
// (Global Offset Table) to obtain the effective address of a
39+
// thread-local variable. Using a GOT is useful only when doing
40+
// dynamic linking.
41+
tls_model: "local-exec".to_string(),
3042
relro_level: RelroLevel::Full,
3143
exe_allocation_crate: super::maybe_jemalloc(),
3244
.. Default::default()

0 commit comments

Comments
 (0)