about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-11-09 11:08:07 +0000
committerbors <bors@rust-lang.org>2020-11-09 11:08:07 +0000
commit25f6938da459a57b43bdf16ed6bdad3225b2a3ce (patch)
tree5d7a6a65a538abf0307adfc212f6859a78c24376
parentfe8f02690804d5ee696bd3bca9515f5f71857e3b (diff)
parent0328e69287b083af4d5d4b49cfc9175e9c82c88e (diff)
downloadrust-25f6938da459a57b43bdf16ed6bdad3225b2a3ce.tar.gz
rust-25f6938da459a57b43bdf16ed6bdad3225b2a3ce.zip
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.
-rw-r--r--src/bootstrap/builder.rs8
-rw-r--r--src/bootstrap/lib.rs4
2 files changed, 12 insertions, 0 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index b48508f2c24..db671c5fe65 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -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 {
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index 0878b0ff789..3d111839dc7 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -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 {