@@ -10,8 +10,8 @@ use crate::exec::{Bootstrap, cmd};
1010use crate :: tests:: run_tests;
1111use crate :: timer:: Timer ;
1212use crate :: training:: {
13- gather_bolt_profiles, gather_llvm_profiles , gather_rustc_profiles , gather_rustdoc_profiles ,
14- llvm_benchmarks, rustc_benchmarks,
13+ gather_bolt_profiles, gather_clippy_profiles , gather_llvm_profiles , gather_rustc_profiles ,
14+ gather_rustdoc_profiles , llvm_benchmarks, rustc_benchmarks,
1515} ;
1616use crate :: utils:: artifact_size:: print_binary_sizes;
1717use crate :: utils:: io:: { copy_directory, reset_directory} ;
@@ -236,11 +236,13 @@ fn execute_pipeline(
236236 copy_rustc_perf ( env, & rustc_perf_checkout_dir)
237237 } ) ?;
238238
239+ let optimize_clippy = !is_fast_try_build ( ) ;
240+
239241 // Stage 1: Build PGO instrumented rustc
240242 // We use a normal build of LLVM, because gathering PGO profiles for LLVM and `rustc` at the
241243 // same time can cause issues, because the host and in-tree LLVM versions can diverge.
242- let ( rustc_pgo_profile, rustdoc_pgo_profile) =
243- timer. section ( "Stage 1 (Rustc + rustdoc PGO)" , |stage| {
244+ let ( rustc_pgo_profile, rustdoc_pgo_profile, clippy_pgo_profile ) =
245+ timer. section ( "Stage 1 (Rustc + rustdoc + cargo + clippy PGO)" , |stage| {
244246 let rustc_profile_dir_root = env. artifact_dir ( ) . join ( "rustc-pgo" ) ;
245247
246248 stage. section ( "Build PGO instrumented rustc and LLVM" , |section| {
@@ -253,6 +255,9 @@ fn execute_pipeline(
253255 . rustc_pgo_instrument ( & rustc_profile_dir_root)
254256 . cargo_pgo_instrument ( & rustc_profile_dir_root)
255257 . rustdoc_pgo_instrument ( & rustc_profile_dir_root) ;
258+ if optimize_clippy {
259+ builder = builder. with_clippy ( ) . clippy_pgo_instrument ( & rustc_profile_dir_root) ;
260+ }
256261
257262 if env. supports_shared_llvm ( ) {
258263 // This first LLVM that we build will be thrown away after this stage, and it
@@ -271,6 +276,13 @@ fn execute_pipeline(
271276 let rustdoc_profile = stage. section ( "Gather rustdoc profiles" , |_| {
272277 gather_rustdoc_profiles ( env, & rustc_profile_dir_root)
273278 } ) ?;
279+ let clippy_profile = if optimize_clippy {
280+ stage. section ( "Gather clippy profiles" , |_| {
281+ Ok ( Some ( gather_clippy_profiles ( env, & rustc_profile_dir_root) ?) )
282+ } ) ?
283+ } else {
284+ None
285+ } ;
274286 print_free_disk_space ( ) ?;
275287
276288 stage. section ( "Build PGO optimized rustc" , |section| {
@@ -280,14 +292,17 @@ fn execute_pipeline(
280292 . rustc_pgo_optimize ( & rustc_profile)
281293 . cargo_pgo_optimize ( & rustc_profile)
282294 . rustdoc_pgo_optimize ( & rustdoc_profile) ;
295+ if let Some ( clippy_profile) = clippy_profile. as_ref ( ) {
296+ cmd = cmd. with_clippy ( ) . clippy_pgo_optimize ( clippy_profile) ;
297+ }
283298 if env. use_bolt ( ) {
284299 cmd = cmd. with_rustc_bolt_ldflags ( ) ;
285300 }
286301
287302 cmd. run ( section)
288303 } ) ?;
289304
290- Ok ( ( rustc_profile, rustdoc_profile) )
305+ Ok ( ( rustc_profile, rustdoc_profile, clippy_profile ) )
291306 } ) ?;
292307
293308 // Stage 2: Gather LLVM PGO profiles
@@ -423,6 +438,9 @@ fn execute_pipeline(
423438 . rustc_pgo_optimize ( & rustc_pgo_profile)
424439 . cargo_pgo_optimize ( & rustc_pgo_profile)
425440 . rustdoc_pgo_optimize ( & rustdoc_pgo_profile) ;
441+ if let Some ( clippy_pgo_profile) = clippy_pgo_profile {
442+ dist = dist. clippy_pgo_optimize ( & clippy_pgo_profile) ;
443+ }
426444
427445 // if LLVM is not built we'll have PGO optimized rustc
428446 dist = if env. supports_shared_llvm ( ) || !env. build_llvm ( ) {
0 commit comments