Rollup merge of #148194 - Zalathar:no-cleanup, r=jieyouxu

compiletest: Remove `cleanup_debug_info_options`

This "cleanup" function is more than a decade old, and I can't find any evidence of modern-day bootstrap being able to pass any of these flags to `--host-rustcflags` or `--target-rustcflags`.

I thought about replacing the cleanup with an assertion, but I think it's better to delete it entirely for now, and re-add checks later if they're motivated by actual problems in practice.

In addition to deleting some old and confusing code, this also lets us remove three instances of duplicating `TestCx`, which is the biggest win.

r? jieyouxu
This commit is contained in:
Matthias Krüger 2025-11-02 09:10:36 +01:00 committed by GitHub
commit 79206268d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,7 +8,6 @@ use tracing::debug;
use super::debugger::DebuggerCommands;
use super::{Debugger, Emit, ProcRes, TestCx, Truncated, WillExecute};
use crate::common::Config;
use crate::debuggers::{extract_gdb_version, is_android_gdb_target};
impl TestCx<'_> {
@ -21,18 +20,6 @@ impl TestCx<'_> {
}
fn run_debuginfo_cdb_test(&self) {
let config = Config {
target_rustcflags: self.cleanup_debug_info_options(&self.config.target_rustcflags),
host_rustcflags: self.cleanup_debug_info_options(&self.config.host_rustcflags),
..self.config.clone()
};
let test_cx = TestCx { config: &config, ..*self };
test_cx.run_debuginfo_cdb_test_no_opt();
}
fn run_debuginfo_cdb_test_no_opt(&self) {
let exe_file = self.make_exe_name();
// Existing PDB files are update in-place. When changing the debuginfo
@ -118,18 +105,6 @@ impl TestCx<'_> {
}
fn run_debuginfo_gdb_test(&self) {
let config = Config {
target_rustcflags: self.cleanup_debug_info_options(&self.config.target_rustcflags),
host_rustcflags: self.cleanup_debug_info_options(&self.config.host_rustcflags),
..self.config.clone()
};
let test_cx = TestCx { config: &config, ..*self };
test_cx.run_debuginfo_gdb_test_no_opt();
}
fn run_debuginfo_gdb_test_no_opt(&self) {
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, "gdb")
.unwrap_or_else(|e| self.fatal(&e));
let mut cmds = dbg_cmds.commands.join("\n");
@ -355,18 +330,6 @@ impl TestCx<'_> {
self.fatal("Can't run LLDB test because LLDB's python path is not set.");
}
let config = Config {
target_rustcflags: self.cleanup_debug_info_options(&self.config.target_rustcflags),
host_rustcflags: self.cleanup_debug_info_options(&self.config.host_rustcflags),
..self.config.clone()
};
let test_cx = TestCx { config: &config, ..*self };
test_cx.run_debuginfo_lldb_test_no_opt();
}
fn run_debuginfo_lldb_test_no_opt(&self) {
// compile test file (it should have 'compile-flags:-g' in the directive)
let should_run = self.run_if_enabled();
let compile_result = self.compile_test(should_run, Emit::None);
@ -501,11 +464,4 @@ impl TestCx<'_> {
.env("PYTHONPATH", pythonpath),
)
}
fn cleanup_debug_info_options(&self, options: &Vec<String>) -> Vec<String> {
// Remove options that are either unwanted (-O) or may lead to duplicates due to RUSTFLAGS.
let options_to_remove = ["-O".to_owned(), "-g".to_owned(), "--debuginfo".to_owned()];
options.iter().filter(|x| !options_to_remove.contains(x)).cloned().collect()
}
}