File tree Expand file tree Collapse file tree 5 files changed +31
-1
lines changed Expand file tree Collapse file tree 5 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,10 @@ impl Environment for LinuxEnvironment {
4141 true
4242 }
4343
44+ fn supports_shared_llvm ( & self ) -> bool {
45+ true
46+ }
47+
4448 fn executable_extension ( & self ) -> & ' static str {
4549 ""
4650 }
Original file line number Diff line number Diff line change @@ -60,6 +60,8 @@ pub trait Environment {
6060
6161 fn supports_bolt ( & self ) -> bool ;
6262
63+ fn supports_shared_llvm ( & self ) -> bool ;
64+
6365 /// What is the extension of binary executables in this environment?
6466 fn executable_extension ( & self ) -> & ' static str ;
6567
Original file line number Diff line number Diff line change @@ -65,6 +65,10 @@ impl Environment for WindowsEnvironment {
6565 false
6666 }
6767
68+ fn supports_shared_llvm ( & self ) -> bool {
69+ false
70+ }
71+
6872 fn executable_extension ( & self ) -> & ' static str {
6973 ".exe"
7074 }
Original file line number Diff line number Diff line change @@ -139,6 +139,16 @@ impl Bootstrap {
139139 self
140140 }
141141
142+ pub fn without_llvm_lto ( mut self ) -> Self {
143+ self . cmd = self
144+ . cmd
145+ . arg ( "--set" )
146+ . arg ( "llvm.thin-lto=false" )
147+ . arg ( "--set" )
148+ . arg ( "llvm.link-shared=true" ) ;
149+ self
150+ }
151+
142152 pub fn rustc_pgo_optimize ( mut self , profile : & RustcPGOProfile ) -> Self {
143153 self . cmd = self . cmd . arg ( "--rust-profile-use" ) . arg ( profile. 0 . as_str ( ) ) ;
144154 self
Original file line number Diff line number Diff line change @@ -38,7 +38,17 @@ fn execute_pipeline(
3838 let rustc_profile_dir_root = env. opt_artifacts ( ) . join ( "rustc-pgo" ) ;
3939
4040 stage. section ( "Build PGO instrumented rustc and LLVM" , |section| {
41- Bootstrap :: build ( env) . rustc_pgo_instrument ( & rustc_profile_dir_root) . run ( section)
41+ let mut builder = Bootstrap :: build ( env) . rustc_pgo_instrument ( & rustc_profile_dir_root) ;
42+
43+ if env. supports_shared_llvm ( ) {
44+ // This first LLVM that we build will be thrown away after this stage, and it
45+ // doesn't really need LTO. Without LTO, it builds in ~1 minute thanks to sccache,
46+ // with LTO it takes almost 10 minutes. It makes the followup Rustc PGO
47+ // instrumented/optimized build a bit slower, but it seems to be worth it.
48+ builder = builder. without_llvm_lto ( ) ;
49+ }
50+
51+ builder. run ( section)
4252 } ) ?;
4353
4454 let profile = stage
You can’t perform that action at this time.
0 commit comments