Skip to content

Commit 9fa9ef3

Browse files
committed
Auto merge of #131634 - davidlattimore:lld-protected, r=Kobzol
Use protected visibility when building rustc with LLD rust-lang/compiler-team#782 I wasn't sure about having two commits in a PR, but I figured, at least initially it might make sense to discuss these commits together. Happy to squash, or move the second commit to a separate PR. I contemplated trying to enable protected visibility for more cases when LLD will be used other than just `-Zlinker-features=+lld`, but that would be more a complex change that probably still wouldn't cover all cases when LLD is used, so went with the simplest option of just checking if the linker-feature is enabled. r? lqd
2 parents a8e1186 + 00da974 commit 9fa9ef3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/bootstrap/src/core/build_steps/compile.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,14 @@ pub fn rustc_cargo(
10561056
cargo.rustflag("-l").rustflag("Enzyme-19");
10571057
}
10581058

1059+
// Building with protected visibility reduces the number of dynamic relocations needed, giving
1060+
// us a faster startup time. However GNU ld < 2.40 will error if we try to link a shared object
1061+
// with direct references to protected symbols, so for now we only use protected symbols if
1062+
// linking with LLD is enabled.
1063+
if builder.build.config.lld_mode.is_used() {
1064+
cargo.rustflag("-Zdefault-visibility=protected");
1065+
}
1066+
10591067
// We currently don't support cross-crate LTO in stage0. This also isn't hugely necessary
10601068
// and may just be a time sink.
10611069
if compiler.stage != 0 {

0 commit comments

Comments
 (0)