Skip to content

Commit 50aa041

Browse files
committed
Auto merge of rust-lang#140786 - Kobzol:try-builds-no-deny-warnings, r=jieyouxu
Do not deny warnings in "fast" try builds When we do the classic ``@bors` try` build without specifying `try-job` in the PR description, we want to get a compiler toolchain for perf./crater/local experimentation as fast as possible. We don't run any tests in that case, so it seems reasonable to also ignore warnings. Fixes: rust-lang#140753 r? `@jieyouxu` try-job: dist-x86_64-linux
2 parents fe348cd + 4f9bb8c commit 50aa041

File tree

6 files changed

+42
-20
lines changed

6 files changed

+42
-20
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -2567,7 +2567,6 @@ dependencies = [
25672567
"humansize",
25682568
"humantime",
25692569
"log",
2570-
"serde",
25712570
"serde_json",
25722571
"sysinfo",
25732572
"tabled",

src/doc/rustc-dev-guide/src/tests/ci.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,16 @@ There are several use-cases for try builds:
135135
- Run a specific CI job (e.g. Windows tests) on a PR, to quickly test if it
136136
passes the test suite executed by that job.
137137

138-
You can select which CI jobs will
139-
be executed in the try build by adding lines containing `try-job:
140-
<job pattern>` to the PR description. All such specified jobs will be executed
141-
in the try build once the `@bors try` command is used on the PR. If no try
142-
jobs are specified in this way, the jobs defined in the `try` section of
143-
[`jobs.yml`] will be executed by default.
138+
By default, if you send a comment with `@bors try`, the jobs defined in the `try` section of
139+
[`jobs.yml`] will be executed. We call this mode a "fast try build". Such a try build
140+
will not execute any tests, and it will allow compilation warnings. It is useful when you want to
141+
get an optimized toolchain as fast as possible, for a crater run or performance benchmarks,
142+
even if it might not be working fully correctly.
143+
144+
If you want to run a custom CI job in a try build and make sure that it passes all tests and does
145+
not produce any compilation warnings, you can select CI jobs to be executed by adding lines
146+
containing `try-job: <job pattern>` to the PR description. All such specified jobs will be executed
147+
in the try build once the `@bors try` command is used on the PR.
144148

145149
Each pattern can either be an exact name of a job or a glob pattern that matches multiple jobs,
146150
for example `*msvc*` or `*-alt`. You can start at most 20 jobs in a single try build. When using

src/tools/opt-dist/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "opt-dist"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
[dependencies]
77
build_helper = { path = "../../build_helper" }
@@ -15,7 +15,6 @@ fs_extra = "1"
1515
camino = "1"
1616
tar = "0.4"
1717
xz = { version = "0.1", package = "xz2" }
18-
serde = { version = "1", features = ["derive"] }
1918
serde_json = "1"
2019
glob = "0.3"
2120
tempfile = "3.5"

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

+17-9
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

@@ -361,7 +366,10 @@ fn execute_pipeline(
361366

362367
fn main() -> anyhow::Result<()> {
363368
// Make sure that we get backtraces for easier debugging in CI
364-
std::env::set_var("RUST_BACKTRACE", "1");
369+
unsafe {
370+
// SAFETY: we are the only thread running at this point
371+
std::env::set_var("RUST_BACKTRACE", "1");
372+
}
365373

366374
env_logger::builder()
367375
.filter_level(LevelFilter::Info)
@@ -393,9 +401,9 @@ fn main() -> anyhow::Result<()> {
393401

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

396-
// Skip components that are not needed for try builds to speed them up
397-
if is_try_build() {
398-
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");
399407
for target in [
400408
"rust-docs",
401409
"rustc-docs",

0 commit comments

Comments
 (0)