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 @@ -1111,6 +1111,18 @@ pub fn rustc_cargo(
11111111 cargo. rustflag ( "-Clink-args=-Wl,--icf=all" ) ;
11121112 }
11131113
1114+ // Use protected visibility for rustc_driver.so. This significantly reduces the
1115+ // amount of symbols the dynamic linker has to process at runtime as protected
1116+ // symbols defined in the same DSO can't be overwritten by other DSO's and thus
1117+ // can be directly referenced rather than going through the GOT. Only do this
1118+ // with lld however as ld.bfd versions older than 2.40 will give a linker error
1119+ // when using protected symbols with object files compiled by LLVM. See
1120+ // https://davidlattimore.github.io/posts/2024/08/27/rust-dylib-rabbit-holes.html
1121+ // for more details.
1122+ if builder. config . lld_mode . is_used ( ) {
1123+ cargo. rustflag ( "-Zdefault-visibility=protected" ) ;
1124+ }
1125+
11141126 if builder. config . rust_profile_use . is_some ( ) && builder. config . rust_profile_generate . is_some ( ) {
11151127 panic ! ( "Cannot use and generate PGO profiles at the same time" ) ;
11161128 }
You can’t perform that action at this time.
0 commit comments