Auto merge of #78201 - joshtriplett:rustc-tls-model, r=Mark-Simulacrum

Compile rustc crates with the initial-exec TLS model

This should produce more efficient code, with fewer calls to
__tls_get_addr. The tradeoff is that libraries using it won't work with
dlopen, but that shouldn't be a problem for rustc's internal libraries.
This commit is contained in:
bors 2020-11-09 11:08:07 +00:00
commit 25f6938da4
2 changed files with 12 additions and 0 deletions

View File

@ -1178,6 +1178,14 @@ impl<'a> Builder<'a> {
}
}
// Compile everything except libraries and proc macros with the more
// efficient initial-exec TLS model. This doesn't work with `dlopen`,
// so we can't use it by default in general, but we can use it for tools
// and our own internal libraries.
if !mode.must_support_dlopen() {
rustflags.arg("-Ztls-model=initial-exec");
}
if self.config.incremental {
cargo.env("CARGO_INCREMENTAL", "1");
} else {

View File

@ -332,6 +332,10 @@ impl Mode {
pub fn is_tool(&self) -> bool {
matches!(self, Mode::ToolBootstrap | Mode::ToolRustc | Mode::ToolStd)
}
pub fn must_support_dlopen(&self) -> bool {
matches!(self, Mode::Std | Mode::Codegen)
}
}
impl Build {