Skip to content

Commit b5dfe06

Browse files
committed
Auto merge of #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: #140753
2 parents 7e552b4 + ed792d4 commit b5dfe06

File tree

10 files changed

+65
-32
lines changed

10 files changed

+65
-32
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/bootstrap/bootstrap.py

+24-23
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def unpack(tarball, tarball_suffix, dst, verbose=False, match=None):
204204
name = member.replace(fname + "/", "", 1)
205205
if match is not None and not name.startswith(match):
206206
continue
207-
name = name[len(match) + 1 :]
207+
name = name[len(match) + 1:]
208208

209209
dst_path = os.path.join(dst, name)
210210
if verbose:
@@ -486,15 +486,15 @@ class DownloadInfo:
486486
"""A helper class that can be pickled into a parallel subprocess"""
487487

488488
def __init__(
489-
self,
490-
base_download_url,
491-
download_path,
492-
bin_root,
493-
tarball_path,
494-
tarball_suffix,
495-
stage0_data,
496-
pattern,
497-
verbose,
489+
self,
490+
base_download_url,
491+
download_path,
492+
bin_root,
493+
tarball_path,
494+
tarball_suffix,
495+
stage0_data,
496+
pattern,
497+
verbose,
498498
):
499499
self.base_download_url = base_download_url
500500
self.download_path = download_path
@@ -576,7 +576,7 @@ def __init__(self, config_toml="", args=None):
576576
self.stage0_data["compiler_date"], self.stage0_data["compiler_version"]
577577
)
578578
self.download_url = (
579-
os.getenv("RUSTUP_DIST_SERVER") or self.stage0_data["dist_server"]
579+
os.getenv("RUSTUP_DIST_SERVER") or self.stage0_data["dist_server"]
580580
)
581581

582582
self.build = args.build or self.build_triple()
@@ -597,10 +597,10 @@ def download_toolchain(self):
597597
key = self.stage0_compiler.date
598598
is_outdated = self.program_out_of_date(self.rustc_stamp(), key)
599599
need_rustc = self.rustc().startswith(bin_root) and (
600-
not os.path.exists(self.rustc()) or is_outdated
600+
not os.path.exists(self.rustc()) or is_outdated
601601
)
602602
need_cargo = self.cargo().startswith(bin_root) and (
603-
not os.path.exists(self.cargo()) or is_outdated
603+
not os.path.exists(self.cargo()) or is_outdated
604604
)
605605

606606
if need_rustc or need_cargo:
@@ -617,10 +617,10 @@ def download_toolchain(self):
617617
script = (
618618
# NOTE: can't use `taskkill` or `Get-Process -Name` because they error if
619619
# the server isn't running.
620-
"Get-Process | "
621-
+ 'Where-Object {$_.Name -eq "rust-analyzer-proc-macro-srv"} |'
622-
+ 'Where-Object {{$_.Path -match "{}"}} |'.format(regex)
623-
+ "Stop-Process"
620+
"Get-Process | "
621+
+ 'Where-Object {$_.Name -eq "rust-analyzer-proc-macro-srv"} |'
622+
+ 'Where-Object {{$_.Path -match "{}"}} |'.format(regex)
623+
+ "Stop-Process"
624624
)
625625
run_powershell([script])
626626
shutil.rmtree(bin_root)
@@ -844,7 +844,7 @@ def fix_bin_or_dylib(self, fname):
844844
if ".so" not in fname:
845845
# Finally, set the correct .interp for binaries
846846
with open(
847-
"{}/nix-support/dynamic-linker".format(nix_deps_dir)
847+
"{}/nix-support/dynamic-linker".format(nix_deps_dir)
848848
) as dynamic_linker:
849849
patchelf_args += ["--set-interpreter", dynamic_linker.read().rstrip()]
850850

