@@ -95,7 +95,7 @@ fn execute_pipeline(
9595 Ok ( profile)
9696 } ) ?;
9797
98- if env. supports_bolt ( ) {
98+ let llvm_bolt_profile = if env. supports_bolt ( ) {
9999 // Stage 3: Build BOLT instrumented LLVM
100100 // We build a PGO optimized LLVM in this step, then instrument it with BOLT and gather BOLT profiles.
101101 // Note that we don't remove LLVM artifacts after this step, so that they are reused in the final dist build.
@@ -128,18 +128,24 @@ fn execute_pipeline(
128128 // the final dist build. However, when BOLT optimizes an artifact, it does so *in-place*,
129129 // therefore it will actually optimize all the hard links, which means that the final
130130 // packaged `libLLVM.so` file *will* be BOLT optimized.
131- bolt_optimize ( & llvm_lib, profile) . context ( "Could not optimize LLVM with BOLT" ) ?;
131+ bolt_optimize ( & llvm_lib, & profile) . context ( "Could not optimize LLVM with BOLT" ) ?;
132132
133133 // LLVM is not being cleared here, we want to use the BOLT-optimized LLVM
134- Ok ( ( ) )
135- } ) ?;
136- }
134+ Ok ( Some ( profile) )
135+ } ) ?
136+ } else {
137+ None
138+ } ;
137139
138- let dist = Bootstrap :: dist ( env, & dist_args)
140+ let mut dist = Bootstrap :: dist ( env, & dist_args)
139141 . llvm_pgo_optimize ( & llvm_pgo_profile)
140142 . rustc_pgo_optimize ( & rustc_pgo_profile)
141143 . avoid_rustc_rebuild ( ) ;
142144
145+ if let Some ( llvm_bolt_profile) = llvm_bolt_profile {
146+ dist = dist. with_bolt_profile ( llvm_bolt_profile) ;
147+ }
148+
143149 // Final stage: Assemble the dist artifacts
144150 // The previous PGO optimized rustc build and PGO optimized LLVM builds should be reused.
145151 timer. section ( "Stage 4 (final build)" , |stage| dist. run ( stage) ) ?;
0 commit comments