Skip to content

Commit c7de77a

Browse files
committed
Auto merge of rust-lang#140786 - Kobzol:try-builds-no-deny-warnings, r=<try>
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
2 parents 7e552b4 + 578b722 commit c7de77a

File tree

6 files changed

+47
-22
lines changed

6 files changed

+47
-22
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",

library/core/src/alloc/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ impl Error for AllocError {}
4242
#[unstable(feature = "allocator_api", issue = "32838")]
4343
impl fmt::Display for AllocError {
4444
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
45+
let a = 5;
4546
f.write_str("memory allocation failed")
4647
}
4748
}

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

+28-15
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ impl CmdBuilder {
2323
self
2424
}
2525

26+
pub fn args(mut self, args: &[&str]) -> Self {
27+
for arg in args {
28+
self.args.push(arg.to_string());
29+
}
30+
self
31+
}
32+
2633
pub fn env(mut self, name: &str, value: &str) -> Self {
2734
self.env.insert(name.to_string(), value.to_string());
2835
self
@@ -100,26 +107,28 @@ pub struct Bootstrap {
100107
impl Bootstrap {
101108
pub fn build(env: &Environment) -> Self {
102109
let metrics_path = env.build_root().join("build").join("metrics.json");
103-
let cmd = cmd(&[
104-
env.python_binary(),
105-
env.checkout_path().join("x.py").as_str(),
106-
"build",
107-
"--target",
108-
&env.host_tuple(),
109-
"--host",
110-
&env.host_tuple(),
111-
"--stage",
112-
"2",
113-
"library/std",
114-
])
115-
.env("RUST_BACKTRACE", "full");
110+
let cmd = cmd(&[env.python_binary(), env.checkout_path().join("x.py").as_str()]);
111+
let cmd = add_shared_x_flags(env, cmd)
112+
.args(&[
113+
"build",
114+
"--target",
115+
&env.host_tuple(),
116+
"--host",
117+
&env.host_tuple(),
118+
"--stage",
119+
"2",
120+
"library/std",
121+
])
122+
.env("RUST_BACKTRACE", "full");
123+
116124
Self { cmd, metrics_path }
117125
}
118126

119127
pub fn dist(env: &Environment, dist_args: &[String]) -> Self {
120128
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");
129+
let args = dist_args.iter().map(|arg| arg.as_str()).collect::<Vec<_>>();
130+
let cmd = cmd(&args).env("RUST_BACKTRACE", "full");
131+
let cmd = add_shared_x_flags(env, cmd);
123132
Self { cmd, metrics_path }
124133
}
125134

@@ -184,3 +193,7 @@ impl Bootstrap {
184193
Ok(())
185194
}
186195
}
196+
197+
fn add_shared_x_flags(env: &Environment, cmd: CmdBuilder) -> CmdBuilder {
198+
if env.is_fast_try_build() { cmd.arg("--set").arg("rust.deny-warnings=false") } else { cmd }
199+
}

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

+12-4
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,13 @@ enum EnvironmentCmd {
111111
},
112112
}
113113

114-
fn is_try_build() -> bool {
114+
/// Are we supposed to only build the bare minimum of components to get a working toolchain?
115+
fn is_fast_try_build() -> bool {
115116
std::env::var("DIST_TRY_BUILD").unwrap_or_else(|_| "0".to_string()) != "0"
116117
}
117118

118119
fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)> {
120+
let is_fast_try_build = is_fast_try_build();
119121
let (env, args) = match args.env {
120122
EnvironmentCmd::Local {
121123
target_triple,
@@ -144,6 +146,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
144146
.skipped_tests(skipped_tests)
145147
.benchmark_cargo_config(benchmark_cargo_config)
146148
.run_tests(run_tests)
149+
.fast_try_build(is_fast_try_build)
147150
.build()?;
148151

149152
(env, shared.build_args)
@@ -167,6 +170,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
167170
.use_bolt(!is_aarch64)
168171
.skipped_tests(vec![])
169172
.run_tests(true)
173+
.fast_try_build(is_fast_try_build)
170174
.build()?;
171175

172176
(env, shared.build_args)
@@ -187,6 +191,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
187191
.use_bolt(false)
188192
.skipped_tests(vec![])
189193
.run_tests(true)
194+
.fast_try_build(is_fast_try_build)
190195
.build()?;
191196

192197
(env, shared.build_args)
@@ -352,7 +357,7 @@ fn execute_pipeline(
352357
// possible regressions.
353358
// The tests are not executed for try builds, which can be in various broken states, so we don't
354359
// want to gatekeep them with tests.
355-
if !is_try_build() && env.run_tests() {
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)
@@ -394,7 +402,7 @@ fn main() -> anyhow::Result<()> {
394402
let (env, mut build_args) = create_environment(args).context("Cannot create environment")?;
395403

396404
// Skip components that are not needed for try builds to speed them up
397-
if is_try_build() {
405+
if is_fast_try_build() {
398406
log::info!("Skipping building of unimportant components for a try build");
399407
for target in [
400408
"rust-docs",

0 commit comments

Comments
 (0)