Skip to content

Commit 082777e

Browse files
committed
Do not deny warnings for fast try builds
1 parent 34495f5 commit 082777e

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

src/tools/opt-dist/src/environment.rs

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub struct Environment {
2626
use_bolt: bool,
2727
shared_llvm: bool,
2828
run_tests: bool,
29+
fast_try_build: bool,
2930
}
3031

3132
impl Environment {
@@ -106,6 +107,10 @@ impl Environment {
106107
pub fn run_tests(&self) -> bool {
107108
self.run_tests
108109
}
110+
111+
pub fn is_fast_try_build(&self) -> bool {
112+
self.fast_try_build
113+
}
109114
}
110115

111116
/// What is the extension of binary executables on this platform?

src/tools/opt-dist/src/exec.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,16 @@ impl Bootstrap {
113113
"library/std",
114114
])
115115
.env("RUST_BACKTRACE", "full");
116+
let cmd = add_shared_x_flags(env, cmd);
117+
116118
Self { cmd, metrics_path }
117119
}
118120

119121
pub fn dist(env: &Environment, dist_args: &[String]) -> Self {
120122
let metrics_path = env.build_root().join("build").join("metrics.json");
121-
let cmd = cmd(&dist_args.iter().map(|arg| arg.as_str()).collect::<Vec<_>>())
122-
.env("RUST_BACKTRACE", "full");
123+
let args = dist_args.iter().map(|arg| arg.as_str()).collect::<Vec<_>>();
124+
let cmd = cmd(&args).env("RUST_BACKTRACE", "full");
125+
let cmd = add_shared_x_flags(env, cmd);
123126
Self { cmd, metrics_path }
124127
}
125128

@@ -184,3 +187,7 @@ impl Bootstrap {
184187
Ok(())
185188
}
186189
}
190+
191+
fn add_shared_x_flags(env: &Environment, cmd: CmdBuilder) -> CmdBuilder {
192+
if env.is_fast_try_build() { cmd.arg("--set").arg("rust.deny-warnings=false") } else { cmd }
193+
}

src/tools/opt-dist/src/main.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ enum EnvironmentCmd {
9595
#[arg(long)]
9696
benchmark_cargo_config: Vec<String>,
9797

98-
/// Perform tests after final build if it's not a try build
98+
/// Perform tests after final build if it's not a fast try build
9999
#[arg(long)]
100100
run_tests: bool,
101101
},
@@ -111,11 +111,14 @@ enum EnvironmentCmd {
111111
},
112112
}
113113

114-
fn is_try_build() -> bool {
114+
/// For a fast try build, we want to only build the bare minimum of components to get a
115+
/// working toolchain, and not run any tests.
116+
fn is_fast_try_build() -> bool {
115117
std::env::var("DIST_TRY_BUILD").unwrap_or_else(|_| "0".to_string()) != "0"
116118
}
117119

118120
fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)> {
121+
let is_fast_try_build = is_fast_try_build();
119122
let (env, args) = match args.env {
120123
EnvironmentCmd::Local {
121124
target_triple,
@@ -144,6 +147,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
144147
.skipped_tests(skipped_tests)
145148
.benchmark_cargo_config(benchmark_cargo_config)
146149
.run_tests(run_tests)
150+
.fast_try_build(is_fast_try_build)
147151
.build()?;
148152

149153
(env, shared.build_args)
@@ -167,6 +171,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
167171
.use_bolt(!is_aarch64)
168172
.skipped_tests(vec![])
169173
.run_tests(true)
174+
.fast_try_build(is_fast_try_build)
170175
.build()?;
171176

172177
(env, shared.build_args)
@@ -187,6 +192,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
187192
.use_bolt(false)
188193
.skipped_tests(vec![])
189194
.run_tests(true)
195+
.fast_try_build(is_fast_try_build)
190196
.build()?;
191197

192198
(env, shared.build_args)
@@ -350,9 +356,8 @@ fn execute_pipeline(
350356

351357
// After dist has finished, run a subset of the test suite on the optimized artifacts to discover
352358
// possible regressions.
353-
// The tests are not executed for try builds, which can be in various broken states, so we don't
354-
// want to gatekeep them with tests.
355-
if !is_try_build() && env.run_tests() {
359+
// The tests are not executed for fast try builds, which can be broken and might not pass them.
360+
if !is_fast_try_build() && env.run_tests() {
356361
timer.section("Run tests", |_| run_tests(env))?;
357362
}
358363

@@ -396,9 +401,9 @@ fn main() -> anyhow::Result<()> {
396401

397402
let (env, mut build_args) = create_environment(args).context("Cannot create environment")?;
398403

399-
// Skip components that are not needed for try builds to speed them up
400-
if is_try_build() {
401-
log::info!("Skipping building of unimportant components for a try build");
404+
// Skip components that are not needed for fast try builds to speed them up
405+
if is_fast_try_build() {
406+
log::info!("Skipping building of unimportant components for a fast try build");
402407
for target in [
403408
"rust-docs",
404409
"rustc-docs",

0 commit comments

Comments
 (0)