Skip to content

Commit 9b93969

Browse files
authored
Unrolled build for rust-lang#131913
Rollup merge of rust-lang#131913 - jieyouxu:only_debug_assertions, r=onur-ozkan Add `{ignore,needs}-{rustc,std}-debug-assertions` directive support Add `{ignore,needs}-{rustc,std}-debug-assertions` compiletest directives and retire the old `{ignore,only}-debug` directives. The old `{ignore,only}-debug` directives were ambiguous because you could have std built with debug assertions but rustc not built with debug assertions or vice versa. If we want to support the use case of controlling test run based on if rustc was built with debug assertions, then having `{ignore,only}-debug` will be very confusing. cc ````@matthiaskrgr```` Closes rust-lang#123987. r? bootstrap (or compiler tbh)
2 parents 5b20c45 + 0d5cc8e commit 9b93969

22 files changed

+119
-43
lines changed

src/bootstrap/src/core/build_steps/test.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1938,9 +1938,13 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
19381938

19391939
cmd.arg("--json");
19401940

1941-
if builder.config.rust_debug_assertions_std {
1942-
cmd.arg("--with-debug-assertions");
1943-
};
1941+
if builder.config.rustc_debug_assertions {
1942+
cmd.arg("--with-rustc-debug-assertions");
1943+
}
1944+
1945+
if builder.config.std_debug_assertions {
1946+
cmd.arg("--with-std-debug-assertions");
1947+
}
19441948

