about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorDavid Lattimore <dvdlttmr@gmail.com>2024-10-27 13:54:31 +1100
committerDavid Lattimore <dvdlttmr@gmail.com>2024-10-31 20:26:21 +1100
commit00da974c5c66113c3649e4076da4d74cada8604b (patch)
treedb50f57fccf1e4ee3baaad0bef864c0e92e344d3 /src/bootstrap
parent759e07f063fb8e6306ff1bdaeb70af56a878b415 (diff)
downloadrust-00da974c5c66113c3649e4076da4d74cada8604b.tar.gz
rust-00da974c5c66113c3649e4076da4d74cada8604b.zip
Use protected symbols when building rustc_driver
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/src/core/build_steps/compile.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
index e13d4ccc618..47c920061a7 100644
--- a/src/bootstrap/src/core/build_steps/compile.rs
+++ b/src/bootstrap/src/core/build_steps/compile.rs
@@ -1057,6 +1057,14 @@ pub fn rustc_cargo(
         cargo.rustflag("-l").rustflag("Enzyme-19");
     }
 
+    // Building with protected visibility reduces the number of dynamic relocations needed, giving
+    // us a faster startup time. However GNU ld < 2.40 will error if we try to link a shared object
+    // with direct references to protected symbols, so for now we only use protected symbols if
+    // linking with LLD is enabled.
+    if builder.build.config.lld_mode.is_used() {
+        cargo.rustflag("-Zdefault-visibility=protected");
+    }
+
     // We currently don't support cross-crate LTO in stage0. This also isn't hugely necessary
     // and may just be a time sink.
     if compiler.stage != 0 {