Skip to content

Commit

Permalink
Rollup merge of rust-lang#47110 - EdSchouten:cloudabi-tls, r=kennytm
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
kennytm authored Jan 4, 2018
2 parents b583e17 + 05949b0 commit 9e5787d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/librustc_back/target/cloudabi_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ pub fn opts() -> TargetOptions {
linker_is_gnu: true,
pre_link_args: args,
position_independent_executables: true,
// As CloudABI only supports static linkage, there is no need
// for dynamic TLS. The C library therefore does not provide
// __tls_get_addr(), which is normally used to perform dynamic
// TLS lookups by programs that make use of dlopen(). Only the
// "local-exec" and "initial-exec" TLS models can be used.
//
// "local-exec" is more efficient than "initial-exec", as the
// latter has one more level of indirection: it accesses the GOT
// (Global Offset Table) to obtain the effective address of a
// thread-local variable. Using a GOT is useful only when doing
// dynamic linking.
tls_model: "local-exec".to_string(),
relro_level: RelroLevel::Full,
exe_allocation_crate: super::maybe_jemalloc(),
.. Default::default()
Expand Down

0 comments on commit 9e5787d

Please sign in to comment.