19451949
let mut llvm_components_passed = false;
19461950
let mut copts_passed = false;

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -833,9 +833,9 @@ impl Builder<'_> {
833833
cargo.env(
834834
profile_var("DEBUG_ASSERTIONS"),
835835
if mode == Mode::Std {
836-
self.config.rust_debug_assertions_std.to_string()
836+
self.config.std_debug_assertions.to_string()
837837
} else {
838-
self.config.rust_debug_assertions.to_string()
838+
self.config.rustc_debug_assertions.to_string()
839839
},
840840
);
841841
cargo.env(

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

+17-16
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,10 @@ pub struct Config {
263263
pub rust_optimize: RustOptimize,
264264
pub rust_codegen_units: Option<u32>,
265265
pub rust_codegen_units_std: Option<u32>,
266-
pub rust_debug_assertions: bool,
267-
pub rust_debug_assertions_std: bool,
266+
267+
pub rustc_debug_assertions: bool,
268+
pub std_debug_assertions: bool,
269+
268270
pub rust_overflow_checks: bool,
269271
pub rust_overflow_checks_std: bool,
270272
pub rust_debug_logging: bool,
@@ -1115,9 +1117,9 @@ define_config! {
11151117
debug: Option<bool> = "debug",
11161118
codegen_units: Option<u32> = "codegen-units",
11171119
codegen_units_std: Option<u32> = "codegen-units-std",
1118-
debug_assertions: Option<bool> = "debug-assertions",
1120+
rustc_debug_assertions: Option<bool> = "debug-assertions",
11191121
randomize_layout: Option<bool> = "randomize-layout",
1120-
debug_assertions_std: Option<bool> = "debug-assertions-std",
1122+
std_debug_assertions: Option<bool> = "debug-assertions-std",
11211123
overflow_checks: Option<bool> = "overflow-checks",
11221124
overflow_checks_std: Option<bool> = "overflow-checks-std",
11231125
debug_logging: Option<bool> = "debug-logging",
@@ -1652,8 +1654,8 @@ impl Config {
16521654
let mut llvm_offload = None;
16531655
let mut llvm_plugins = None;
16541656
let mut debug = None;
1655-
let mut debug_assertions = None;
1656-
let mut debug_assertions_std = None;
1657+
let mut rustc_debug_assertions = None;
1658+
let mut std_debug_assertions = None;
16571659
let mut overflow_checks = None;
16581660
let mut overflow_checks_std = None;
16591661
let mut debug_logging = None;
@@ -1675,8 +1677,8 @@ impl Config {
16751677
debug: debug_toml,
16761678
codegen_units,
16771679
codegen_units_std,
1678-
debug_assertions: debug_assertions_toml,
1679-
debug_assertions_std: debug_assertions_std_toml,
1680+
rustc_debug_assertions: rustc_debug_assertions_toml,
1681+
std_debug_assertions: std_debug_assertions_toml,
16801682
overflow_checks: overflow_checks_toml,
16811683
overflow_checks_std: overflow_checks_std_toml,
16821684
debug_logging: debug_logging_toml,
@@ -1734,8 +1736,8 @@ impl Config {
17341736
config.download_ci_rustc_commit(download_rustc, config.llvm_assertions);
17351737

17361738
debug = debug_toml;
1737-
debug_assertions = debug_assertions_toml;
1738-
debug_assertions_std = debug_assertions_std_toml;
1739+
rustc_debug_assertions = rustc_debug_assertions_toml;
1740+
std_debug_assertions = std_debug_assertions_toml;
17391741
overflow_checks = overflow_checks_toml;
17401742
overflow_checks_std = overflow_checks_std_toml;
17411743
debug_logging = debug_logging_toml;
@@ -2148,14 +2150,13 @@ impl Config {
21482150
config.rust_std_features = std_features.unwrap_or(default_std_features);
21492151

21502152
let default = debug == Some(true);
2151-
config.rust_debug_assertions = debug_assertions.unwrap_or(default);
2152-
config.rust_debug_assertions_std =
2153-
debug_assertions_std.unwrap_or(config.rust_debug_assertions);
2153+
config.rustc_debug_assertions = rustc_debug_assertions.unwrap_or(default);
2154+
config.std_debug_assertions = std_debug_assertions.unwrap_or(config.rustc_debug_assertions);
21542155
config.rust_overflow_checks = overflow_checks.unwrap_or(default);
21552156
config.rust_overflow_checks_std =
21562157
overflow_checks_std.unwrap_or(config.rust_overflow_checks);
21572158

2158-
config.rust_debug_logging = debug_logging.unwrap_or(config.rust_debug_assertions);
2159+
config.rust_debug_logging = debug_logging.unwrap_or(config.rustc_debug_assertions);
21592160

21602161
let with_defaults = |debuginfo_level_specific: Option<_>| {
21612162
debuginfo_level_specific.or(debuginfo_level).unwrap_or(if debug == Some(true) {
@@ -3075,8 +3076,8 @@ fn check_incompatible_options_for_ci_rustc(
30753076
debug: _,
30763077
codegen_units: _,
30773078
codegen_units_std: _,
3078-
debug_assertions: _,
3079-
debug_assertions_std: _,
3079+
rustc_debug_assertions: _,
3080+
std_debug_assertions: _,
30803081
overflow_checks: _,
30813082
overflow_checks_std: _,
30823083
debuginfo_level: _,

src/tools/compiletest/src/common.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,11 @@ pub struct Config {
236236
/// Run ignored tests
237237
pub run_ignored: bool,
238238

239-
/// Whether to run tests with `ignore-debug` header
240-
pub with_debug_assertions: bool,
239+
/// Whether rustc was built with debug assertions.
240+
pub with_rustc_debug_assertions: bool,
241+
242+
/// Whether std was built with debug assertions.
243+
pub with_std_debug_assertions: bool,
241244

242245
/// Only run tests that match these filters
243246
pub filters: Vec<String>,

src/tools/compiletest/src/directive-list.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
4646
"ignore-coverage-map",
4747
"ignore-coverage-run",
4848
"ignore-cross-compile",
49-
"ignore-debug",
5049
"ignore-eabi",
5150
"ignore-emscripten",
5251
"ignore-endian-big",
@@ -82,13 +81,15 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
8281
"ignore-powerpc",
8382
"ignore-remote",
8483
"ignore-riscv64",
84+
"ignore-rustc-debug-assertions",
8585
"ignore-s390x",
8686
"ignore-sgx",
8787
"ignore-sparc64",
8888
"ignore-spirv",
8989
"ignore-stable",
9090
"ignore-stage1",
9191
"ignore-stage2",
92+
"ignore-std-debug-assertions",
9293
"ignore-test",
9394
"ignore-thumb",
9495
"ignore-thumbv8m.base-none-eabi",
@@ -135,6 +136,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
135136
"needs-relocation-model-pic",
136137
"needs-run-enabled",
137138
"needs-rust-lld",
139+
"needs-rustc-debug-assertions",
138140
"needs-sanitizer-address",
139141
"needs-sanitizer-cfi",
140142
"needs-sanitizer-dataflow",
@@ -147,6 +149,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
147149
"needs-sanitizer-shadow-call-stack",
148150
"needs-sanitizer-support",
149151
"needs-sanitizer-thread",
152+
"needs-std-debug-assertions",
150153
"needs-symlink",
151154
"needs-threads",
152155
"needs-unwind",

src/tools/compiletest/src/header/cfg.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,14 @@ pub(super) fn parse_cfg_name_directive<'a>(
202202
message: "when running tests remotely",
203203
}
204204
condition! {
205-
name: "debug",
206-
condition: config.with_debug_assertions,
207-
message: "when running tests with `ignore-debug` header",
205+
name: "rustc-debug-assertions",
206+
condition: config.with_rustc_debug_assertions,
207+
message: "when rustc is built with debug assertions",
208+
}
209+
condition! {
210+
name: "std-debug-assertions",
211+
condition: config.with_std_debug_assertions,
212+
message: "when std is built with debug assertions",
208213
}
209214
condition! {
210215
name: config.debugger.as_ref().map(|d| d.to_str()),

src/tools/compiletest/src/header/needs.rs

+10
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,16 @@ pub(super) fn handle_needs(
159159
condition: cache.llvm_zstd,
160160
ignore_reason: "ignored if LLVM wasn't build with zstd for ELF section compression",
161161
},
162+
Need {
163+
name: "needs-rustc-debug-assertions",
164+
condition: config.with_rustc_debug_assertions,
165+
ignore_reason: "ignored if rustc wasn't built with debug assertions",
166+
},
167+
Need {
168+
name: "needs-std-debug-assertions",
169+
condition: config.with_std_debug_assertions,
170+
ignore_reason: "ignored if std wasn't built with debug assertions",
171+
},
162172
];
163173

164174
let (name, comment) = match ln.split_once([':', ' ']) {

src/tools/compiletest/src/header/tests.rs

+44
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ struct ConfigBuilder {
7474
git_hash: bool,
7575
system_llvm: bool,
7676
profiler_runtime: bool,
77+
rustc_debug_assertions: bool,
78+
std_debug_assertions: bool,
7779
}
7880

7981
impl ConfigBuilder {
@@ -122,6 +124,16 @@ impl ConfigBuilder {
122124
self
123125
}
124126

127+
fn rustc_debug_assertions(&mut self, is_enabled: bool) -> &mut Self {
128+
self.rustc_debug_assertions = is_enabled;
129+
self
130+
}
131+
132+
fn std_debug_assertions(&mut self, is_enabled: bool) -> &mut Self {
133+
self.std_debug_assertions = is_enabled;
134+
self
135+
}
136+
125137
fn build(&mut self) -> Config {
126138
let args = &[
127139
"compiletest",
@@ -170,6 +182,12 @@ impl ConfigBuilder {
170182
if self.profiler_runtime {
171183
args.push("--profiler-runtime".to_owned());
172184
}
185+
if self.rustc_debug_assertions {
186+
args.push("--with-rustc-debug-assertions".to_owned());
187+
}
188+
if self.std_debug_assertions {
189+
args.push("--with-std-debug-assertions".to_owned());
190+
}
173191

174192
args.push("--rustc-path".to_string());
175193
// This is a subtle/fragile thing. On rust-lang CI, there is no global
@@ -314,6 +332,32 @@ fn only_target() {
314332
assert!(!check_ignore(&config, "//@ only-64bit"));
315333
}
316334

335+
#[test]
336+
fn rustc_debug_assertions() {
337+
let config: Config = cfg().rustc_debug_assertions(false).build();
338+
339+
assert!(check_ignore(&config, "//@ needs-rustc-debug-assertions"));
340+
assert!(!check_ignore(&config, "//@ ignore-rustc-debug-assertions"));
341+
342+
let config: Config = cfg().rustc_debug_assertions(true).build();
343+
344+
assert!(!check_ignore(&config, "//@ needs-rustc-debug-assertions"));
345+
assert!(check_ignore(&config, "//@ ignore-rustc-debug-assertions"));
346+
}
347+
348+
#[test]
349+
fn std_debug_assertions() {
350+
let config: Config = cfg().std_debug_assertions(false).build();
351+
352+
assert!(check_ignore(&config, "//@ needs-std-debug-assertions"));
353+
assert!(!check_ignore(&config, "//@ ignore-std-debug-assertions"));
354+
355+
let config: Config = cfg().std_debug_assertions(true).build();
356+
357+
assert!(!check_ignore(&config, "//@ needs-std-debug-assertions"));
358+
assert!(check_ignore(&config, "//@ ignore-std-debug-assertions"));
359+
}
360+
317361
#[test]
318362
fn stage() {
319363
let config: Config = cfg().stage_id("stage1-x86_64-unknown-linux-gnu").build();

src/tools/compiletest/src/lib.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
8888
.optopt("", "run", "whether to execute run-* tests", "auto | always | never")
8989
.optflag("", "ignored", "run tests marked as ignored")
9090
.optflag("", "has-enzyme", "run tests that require enzyme")
91-
.optflag("", "with-debug-assertions", "whether to run tests with `ignore-debug` header")
91+
.optflag("", "with-rustc-debug-assertions", "whether rustc was built with debug assertions")
92+
.optflag("", "with-std-debug-assertions", "whether std was built with debug assertions")
9293
.optmulti(
9394
"",
9495
"skip",
@@ -235,7 +236,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
235236

236237
let src_base = opt_path(matches, "src-base");
237238
let run_ignored = matches.opt_present("ignored");
238-
let with_debug_assertions = matches.opt_present("with-debug-assertions");
239+
let with_rustc_debug_assertions = matches.opt_present("with-rustc-debug-assertions");
240+
let with_std_debug_assertions = matches.opt_present("with-std-debug-assertions");
239241
let mode = matches.opt_str("mode").unwrap().parse().expect("invalid mode");
240242
let has_html_tidy = if mode == Mode::Rustdoc {
241243
Command::new("tidy")
@@ -293,7 +295,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
293295
suite: matches.opt_str("suite").unwrap(),
294296
debugger: None,
295297
run_ignored,
296-
with_debug_assertions,
298+
with_rustc_debug_assertions,
299+
with_std_debug_assertions,
297300
filters,
298301
skip: matches.opt_strs("skip"),
299302
filter_exact: matches.opt_present("exact"),

tests/codegen/binary-heap-peek-mut-pop-no-panic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ compile-flags: -O
2-
//@ ignore-debug
2+
//@ ignore-std-debug-assertions
33
#![crate_type = "lib"]
44

55
use std::collections::binary_heap::PeekMut;

tests/codegen/mem-replace-big-type.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
// known to be `1` after inlining).
55

66
//@ compile-flags: -C no-prepopulate-passes -Zinline-mir=no
7-
//@ ignore-debug: precondition checks in ptr::read make them a bad candidate for MIR inlining
7+
//@ ignore-std-debug-assertions
8+
// Reason: precondition checks in ptr::read make them a bad candidate for MIR inlining
89
//@ needs-deterministic-layouts
910

1011
#![crate_type = "lib"]

tests/codegen/mem-replace-simple-type.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ compile-flags: -O -C no-prepopulate-passes
22
//@ only-x86_64 (to not worry about usize differing)
3-
//@ ignore-debug: precondition checks make mem::replace not a candidate for MIR inlining
3+
//@ ignore-std-debug-assertions
4+
// Reason: precondition checks make mem::replace not a candidate for MIR inlining
45

56
#![crate_type = "lib"]
67

tests/codegen/slice-reverse.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ compile-flags: -O
22
//@ only-x86_64
3-
//@ ignore-debug: debug assertions prevent generating shufflevector
3+
//@ ignore-std-debug-assertions (debug assertions prevent generating shufflevector)
44

55
#![crate_type = "lib"]
66

tests/codegen/vec-in-place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ ignore-debug: FIXME: checks for call detect scoped noalias metadata
1+
//@ ignore-std-debug-assertions (FIXME: checks for call detect scoped noalias metadata)
22
//@ compile-flags: -O -Z merge-functions=disabled
33
#![crate_type = "lib"]
44

tests/codegen/vec-shrink-panik.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// LLVM 17 realizes double panic is not possible and doesn't generate calls
22
// to panic_cannot_unwind.
33
//@ compile-flags: -O
4-
//@ ignore-debug: plain old debug assertions
4+
//@ ignore-std-debug-assertions (plain old debug assertions)
55
//@ needs-unwind
66
#![crate_type = "lib"]
77
#![feature(shrink_to)]

tests/codegen/vec-with-capacity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ compile-flags: -O
2-
//@ ignore-debug
2+
//@ ignore-std-debug-assertions
33
// (with debug assertions turned on, `assert_unchecked` generates a real assertion)
44

55
#![crate_type = "lib"]

tests/codegen/vecdeque-drain.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
//@ compile-flags: -O
44
//@ needs-deterministic-layouts
5-
//@ ignore-debug: FIXME: checks for call detect scoped noalias metadata
5+
//@ ignore-std-debug-assertions (FIXME: checks for call detect scoped noalias metadata)
66

77
#![crate_type = "lib"]
88

tests/codegen/vecdeque_no_panic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This test checks that `VecDeque::front[_mut]()` and `VecDeque::back[_mut]()` can't panic.
22

33
//@ compile-flags: -O
4-
//@ ignore-debug: plain old debug assertions
4+
//@ ignore-std-debug-assertions (plain old debug assertions)
55

66
#![crate_type = "lib"]
77

tests/mir-opt/pre-codegen/mem_replace.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// skip-filecheck
22
//@ compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 -Zinline-mir
3-
//@ ignore-debug: precondition checks on ptr::read/write are under cfg(debug_assertions)
3+
//@ ignore-std-debug-assertions
4+
// Reason: precondition checks on ptr::read/write are under cfg(debug_assertions)
45
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
56

67
#![crate_type = "lib"]

tests/mir-opt/pre-codegen/ptr_offset.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// skip-filecheck
22
//@ compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2 -Zinline-mir
3-
//@ ignore-debug: precondition checks are under cfg(debug_assertions)
3+
//@ ignore-std-debug-assertions (precondition checks are under cfg(debug_assertions))
44
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
55

66
#![crate_type = "lib"]

0 commit comments

Comments
 (0)