Skip to content

Commit 25f6938

Browse files
committed
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.
2 parents fe8f026 + 0328e69 commit 25f6938

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/bootstrap/builder.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,14 @@ impl<'a> Builder<'a> {
11781178
}
11791179
}
11801180

1181+
// Compile everything except libraries and proc macros with the more
1182+
// efficient initial-exec TLS model. This doesn't work with `dlopen`,
1183+
// so we can't use it by default in general, but we can use it for tools
1184+
// and our own internal libraries.
1185+
if !mode.must_support_dlopen() {
1186+
rustflags.arg("-Ztls-model=initial-exec");
1187+
}
1188+
11811189
if self.config.incremental {
11821190
cargo.env("CARGO_INCREMENTAL", "1");
11831191
} else {

src/bootstrap/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,10 @@ impl Mode {
332332
pub fn is_tool(&self) -> bool {
333333
matches!(self, Mode::ToolBootstrap | Mode::ToolRustc | Mode::ToolStd)
334334
}
335+
336+
pub fn must_support_dlopen(&self) -> bool {
337+
matches!(self, Mode::Std | Mode::Codegen)
338+
}
335339
}
336340

337341
impl Build {

0 commit comments

Comments
 (0)