File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
src/bootstrap/src/core/build_steps Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -1096,6 +1096,18 @@ pub fn rustc_cargo(
10961096 cargo. rustflag ( "-Clink-args=-Wl,--icf=all" ) ;
10971097 }
10981098
1099+ // Use protected visibility for rustc_driver.so. This significantly reduces the
1100+ // amount of symbols the dynamic linker has to process at runtime as protected
1101+ // symbols defined in the same DSO can't be overwritten by other DSO's and thus
1102+ // can be directly referenced rather than going through the GOT. Only do this
1103+ // with lld however as ld.bfd versions older than 2.40 will give a linker error
1104+ // when using protected symbols with object files compiled by LLVM. See
1105+ // https://davidlattimore.github.io/posts/2024/08/27/rust-dylib-rabbit-holes.html
1106+ // for more details.
1107+ if builder. config . lld_mode . is_used ( ) {
1108+ cargo. rustflag ( "-Zdefault-visibility=protected" ) ;
1109+ }
1110+
10991111 if builder. config . rust_profile_use . is_some ( ) && builder. config . rust_profile_generate . is_some ( ) {
11001112 panic ! ( "Cannot use and generate PGO profiles at the same time" ) ;
11011113 }
You can’t perform that action at this time.
0 commit comments