Skip to content

Commit 1b8ee46

Browse files
committed
Add needs-std-remap-debuginfo directive to compiletest & run-make
1 parent a6525d5 commit 1b8ee46

File tree

11 files changed

+64
-0
lines changed

11 files changed

+64
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,6 +2257,10 @@ Please disable assertions with `rust.debug-assertions = false`.
22572257
cmd.arg("--with-std-debug-assertions");
22582258
}
22592259

2260+
if builder.config.rust_remap_debuginfo {
2261+
cmd.arg("--with-std-remap-debuginfo");
2262+
}
2263+
22602264
let mut llvm_components_passed = false;
22612265
let mut copts_passed = false;
22622266
if builder.config.llvm_enabled(test_compiler.host) {

src/doc/rustc-dev-guide/src/tests/directives.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ settings:
189189
assertions.
190190
- `needs-std-debug-assertions` — ignores if std was not built with debug
191191
assertions.
192+
- `ignore-std-remap-debuginfo` — ignores if std was built with remapping of
193+
it's sources.
194+
- `needs-std-remap-debugino` — ignores if std was not built with remapping of
195+
it's sources.
192196
- `ignore-rustc-debug-assertions` — ignores if rustc was built with debug
193197
assertions.
194198
- `needs-rustc-debug-assertions` — ignores if rustc was not built with debug

src/tools/compiletest/src/common.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,11 @@ pub struct Config {
438438
/// FIXME: make it clearer that this refers to the staged `std`, not stage 0 `std`.
439439
pub with_std_debug_assertions: bool,
440440

441+
/// Whether *staged* `std` was built with remapping of debuginfo.
442+
///
443+
/// FIXME: make it clearer that this refers to the staged `std`, not stage 0 `std`.
444+
pub with_std_remap_debuginfo: bool,
445+
441446
/// Only run tests that match these filters (using `libtest` "test name contains" filter logic).
442447
///
443448
/// FIXME(#139660): the current hand-rolled test executor intentionally mimics the `libtest`

src/tools/compiletest/src/directives/cfg.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ pub(crate) fn prepare_conditions(config: &Config) -> PreparedConditions {
202202
config.with_std_debug_assertions,
203203
"when std is built with debug assertions",
204204
);
205+
builder.cond(
206+
"std-remap-debuginfo",
207+
config.with_std_remap_debuginfo,
208+
"when std is built with remapping of debuginfo",
209+
);
205210

206211
for &debugger in Debugger::STR_VARIANTS {
207212
builder.cond(

src/tools/compiletest/src/directives/directive_names.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
184184
"needs-sanitizer-support",
185185
"needs-sanitizer-thread",
186186
"needs-std-debug-assertions",
187+
"needs-std-remap-debuginfo",
187188
"needs-subprocess",
188189
"needs-symlink",
189190
"needs-target-has-atomic",

src/tools/compiletest/src/directives/needs.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ pub(super) fn handle_needs(
181181
condition: config.with_std_debug_assertions,
182182
ignore_reason: "ignored if std wasn't built with debug assertions",
183183
},
184+
Need {
185+
name: "needs-std-remap-debuginfo",
186+
condition: config.with_std_remap_debuginfo,
187+
ignore_reason: "ignored if std wasn't built with remapping of debuginfo",
188+
},
184189
Need {
185190
name: "needs-target-std",
186191
condition: build_helper::targets::target_supports_std(&config.target),

src/tools/compiletest/src/directives/tests.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ struct ConfigBuilder {
117117
profiler_runtime: bool,
118118
rustc_debug_assertions: bool,
119119
std_debug_assertions: bool,
120+
std_remap_debuginfo: bool,
120121
}
121122

122123
impl ConfigBuilder {
@@ -185,6 +186,11 @@ impl ConfigBuilder {
185186
self
186187
}
187188

189+
fn std_remap_debuginfo(&mut self, is_enabled: bool) -> &mut Self {
190+
self.std_remap_debuginfo = is_enabled;
191+
self
192+
}
193+
188194
fn build(&mut self) -> Config {
189195
let args = &[
190196
"compiletest",
@@ -246,6 +252,9 @@ impl ConfigBuilder {
246252
if self.std_debug_assertions {
247253
args.push("--with-std-debug-assertions".to_owned());
248254
}
255+
if self.std_remap_debuginfo {
256+
args.push("--with-std-remap-debuginfo".to_owned());
257+
}
249258

250259
args.push("--rustc-path".to_string());
251260
args.push(std::env::var("TEST_RUSTC").expect("must be configured by bootstrap"));
@@ -400,6 +409,19 @@ fn std_debug_assertions() {
400409
assert!(check_ignore(&config, "//@ ignore-std-debug-assertions"));
401410
}
402411

412+
#[test]
413+
fn std_remap_debuginfo() {
414+
let config: Config = cfg().std_remap_debuginfo(false).build();
415+
416+
assert!(check_ignore(&config, "//@ needs-std-remap-debuginfo"));
417+
assert!(!check_ignore(&config, "//@ ignore-std-remap-debuginfo"));
418+
419+
let config: Config = cfg().std_remap_debuginfo(true).build();
420+
421+
assert!(!check_ignore(&config, "//@ needs-std-remap-debuginfo"));
422+
assert!(check_ignore(&config, "//@ ignore-std-remap-debuginfo"));
423+
}
424+
403425
#[test]
404426
fn stage() {
405427
let config: Config = cfg().stage(1).stage_id("stage1-x86_64-unknown-linux-gnu").build();

src/tools/compiletest/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ fn parse_config(args: Vec<String>) -> Config {
106106
.optflag("", "has-enzyme", "run tests that require enzyme")
107107
.optflag("", "with-rustc-debug-assertions", "whether rustc was built with debug assertions")
108108
.optflag("", "with-std-debug-assertions", "whether std was built with debug assertions")
109+
.optflag("", "with-std-remap-debuginfo", "whether std was built with remapping")
109110
.optmulti(
110111
"",
111112
"skip",
@@ -295,6 +296,7 @@ fn parse_config(args: Vec<String>) -> Config {
295296
let run_ignored = matches.opt_present("ignored");
296297
let with_rustc_debug_assertions = matches.opt_present("with-rustc-debug-assertions");
297298
let with_std_debug_assertions = matches.opt_present("with-std-debug-assertions");
299+
let with_std_remap_debuginfo = matches.opt_present("with-std-remap-debuginfo");
298300
let mode = matches.opt_str("mode").unwrap().parse().expect("invalid mode");
299301
let has_enzyme = matches.opt_present("has-enzyme");
300302
let filters = if mode == TestMode::RunMake {
@@ -402,6 +404,7 @@ fn parse_config(args: Vec<String>) -> Config {
402404
run_ignored,
403405
with_rustc_debug_assertions,
404406
with_std_debug_assertions,
407+
with_std_remap_debuginfo,
405408
filters,
406409
skip: matches.opt_strs("skip"),
407410
filter_exact: matches.opt_present("exact"),

src/tools/compiletest/src/runtest/run_make.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,12 @@ impl TestCx<'_> {
243243
cmd.env("__STD_DEBUG_ASSERTIONS_ENABLED", "1");
244244
}
245245

246+
cmd.env_remove("__STD_REMAP_DEBUGINFO_ENABLED");
247+
if self.config.with_std_remap_debuginfo {
248+
// Used for `run_make_support::env::std_remap_debuginfo_enabled`.
249+
cmd.env("__STD_REMAP_DEBUGINFO_ENABLED", "1");
250+
}
251+
246252
// We don't want RUSTFLAGS set from the outside to interfere with
247253
// compiler flags set in the test cases:
248254
cmd.env_remove("RUSTFLAGS");

src/tools/compiletest/src/rustdoc_gui_test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ fn incomplete_config_for_rustdoc_gui_test() -> Config {
8383
run_ignored: Default::default(),
8484
with_rustc_debug_assertions: Default::default(),
8585
with_std_debug_assertions: Default::default(),
86+
with_std_remap_debuginfo: Default::default(),
8687
filters: Default::default(),
8788
skip: Default::default(),
8889
filter_exact: Default::default(),

0 commit comments

Comments
 (0)