Skip to content

Commit 6acdc26

Browse files
Auto merge of #142235 - Kobzol:rustc-dist-alt-assertions, r=<try>
Build rustc with assertions in `dist-alt` jobs Revival of #131077, to check CI times now that we don't do PGO/BOLT anymore on Linux `-alt` builds. r? `@ghost` try-job: dist-x86_64-msvc-alt try-job: dist-x86_64-linux-alt
2 parents 7c10378 + 6d4df2d commit 6acdc26

File tree

5 files changed

+58
-2
lines changed

5 files changed

+58
-2
lines changed

src/ci/github-actions/jobs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ auto:
256256
IMAGE: dist-x86_64-linux
257257
CODEGEN_BACKENDS: llvm,cranelift
258258
DOCKER_SCRIPT: dist-alt.sh
259-
<<: *job-linux-4c-largedisk
259+
<<: *job-linux-8c
260260

261261
- name: dist-x86_64-musl
262262
env:

src/ci/run.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then
134134

135135
CODEGEN_BACKENDS="${CODEGEN_BACKENDS:-llvm}"
136136
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-backends=$CODEGEN_BACKENDS"
137+
138+
# Unless explicitly disabled, we want rustc debug assertions on the -alt builds
139+
if [ "$DEPLOY_ALT" != "" ] && [ "$NO_DEBUG_ASSERTIONS" = "" ]; then
140+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-debug-assertions"
141+
fi
137142
else
138143
# We almost always want debug assertions enabled, but sometimes this takes too
139144
# long for too little benefit, so we just turn them off.

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ pub struct Environment {
2727
shared_llvm: bool,
2828
run_tests: bool,
2929
fast_try_build: bool,
30+
/// Additional configuration that bootstrap needs to know only when running tests.
31+
#[builder(default)]
32+
test_config: TestConfig,
33+
}
34+
35+
/// Builds have optional components, and their presence/absence can enable/disable a subset of
36+
/// tests. When testing the optimized artifacts, bootstrap needs to know about these enabled
37+
/// components to run the expected subset. This structure holds the known components where this
38+
/// matters: currently only whether the build to test is using debug assertions.
39+
///
40+
/// FIXME: ultimately, this is a temporary band-aid, and opt-dist should be more transparent to the
41+
/// CI config and bootstrap optional components: bootstrap has default values, combinations of flags
42+
/// that cascade into others, etc logic that we'd have to duplicate here otherwise. It's more
43+
/// sensible for opt-dist to never know about the config apart from the minimal set of paths
44+
/// required to configure stage0 tests.
45+
#[derive(Builder, Default, Clone, Debug)]
46+
pub struct TestConfig {
47+
/// Whether the build under test is explicitly using `--enable-debug-assertions`.
48+
/// Note that this flag can be implied from others, like `rust.debug`, and we do not handle any
49+
/// of these subtleties and defaults here, as per the FIXME above.
50+
pub rust_debug_assertions: bool,
3051
}
3152

3253
impl Environment {
@@ -111,6 +132,21 @@ impl Environment {
111132
pub fn is_fast_try_build(&self) -> bool {
112133
self.fast_try_build
113134
}
135+
136+
pub fn test_config(&self) -> &TestConfig {
137+
&self.test_config
138+
}
139+
}
140+
141+
impl TestConfig {
142+
/// Returns the test config matching the given `RUST_CONFIGURE_ARGS` for the known optional
143+
/// components for tests. This is obviously extremely fragile and we'd rather opt-dist not
144+
/// handle any optional components.
145+
pub fn from_configure_args(configure_args: &str) -> TestConfig {
146+
let enable_debug_assertions =
147+
configure_args.split(" ").find(|part| *part == "--enable-debug-assertions").is_some();
148+
TestConfig { rust_debug_assertions: enable_debug_assertions }
149+
}
114150
}
115151

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

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use anyhow::Context;
22
use camino::{Utf8Path, Utf8PathBuf};
33
use clap::Parser;
4+
use environment::TestConfig;
45
use log::LevelFilter;
56
use utils::io;
67

@@ -158,6 +159,11 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
158159

159160
let is_aarch64 = target_triple.starts_with("aarch64");
160161

162+
// Parse the optional build components that impact the test environment.
163+
let rust_configure_args = std::env::var("RUST_CONFIGURE_ARGS")
164+
.expect("RUST_CONFIGURE_ARGS environment variable missing");
165+
let test_config = TestConfig::from_configure_args(&rust_configure_args);
166+
161167
let checkout_dir = Utf8PathBuf::from("/checkout");
162168
let env = EnvironmentBuilder::default()
163169
.host_tuple(target_triple)
@@ -172,6 +178,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
172178
.skipped_tests(vec![])
173179
.run_tests(true)
174180
.fast_try_build(is_fast_try_build)
181+
.test_config(test_config)
175182
.build()?;
176183

177184
(env, shared.build_args)
@@ -180,6 +187,11 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
180187
let target_triple =
181188
std::env::var("PGO_HOST").expect("PGO_HOST environment variable missing");
182189

190+
// Parse the optional build components that impact the test environment.
191+
let rust_configure_args = std::env::var("RUST_CONFIGURE_ARGS")
192+
.expect("RUST_CONFIGURE_ARGS environment variable missing");
193+
let test_config = TestConfig::from_configure_args(&rust_configure_args);
194+
183195
let checkout_dir: Utf8PathBuf = std::env::current_dir()?.try_into()?;
184196
let env = EnvironmentBuilder::default()
185197
.host_tuple(target_triple)
@@ -193,6 +205,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
193205
.skipped_tests(vec![])
194206
.run_tests(true)
195207
.fast_try_build(is_fast_try_build)
208+
.test_config(test_config)
196209
.build()?;
197210

198211
(env, shared.build_args)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ change-id = 115898
7272
[rust]
7373
channel = "{channel}"
7474
verbose-tests = true
75+
debug-assertions = {debug_assertions}
7576
7677
[build]
7778
rustc = "{rustc}"
@@ -83,7 +84,8 @@ llvm-config = "{llvm_config}"
8384
"#,
8485
rustc = rustc_path.to_string().replace('\\', "/"),
8586
cargo = cargo_path.to_string().replace('\\', "/"),
86-
llvm_config = llvm_config.to_string().replace('\\', "/")
87+
llvm_config = llvm_config.to_string().replace('\\', "/"),
88+
debug_assertions = env.test_config().rust_debug_assertions,
8789
);
8890
log::info!("Using following `bootstrap.toml` for running tests:\n{config_content}");
8991

0 commit comments

Comments
 (0)