Add needs-std-remap-debuginfo directive to compiletest & run-make

This commit is contained in:
Urgau 2025-12-22 17:41:53 +01:00
parent a6525d5264
commit 1b8ee46683
11 changed files with 64 additions and 0 deletions

View file

@ -2257,6 +2257,10 @@ Please disable assertions with `rust.debug-assertions = false`.
cmd.arg("--with-std-debug-assertions");
}
if builder.config.rust_remap_debuginfo {
cmd.arg("--with-std-remap-debuginfo");
}
let mut llvm_components_passed = false;
let mut copts_passed = false;
if builder.config.llvm_enabled(test_compiler.host) {

View file

@ -189,6 +189,10 @@ settings:
assertions.
- `needs-std-debug-assertions` — ignores if std was not built with debug
assertions.
- `ignore-std-remap-debuginfo` — ignores if std was built with remapping of
it's sources.
- `needs-std-remap-debugino` — ignores if std was not built with remapping of
it's sources.
- `ignore-rustc-debug-assertions` — ignores if rustc was built with debug
assertions.
- `needs-rustc-debug-assertions` — ignores if rustc was not built with debug

View file

@ -438,6 +438,11 @@ pub struct Config {
/// FIXME: make it clearer that this refers to the staged `std`, not stage 0 `std`.
pub with_std_debug_assertions: bool,
/// Whether *staged* `std` was built with remapping of debuginfo.
///
/// FIXME: make it clearer that this refers to the staged `std`, not stage 0 `std`.
pub with_std_remap_debuginfo: bool,
/// Only run tests that match these filters (using `libtest` "test name contains" filter logic).
///
/// FIXME(#139660): the current hand-rolled test executor intentionally mimics the `libtest`

View file

@ -202,6 +202,11 @@ pub(crate) fn prepare_conditions(config: &Config) -> PreparedConditions {
config.with_std_debug_assertions,
"when std is built with debug assertions",
);
builder.cond(
"std-remap-debuginfo",
config.with_std_remap_debuginfo,
"when std is built with remapping of debuginfo",
);
for &debugger in Debugger::STR_VARIANTS {
builder.cond(

View file

@ -184,6 +184,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"needs-sanitizer-support",
"needs-sanitizer-thread",
"needs-std-debug-assertions",
"needs-std-remap-debuginfo",
"needs-subprocess",
"needs-symlink",
"needs-target-has-atomic",

View file

@ -181,6 +181,11 @@ pub(super) fn handle_needs(
condition: config.with_std_debug_assertions,
ignore_reason: "ignored if std wasn't built with debug assertions",
},
Need {
name: "needs-std-remap-debuginfo",
condition: config.with_std_remap_debuginfo,
ignore_reason: "ignored if std wasn't built with remapping of debuginfo",
},
Need {
name: "needs-target-std",
condition: build_helper::targets::target_supports_std(&config.target),

View file

@ -117,6 +117,7 @@ struct ConfigBuilder {
profiler_runtime: bool,
rustc_debug_assertions: bool,
std_debug_assertions: bool,
std_remap_debuginfo: bool,
}
impl ConfigBuilder {
@ -185,6 +186,11 @@ impl ConfigBuilder {
self
}
fn std_remap_debuginfo(&mut self, is_enabled: bool) -> &mut Self {
self.std_remap_debuginfo = is_enabled;
self
}
fn build(&mut self) -> Config {
let args = &[
"compiletest",
@ -246,6 +252,9 @@ impl ConfigBuilder {
if self.std_debug_assertions {
args.push("--with-std-debug-assertions".to_owned());
}
if self.std_remap_debuginfo {
args.push("--with-std-remap-debuginfo".to_owned());
}
args.push("--rustc-path".to_string());
args.push(std::env::var("TEST_RUSTC").expect("must be configured by bootstrap"));
@ -400,6 +409,19 @@ fn std_debug_assertions() {
assert!(check_ignore(&config, "//@ ignore-std-debug-assertions"));
}
#[test]
fn std_remap_debuginfo() {
let config: Config = cfg().std_remap_debuginfo(false).build();
assert!(check_ignore(&config, "//@ needs-std-remap-debuginfo"));
assert!(!check_ignore(&config, "//@ ignore-std-remap-debuginfo"));
let config: Config = cfg().std_remap_debuginfo(true).build();
assert!(!check_ignore(&config, "//@ needs-std-remap-debuginfo"));
assert!(check_ignore(&config, "//@ ignore-std-remap-debuginfo"));
}
#[test]
fn stage() {
let config: Config = cfg().stage(1).stage_id("stage1-x86_64-unknown-linux-gnu").build();

View file

@ -106,6 +106,7 @@ fn parse_config(args: Vec<String>) -> Config {
.optflag("", "has-enzyme", "run tests that require enzyme")
.optflag("", "with-rustc-debug-assertions", "whether rustc was built with debug assertions")
.optflag("", "with-std-debug-assertions", "whether std was built with debug assertions")
.optflag("", "with-std-remap-debuginfo", "whether std was built with remapping")
.optmulti(
"",
"skip",
@ -295,6 +296,7 @@ fn parse_config(args: Vec<String>) -> Config {
let run_ignored = matches.opt_present("ignored");
let with_rustc_debug_assertions = matches.opt_present("with-rustc-debug-assertions");
let with_std_debug_assertions = matches.opt_present("with-std-debug-assertions");
let with_std_remap_debuginfo = matches.opt_present("with-std-remap-debuginfo");
let mode = matches.opt_str("mode").unwrap().parse().expect("invalid mode");
let has_enzyme = matches.opt_present("has-enzyme");
let filters = if mode == TestMode::RunMake {
@ -402,6 +404,7 @@ fn parse_config(args: Vec<String>) -> Config {
run_ignored,
with_rustc_debug_assertions,
with_std_debug_assertions,
with_std_remap_debuginfo,
filters,
skip: matches.opt_strs("skip"),
filter_exact: matches.opt_present("exact"),

View file

@ -243,6 +243,12 @@ impl TestCx<'_> {
cmd.env("__STD_DEBUG_ASSERTIONS_ENABLED", "1");
}
cmd.env_remove("__STD_REMAP_DEBUGINFO_ENABLED");
if self.config.with_std_remap_debuginfo {
// Used for `run_make_support::env::std_remap_debuginfo_enabled`.
cmd.env("__STD_REMAP_DEBUGINFO_ENABLED", "1");
}
// We don't want RUSTFLAGS set from the outside to interfere with
// compiler flags set in the test cases:
cmd.env_remove("RUSTFLAGS");

View file

@ -83,6 +83,7 @@ fn incomplete_config_for_rustdoc_gui_test() -> Config {
run_ignored: Default::default(),
with_rustc_debug_assertions: Default::default(),
with_std_debug_assertions: Default::default(),
with_std_remap_debuginfo: Default::default(),
filters: Default::default(),
skip: Default::default(),
filter_exact: Default::default(),

View file

@ -34,6 +34,14 @@ pub fn std_debug_assertions_enabled() -> bool {
std::env::var_os("__STD_DEBUG_ASSERTIONS_ENABLED").is_some()
}
/// Check if staged `std`-under-test was built with remapping of it's sources.
#[track_caller]
#[must_use]
pub fn std_remap_debuginfo_enabled() -> bool {
// Note: we assume this env var is set when the test recipe is being executed.
std::env::var_os("__STD_REMAP_DEBUGINFO_ENABLED").is_some()
}
/// A wrapper around [`std::env::set_current_dir`] which includes the directory
/// path in the panic message.
#[track_caller]