@@ -42,10 +42,51 @@ struct SharedArgs {
42
42
43
43
#[ derive( clap:: Parser , Clone , Debug ) ]
44
44
enum 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.
45
85
LinuxCi {
46
86
#[ clap( flatten) ]
47
87
shared : SharedArgs ,
48
88
} ,
89
+ /// Perform an optimized build on Windows CI, directly inside Github Actions.
49
90
WindowsCi {
50
91
#[ clap( flatten) ]
51
92
shared : SharedArgs ,
@@ -58,6 +99,34 @@ fn is_try_build() -> bool {
58
99
59
100
fn create_environment ( args : Args ) -> anyhow:: Result < ( Environment , Vec < String > ) > {
60
101
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
+ }
61
130
EnvironmentCmd :: LinuxCi { shared } => {
62
131
let target_triple =
63
132
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>)>
74
143
. use_bolt ( true )
75
144
. skipped_tests ( vec ! [
76
145
// 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 ( ) ,
78
147
] )
79
148
. build ( ) ?;
80
149
// /tmp/rustc-perf comes from the x64 dist Dockerfile
@@ -100,7 +169,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
100
169
. use_bolt ( false )
101
170
. skipped_tests ( vec ! [
102
171
// Fails as of June 2023.
103
- "tests\\ codegen\\ vec-shrink-panik.rs" ,
172
+ "tests\\ codegen\\ vec-shrink-panik.rs" . to_string ( ) ,
104
173
] )
105
174
. build ( ) ?;
106
175
@@ -309,6 +378,8 @@ fn copy_rustc_perf(env: &Environment, dir: &Utf8Path) -> anyhow::Result<()> {
309
378
310
379
// Download and build rustc-perf into the given environment.
311
380
fn download_rustc_perf ( env : & Environment ) -> anyhow:: Result < ( ) > {
381
+ reset_directory ( & env. rustc_perf_dir ( ) ) ?;
382
+
312
383
// FIXME: add some mechanism for synchronization of this commit SHA with
313
384
// Linux (which builds rustc-perf in a Dockerfile)
314
385
// rustc-perf version from 2023-05-30
0 commit comments