@@ -95,7 +95,7 @@ fn execute_pipeline(
95
95
Ok ( profile)
96
96
} ) ?;
97
97
98
- if env. supports_bolt ( ) {
98
+ let llvm_bolt_profile = if env. supports_bolt ( ) {
99
99
// Stage 3: Build BOLT instrumented LLVM
100
100
// We build a PGO optimized LLVM in this step, then instrument it with BOLT and gather BOLT profiles.
101
101
// 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(
128
128
// the final dist build. However, when BOLT optimizes an artifact, it does so *in-place*,
129
129
// therefore it will actually optimize all the hard links, which means that the final
130
130
// 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" ) ?;
132
132
133
133
// 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
+ } ;
137
139
138
- let dist = Bootstrap :: dist ( env, & dist_args)
140
+ let mut dist = Bootstrap :: dist ( env, & dist_args)
139
141
. llvm_pgo_optimize ( & llvm_pgo_profile)
140
142
. rustc_pgo_optimize ( & rustc_pgo_profile)
141
143
. avoid_rustc_rebuild ( ) ;
142
144
145
+ if let Some ( llvm_bolt_profile) = llvm_bolt_profile {
146
+ dist = dist. with_bolt_profile ( llvm_bolt_profile) ;
147
+ }
148
+
143
149
// Final stage: Assemble the dist artifacts
144
150
// The previous PGO optimized rustc build and PGO optimized LLVM builds should be reused.
145
151
timer. section ( "Stage 4 (final build)" , |stage| dist. run ( stage) ) ?;
0 commit comments