@@ -42,10 +42,51 @@ struct SharedArgs {
4242
4343#[ derive( clap:: Parser , Clone , Debug ) ]
4444enum EnvironmentCmd {
45+ /// Perform a custom local PGO/BOLT optimized build.
46+ Local {
47+ /// Target triple of the host.
48+ #[ arg( long) ]
49+ target_triple : String ,
50+
51+ /// Checkout directory of `rustc`.
52+ #[ arg( long) ]
53+ checkout_dir : Utf8PathBuf ,
54+
55+ /// Host LLVM installation directory.
56+ #[ arg( long) ]
57+ llvm_dir : Utf8PathBuf ,
58+
59+ /// Python binary to use in bootstrap invocations.
60+ #[ arg( long, default_value = "python3" ) ]
61+ python : String ,
62+
63+ /// Directory where artifacts (like PGO profiles or rustc-perf) of this workflow
64+ /// will be stored.
65+ #[ arg( long, default_value = "opt-artifacts" ) ]
66+ artifact_dir : Utf8PathBuf ,
67+
68+ /// Is LLVM for `rustc` built in shared library mode?
69+ #[ arg( long, default_value_t = true ) ]
70+ llvm_shared : bool ,
71+
72+ /// Should BOLT optimization be used? If yes, host LLVM must have BOLT binaries
73+ /// (`llvm-bolt` and `merge-fdata`) available.
74+ #[ arg( long, default_value_t = false ) ]
75+ use_bolt : bool ,
76+
77+ /// Tests that should be skipped when testing the optimized compiler.
78+ #[ arg( long) ]
79+ skipped_tests : Vec < String > ,
80+
81+ #[ clap( flatten) ]
82+ shared : SharedArgs ,
83+ } ,
84+ /// Perform an optimized build on Linux CI, from inside Docker.
4585 LinuxCi {
4686 #[ clap( flatten) ]
4787 shared : SharedArgs ,
4888 } ,
89+ /// Perform an optimized build on Windows CI, directly inside Github Actions.
4990 WindowsCi {
5091 #[ clap( flatten) ]
5192 shared : SharedArgs ,
@@ -58,6 +99,34 @@ fn is_try_build() -> bool {
5899
59100fn create_environment ( args : Args ) -> anyhow:: Result < ( Environment , Vec < String > ) > {
60101 let ( env, args) = match args. env {
102+ EnvironmentCmd :: Local {
103+ target_triple,
104+ checkout_dir,
105+ llvm_dir,
106+ python,
107+ artifact_dir,
108+ llvm_shared,
109+ use_bolt,
110+ skipped_tests,
111+ shared,
112+ } => {
113+ let env = EnvironmentBuilder :: default ( )
114+ . host_triple ( target_triple)
115+ . python_binary ( python)
116+ . checkout_dir ( checkout_dir. clone ( ) )
117+ . host_llvm_dir ( llvm_dir)
118+ . artifact_dir ( artifact_dir)
119+ . build_dir ( checkout_dir)
120+ . shared_llvm ( llvm_shared)
121+ . use_bolt ( use_bolt)
122+ . skipped_tests ( skipped_tests)
123+ . build ( ) ?;
124+ with_log_group ( "Building rustc-perf" , || {
125+ Ok :: < ( ) , anyhow:: Error > ( download_rustc_perf ( & env) ?)
126+ } ) ?;
127+
128+ ( env, shared. build_args )
129+ }
61130 EnvironmentCmd :: LinuxCi { shared } => {
62131 let target_triple =
63132 std:: env:: var ( "PGO_HOST" ) . expect ( "PGO_HOST environment variable missing" ) ;
@@ -74,7 +143,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
74143 . use_bolt ( true )
75144 . skipped_tests ( vec ! [
76145 // Fails because of linker errors, as of June 2023.
77- "tests/ui/process/nofile-limit.rs" ,
146+ "tests/ui/process/nofile-limit.rs" . to_string ( ) ,
78147 ] )
79148 . build ( ) ?;
80149 // /tmp/rustc-perf comes from the x64 dist Dockerfile
@@ -100,7 +169,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
100169 . use_bolt ( false )
101170 . skipped_tests ( vec ! [
102171 // Fails as of June 2023.
103- "tests\\ codegen\\ vec-shrink-panik.rs" ,
172+ "tests\\ codegen\\ vec-shrink-panik.rs" . to_string ( ) ,
104173 ] )
105174 . build ( ) ?;
106175
@@ -309,6 +378,8 @@ fn copy_rustc_perf(env: &Environment, dir: &Utf8Path) -> anyhow::Result<()> {
309378
310379// Download and build rustc-perf into the given environment.
311380fn download_rustc_perf ( env : & Environment ) -> anyhow:: Result < ( ) > {
381+ reset_directory ( & env. rustc_perf_dir ( ) ) ?;
382+
312383 // FIXME: add some mechanism for synchronization of this commit SHA with
313384 // Linux (which builds rustc-perf in a Dockerfile)
314385 // rustc-perf version from 2023-05-30
0 commit comments