Skip to content

Commit 24040e7

Browse files
committed
Add {ignore,needs}-{rustc,std}-debug-assertions directive support
And retire the old `only-debug` directive which was ambiguous and only for std debug assertions.
1 parent bfab34a commit 24040e7

File tree

8 files changed

+57
-30
lines changed

8 files changed

+57
-30
lines changed

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

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

19291929
cmd.arg("--json");
19301930

1931-
if builder.config.rust_debug_assertions_std {
1932-
cmd.arg("--with-debug-assertions");
1933-
};
1931+
if builder.config.rustc_debug_assertions {
1932+
cmd.arg("--with-rustc-debug-assertions");
1933+
}
1934+
1935+
if builder.config.std_debug_assertions {
1936+
cmd.arg("--with-std-debug-assertions");
1937+
}
19341938

19351939
let mut llvm_components_passed = false;
19361940
let mut copts_passed = false;

src/bootstrap/src/core/builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1888,9 +1888,9 @@ impl<'a> Builder<'a> {
18881888
cargo.env(
18891889
profile_var("DEBUG_ASSERTIONS"),
18901890
if mode == Mode::Std {
1891-
self.config.rust_debug_assertions_std.to_string()
1891+
self.config.std_debug_assertions.to_string()
18921892
} else {
1893-
self.config.rust_debug_assertions.to_string()
1893+
self.config.rustc_debug_assertions.to_string()
18941894
},
18951895
);
18961896
cargo.env(

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

+15-16
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ pub struct Config {
262262
pub rust_optimize: RustOptimize,
263263
pub rust_codegen_units: Option<u32>,
264264
pub rust_codegen_units_std: Option<u32>,
265-
pub rust_debug_assertions: bool,
266-
pub rust_debug_assertions_std: bool,
265+
pub rustc_debug_assertions: bool,
266+
pub std_debug_assertions: bool,
267267
pub rust_overflow_checks: bool,
268268
pub rust_overflow_checks_std: bool,
269269
pub rust_debug_logging: bool,
@@ -1109,9 +1109,9 @@ define_config! {
11091109
debug: Option<bool> = "debug",
11101110
codegen_units: Option<u32> = "codegen-units",
11111111
codegen_units_std: Option<u32> = "codegen-units-std",
1112-
debug_assertions: Option<bool> = "debug-assertions",
1112+
rustc_debug_assertions: Option<bool> = "debug-assertions",
11131113
randomize_layout: Option<bool> = "randomize-layout",
1114-
debug_assertions_std: Option<bool> = "debug-assertions-std",
1114+
std_debug_assertions: Option<bool> = "debug-assertions-std",
11151115
overflow_checks: Option<bool> = "overflow-checks",
11161116
overflow_checks_std: Option<bool> = "overflow-checks-std",
11171117
debug_logging: Option<bool> = "debug-logging",
@@ -1644,8 +1644,8 @@ impl Config {
16441644
let mut llvm_enzyme = None;
16451645
let mut llvm_plugins = None;
16461646
let mut debug = None;
1647-
let mut debug_assertions = None;
1648-
let mut debug_assertions_std = None;
1647+
let mut rustc_debug_assertions = None;
1648+
let mut std_debug_assertions = None;
16491649
let mut overflow_checks = None;
16501650
let mut overflow_checks_std = None;
16511651
let mut debug_logging = None;
@@ -1667,8 +1667,8 @@ impl Config {
16671667
debug: debug_toml,
16681668
codegen_units,
16691669
codegen_units_std,
1670-
debug_assertions: debug_assertions_toml,
1671-
debug_assertions_std: debug_assertions_std_toml,
1670+
rustc_debug_assertions: rustc_debug_assertions_toml,
1671+
std_debug_assertions: std_debug_assertions_toml,
16721672
overflow_checks: overflow_checks_toml,
16731673
overflow_checks_std: overflow_checks_std_toml,
16741674
debug_logging: debug_logging_toml,
@@ -1726,8 +1726,8 @@ impl Config {
17261726
config.download_ci_rustc_commit(download_rustc, config.llvm_assertions);
17271727

17281728
debug = debug_toml;
1729-
debug_assertions = debug_assertions_toml;
1730-
debug_assertions_std = debug_assertions_std_toml;
1729+
rustc_debug_assertions = rustc_debug_assertions_toml;
1730+
std_debug_assertions = std_debug_assertions_toml;
17311731
overflow_checks = overflow_checks_toml;
17321732
overflow_checks_std = overflow_checks_std_toml;
17331733
debug_logging = debug_logging_toml;
@@ -2136,14 +2136,13 @@ impl Config {
21362136
config.rust_std_features = std_features.unwrap_or(default_std_features);
21372137

21382138
let default = debug == Some(true);
2139-
config.rust_debug_assertions = debug_assertions.unwrap_or(default);
2140-
config.rust_debug_assertions_std =
2141-
debug_assertions_std.unwrap_or(config.rust_debug_assertions);
2139+
config.rustc_debug_assertions = rustc_debug_assertions.unwrap_or(default);
2140+
config.std_debug_assertions = std_debug_assertions.unwrap_or(config.rustc_debug_assertions);
21422141
config.rust_overflow_checks = overflow_checks.unwrap_or(default);
21432142
config.rust_overflow_checks_std =
21442143
overflow_checks_std.unwrap_or(config.rust_overflow_checks);
21452144

2146-
config.rust_debug_logging = debug_logging.unwrap_or(config.rust_debug_assertions);
2145+
config.rust_debug_logging = debug_logging.unwrap_or(config.rustc_debug_assertions);
21472146

21482147
let with_defaults = |debuginfo_level_specific: Option<_>| {
21492148
debuginfo_level_specific.or(debuginfo_level).unwrap_or(if debug == Some(true) {
@@ -3084,8 +3083,8 @@ fn check_incompatible_options_for_ci_rustc(
30843083
debug: _,
30853084
codegen_units: _,
30863085
codegen_units_std: _,
3087-
debug_assertions: _,
3088-
debug_assertions_std: _,
3086+
rustc_debug_assertions: _,
3087+
std_debug_assertions: _,
30893088
overflow_checks: _,
30903089
overflow_checks_std: _,
30913090
debuginfo_level: _,

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
4545
"ignore-coverage-map",
4646
"ignore-coverage-run",
4747
"ignore-cross-compile",
48-
"ignore-debug",
4948
"ignore-eabi",
5049
"ignore-emscripten",
5150
"ignore-endian-big",
@@ -81,13 +80,15 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
8180
"ignore-powerpc",
8281
"ignore-remote",
8382
"ignore-riscv64",
83+
"ignore-rustc-debug-assertions",
8484
"ignore-s390x",
8585
"ignore-sgx",
8686
"ignore-sparc64",
8787
"ignore-spirv",
8888
"ignore-stable",
8989
"ignore-stage1",
9090
"ignore-stage2",
91+
"ignore-std-debug-assertions",
9192
"ignore-test",
9293
"ignore-thumb",
9394
"ignore-thumbv8m.base-none-eabi",
@@ -122,6 +123,8 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
122123
"min-llvm-version",
123124
"min-system-llvm-version",
124125
"needs-asm-support",
126+
"needs-debug-assertions-rustc",
127+
"needs-debug-assertions-std",
125128
"needs-deterministic-layouts",
126129
"needs-dlltool",
127130
"needs-dynamic-linking",

src/tools/compiletest/src/common.rs

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

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

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

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-debug-assertions-rustc",
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-debug-assertions-std",
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/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",
@@ -228,7 +229,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
228229

229230
let src_base = opt_path(matches, "src-base");
230231
let run_ignored = matches.opt_present("ignored");
231-
let with_debug_assertions = matches.opt_present("with-debug-assertions");
232+
let with_rustc_debug_assertions = matches.opt_present("with-rustc-debug-assertions");
233+
let with_std_debug_assertions = matches.opt_present("with-std-debug-assertions");
232234
let mode = matches.opt_str("mode").unwrap().parse().expect("invalid mode");
233235
let has_tidy = if mode == Mode::Rustdoc {
234236
Command::new("tidy")
@@ -286,7 +288,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
286288
suite: matches.opt_str("suite").unwrap(),
287289
debugger: None,
288290
run_ignored,
289-
with_debug_assertions,
291+
with_rustc_debug_assertions,
292+
with_std_debug_assertions,
290293
filters,
291294
skip: matches.opt_strs("skip"),
292295
filter_exact: matches.opt_present("exact"),

0 commit comments

Comments
 (0)