@@ -968,12 +968,12 @@ def get_string(line):
968968
"""
969969
start = line.find('"')
970970
if start != -1:
971-
end = start + 1 + line[start + 1 :].find('"')
972-
return line[start + 1 : end]
971+
end = start + 1 + line[start + 1:].find('"')
972+
return line[start + 1: end]
973973
start = line.find("'")
974974
if start != -1:
975-
end = start + 1 + line[start + 1 :].find("'")
976-
return line[start + 1 : end]
975+
end = start + 1 + line[start + 1:].find("'")
976+
return line[start + 1: end]
977977
return None
978978

979979
def bootstrap_out(self):
@@ -1109,6 +1109,7 @@ def build_bootstrap_cmd(self, env):
11091109
else:
11101110
deny_warnings = self.warnings == "deny"
11111111
if deny_warnings:
1112+
print("DENYING WARNINGS IN PYTHON")
11121113
env["RUSTFLAGS"] += " -Dwarnings"
11131114

11141115
# Add RUSTFLAGS_BOOTSTRAP to RUSTFLAGS for bootstrap compilation.
@@ -1267,7 +1268,7 @@ def bootstrap(args):
12671268
rust_root = os.path.abspath(os.path.join(__file__, "../../.."))
12681269

12691270
if not os.path.exists(os.path.join(rust_root, ".git")) and os.path.exists(
1270-
os.path.join(rust_root, ".github")
1271+
os.path.join(rust_root, ".github")
12711272
):
12721273
eprint(
12731274
"warn: Looks like you are trying to bootstrap Rust from a source that is neither a "

src/bootstrap/src/core/builder/cargo.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,7 @@ impl Builder<'_> {
10621062
lint_flags.push("-Wunused_lifetimes");
10631063

10641064
if self.config.deny_warnings {
1065+
eprintln!("DENYING WARNINGS IN BOOTSTRAP");
10651066
lint_flags.push("-Dwarnings");
10661067
rustdocflags.arg("-Dwarnings");
10671068
}

src/bootstrap/src/core/builder/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,7 @@ impl<'a> Builder<'a> {
14781478
cmd.arg("-Wrustdoc::invalid_codeblock_attributes");
14791479

14801480
if self.config.deny_warnings {
1481+
eprintln!("DENYING WARNINGS FOR RUSTDOC IN BOOTSTRAP");
14811482
cmd.arg("-Dwarnings");
14821483
}
14831484
cmd.arg("-Znormalize-docs");

src/bootstrap/src/core/config/config.rs

+11
Original file line numberDiff line numberDiff line change
@@ -1693,6 +1693,7 @@ impl Config {
16931693
}
16941694

16951695
let mut override_toml = TomlConfig::default();
1696+
eprintln!("BOOTSTRAP SET FLAGS: {:?}", flags.set);
16961697
for option in flags.set.iter() {
16971698
fn get_table(option: &str) -> Result<TomlConfig, toml::de::Error> {
16981699
toml::from_str(option).and_then(|table: toml::Value| TomlConfig::deserialize(table))
@@ -1731,7 +1732,13 @@ impl Config {
17311732
eprintln!("failed to parse override `{option}`: `{err}");
17321733
exit!(2)
17331734
}
1735+
if let Some(r) = override_toml.rust.as_ref() {
1736+
eprintln!("BOOTSTRAP OVERRIDE TOML: {:?}", r.deny_warnings);
1737+
}
17341738
toml.merge(None, &mut Default::default(), override_toml, ReplaceOpt::Override);
1739+
if let Some(r) = toml.rust.as_ref() {
1740+
eprintln!("BOOTSTRAP TOML AFTER OVERRIDE: {:?}", r.deny_warnings);
1741+
}
17351742

17361743
config.change_id = toml.change_id.inner;
17371744

@@ -2142,6 +2149,10 @@ impl Config {
21422149
Warnings::Default => deny_warnings,
21432150
},
21442151
);
2152+
eprintln!(
2153+
"SETTING DENY WARNINGS TO {}, flags: {:?}",
2154+
config.deny_warnings, flags.warnings
2155+
);
21452156
set(&mut config.backtrace_on_ice, backtrace_on_ice);
21462157
set(&mut config.rust_verify_llvm_ir, verify_llvm_ir);
21472158
config.rust_thin_lto_import_instr_limit = thin_lto_import_instr_limit;

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

+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)