From e2523c18427db0a6b28b7dc8c12a5a65011bef49 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sat, 17 Aug 2024 18:09:27 -0400 Subject: [PATCH] Clean up compiletest --- src/tools/compiletest/src/command-list.rs | 1 - src/tools/compiletest/src/common.rs | 6 ---- src/tools/compiletest/src/header/needs.rs | 7 +---- src/tools/compiletest/src/lib.rs | 36 +++++++---------------- src/tools/compiletest/src/runtest.rs | 20 ++----------- src/tools/compiletest/src/tests.rs | 8 ++--- 6 files changed, 19 insertions(+), 59 deletions(-) diff --git a/src/tools/compiletest/src/command-list.rs b/src/tools/compiletest/src/command-list.rs index 50c909793f5e1..e4e6ddcd22cbc 100644 --- a/src/tools/compiletest/src/command-list.rs +++ b/src/tools/compiletest/src/command-list.rs @@ -142,7 +142,6 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ "needs-relocation-model-pic", "needs-run-enabled", "needs-rust-lld", - "needs-rust-lldb", "needs-sanitizer-address", "needs-sanitizer-cfi", "needs-sanitizer-dataflow", diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 70ebefe3f417f..5831f7c3cf283 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -296,15 +296,9 @@ pub struct Config { /// Version of GDB, encoded as ((major * 1000) + minor) * 1000 + patch pub gdb_version: Option, - /// Whether GDB has native rust support - pub gdb_native_rust: bool, - /// Version of LLDB pub lldb_version: Option, - /// Whether LLDB has native rust support - pub lldb_native_rust: bool, - /// Version of LLVM pub llvm_version: Option, diff --git a/src/tools/compiletest/src/header/needs.rs b/src/tools/compiletest/src/header/needs.rs index 5b2665f7d0ba7..8f935d5b74441 100644 --- a/src/tools/compiletest/src/header/needs.rs +++ b/src/tools/compiletest/src/header/needs.rs @@ -1,4 +1,4 @@ -use crate::common::{Config, Debugger, Sanitizer}; +use crate::common::{Config, Sanitizer}; use crate::header::IgnoreDecision; pub(super) fn handle_needs( @@ -114,11 +114,6 @@ pub(super) fn handle_needs( condition: cache.rust_lld, ignore_reason: "ignored on targets without Rust's LLD", }, - Need { - name: "needs-rust-lldb", - condition: config.debugger != Some(Debugger::Lldb) || config.lldb_native_rust, - ignore_reason: "ignored on targets without Rust's LLDB", - }, Need { name: "needs-dlltool", condition: cache.dlltool, diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index 6acf46f919624..7018362af5410 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -194,14 +194,8 @@ pub fn parse_config(args: Vec) -> Config { let target = opt_str2(matches.opt_str("target")); let android_cross_path = opt_path(matches, "android-cross-path"); let (cdb, cdb_version) = analyze_cdb(matches.opt_str("cdb"), &target); - let (gdb, gdb_version, gdb_native_rust) = - analyze_gdb(matches.opt_str("gdb"), &target, &android_cross_path); - let (lldb_version, lldb_native_rust) = matches - .opt_str("lldb-version") - .as_deref() - .and_then(extract_lldb_version) - .map(|(v, b)| (Some(v), b)) - .unwrap_or((None, false)); + let (gdb, gdb_version) = analyze_gdb(matches.opt_str("gdb"), &target, &android_cross_path); + let lldb_version = matches.opt_str("lldb-version").as_deref().and_then(extract_lldb_version); let color = match matches.opt_str("color").as_deref() { Some("auto") | None => ColorConfig::AutoColor, Some("always") => ColorConfig::AlwaysColor, @@ -298,9 +292,7 @@ pub fn parse_config(args: Vec) -> Config { cdb_version, gdb, gdb_version, - gdb_native_rust, lldb_version, - lldb_native_rust, llvm_version, system_llvm: matches.opt_present("system-llvm"), android_cross_path, @@ -1035,19 +1027,17 @@ fn extract_cdb_version(full_version_line: &str) -> Option<[u16; 4]> { Some([major, minor, patch, build]) } -/// Returns (Path to GDB, GDB Version, GDB has Rust Support) +/// Returns (Path to GDB, GDB Version) fn analyze_gdb( gdb: Option, target: &str, android_cross_path: &PathBuf, -) -> (Option, Option, bool) { +) -> (Option, Option) { #[cfg(not(windows))] const GDB_FALLBACK: &str = "gdb"; #[cfg(windows)] const GDB_FALLBACK: &str = "gdb.exe"; - const MIN_GDB_WITH_RUST: u32 = 7011010; - let fallback_gdb = || { if is_android_gdb_target(target) { let mut gdb_path = match android_cross_path.to_str() { @@ -1076,12 +1066,10 @@ fn analyze_gdb( let version = match version_line { Some(line) => extract_gdb_version(&line), - None => return (None, None, false), + None => return (None, None), }; - let gdb_native_rust = version.map_or(false, |v| v >= MIN_GDB_WITH_RUST); - - (Some(gdb), version, gdb_native_rust) + (Some(gdb), version) } fn extract_gdb_version(full_version_line: &str) -> Option { @@ -1131,8 +1119,8 @@ fn extract_gdb_version(full_version_line: &str) -> Option { Some(((major * 1000) + minor) * 1000 + patch) } -/// Returns (LLDB version, LLDB is rust-enabled) -fn extract_lldb_version(full_version_line: &str) -> Option<(u32, bool)> { +/// Returns LLDB version +fn extract_lldb_version(full_version_line: &str) -> Option { // Extract the major LLDB version from the given version string. // LLDB version strings are different for Apple and non-Apple platforms. // The Apple variant looks like this: @@ -1149,9 +1137,7 @@ fn extract_lldb_version(full_version_line: &str) -> Option<(u32, bool)> { // There doesn't seem to be a way to correlate the Apple version // with the upstream version, and since the tests were originally // written against Apple versions, we make a fake Apple version by - // multiplying the first number by 100. This is a hack, but - // normally fine because the only non-Apple version we test is - // rust-enabled. + // multiplying the first number by 100. This is a hack. let full_version_line = full_version_line.trim(); @@ -1160,12 +1146,12 @@ fn extract_lldb_version(full_version_line: &str) -> Option<(u32, bool)> { { if let Some(idx) = apple_ver.find(not_a_digit) { let version: u32 = apple_ver[..idx].parse().unwrap(); - return Some((version, full_version_line.contains("rust-enabled"))); + return Some(version); } } else if let Some(lldb_ver) = full_version_line.strip_prefix("lldb version ") { if let Some(idx) = lldb_ver.find(not_a_digit) { let version: u32 = lldb_ver[..idx].parse().ok()?; - return Some((version * 100, full_version_line.contains("rust-enabled"))); + return Some(version * 100); } } None diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 394f24e6f359b..eca21e559896a 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -856,12 +856,10 @@ impl<'test> TestCx<'test> { } fn run_debuginfo_gdb_test_no_opt(&self) { - let prefixes = &["gdb"]; - let dbg_cmds = DebuggerCommands::parse_from( &self.testpaths.file, self.config, - prefixes, + &["gdb"], self.revision, ) .unwrap_or_else(|e| self.fatal(&e)); @@ -1043,9 +1041,7 @@ impl<'test> TestCx<'test> { .push_str(&format!("file {}\n", exe_file.to_str().unwrap().replace(r"\", r"\\"))); // Force GDB to print values in the Rust format. - if self.config.gdb_native_rust { - script_str.push_str("set language rust\n"); - } + script_str.push_str("set language rust\n"); // Add line breakpoints for line in &dbg_cmds.breakpoint_lines { @@ -1130,21 +1126,11 @@ impl<'test> TestCx<'test> { } } - let prefixes = if self.config.lldb_native_rust { - static PREFIXES: &[&str] = &["lldb", "lldbr"]; - println!("NOTE: compiletest thinks it is using LLDB with native rust support"); - PREFIXES - } else { - static PREFIXES: &[&str] = &["lldb", "lldbg"]; - println!("NOTE: compiletest thinks it is using LLDB without native rust support"); - PREFIXES - }; - // Parse debugger commands etc from test files let dbg_cmds = DebuggerCommands::parse_from( &self.testpaths.file, self.config, - prefixes, + &["lldb"], self.revision, ) .unwrap_or_else(|e| self.fatal(&e)); diff --git a/src/tools/compiletest/src/tests.rs b/src/tools/compiletest/src/tests.rs index 4292f234adc78..7c2e7b0f023cc 100644 --- a/src/tools/compiletest/src/tests.rs +++ b/src/tools/compiletest/src/tests.rs @@ -48,12 +48,12 @@ fn test_extract_gdb_version() { #[test] fn test_extract_lldb_version() { // Apple variants - assert_eq!(extract_lldb_version("LLDB-179.5"), Some((179, false))); - assert_eq!(extract_lldb_version("lldb-300.2.51"), Some((300, false))); + assert_eq!(extract_lldb_version("LLDB-179.5"), Some(179)); + assert_eq!(extract_lldb_version("lldb-300.2.51"), Some(300)); // Upstream versions - assert_eq!(extract_lldb_version("lldb version 6.0.1"), Some((600, false))); - assert_eq!(extract_lldb_version("lldb version 9.0.0"), Some((900, false))); + assert_eq!(extract_lldb_version("lldb version 6.0.1"), Some(600)); + assert_eq!(extract_lldb_version("lldb version 9.0.0"), Some(900)); } #[test]