Skip to content

Commit 3126289

Browse files
committed
Clean up compiletest
1 parent bac291c commit 3126289

File tree

5 files changed

+14
-54
lines changed

5 files changed

+14
-54
lines changed

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

-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
142142
"needs-relocation-model-pic",
143143
"needs-run-enabled",
144144
"needs-rust-lld",
145-
"needs-rust-lldb",
146145
"needs-sanitizer-address",
147146
"needs-sanitizer-cfi",
148147
"needs-sanitizer-dataflow",

src/tools/compiletest/src/common.rs

-6
Original file line numberDiff line numberDiff line change
@@ -296,15 +296,9 @@ pub struct Config {
296296
/// Version of GDB, encoded as ((major * 1000) + minor) * 1000 + patch
297297
pub gdb_version: Option<u32>,
298298

299-
/// Whether GDB has native rust support
300-
pub gdb_native_rust: bool,
301-
302299
/// Version of LLDB
303300
pub lldb_version: Option<u32>,
304301

305-
/// Whether LLDB has native rust support
306-
pub lldb_native_rust: bool,
307-
308302
/// Version of LLVM
309303
pub llvm_version: Option<u32>,
310304

src/tools/compiletest/src/header/needs.rs

-5
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,6 @@ pub(super) fn handle_needs(
114114
condition: cache.rust_lld,
115115
ignore_reason: "ignored on targets without Rust's LLD",
116116
},
117-
Need {
118-
name: "needs-rust-lldb",
119-
condition: config.debugger != Some(Debugger::Lldb) || config.lldb_native_rust,
120-
ignore_reason: "ignored on targets without Rust's LLDB",
121-
},
122117
Need {
123118
name: "needs-dlltool",
124119
condition: cache.dlltool,

src/tools/compiletest/src/lib.rs

+11-25
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
194194
let target = opt_str2(matches.opt_str("target"));
195195
let android_cross_path = opt_path(matches, "android-cross-path");
196196
let (cdb, cdb_version) = analyze_cdb(matches.opt_str("cdb"), &target);
197-
let (gdb, gdb_version, gdb_native_rust) =
198-
analyze_gdb(matches.opt_str("gdb"), &target, &android_cross_path);
199-
let (lldb_version, lldb_native_rust) = matches
200-
.opt_str("lldb-version")
201-
.as_deref()
202-
.and_then(extract_lldb_version)
203-
.map(|(v, b)| (Some(v), b))
204-
.unwrap_or((None, false));
197+
let (gdb, gdb_version) = analyze_gdb(matches.opt_str("gdb"), &target, &android_cross_path);
198+
let lldb_version = matches.opt_str("lldb-version").as_deref().and_then(extract_lldb_version);
205199
let color = match matches.opt_str("color").as_deref() {
206200
Some("auto") | None => ColorConfig::AutoColor,
207201
Some("always") => ColorConfig::AlwaysColor,
@@ -298,9 +292,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
298292
cdb_version,
299293
gdb,
300294
gdb_version,
301-
gdb_native_rust,
302295
lldb_version,
303-
lldb_native_rust,
304296
llvm_version,
305297
system_llvm: matches.opt_present("system-llvm"),
306298
android_cross_path,
@@ -1035,19 +1027,17 @@ fn extract_cdb_version(full_version_line: &str) -> Option<[u16; 4]> {
10351027
Some([major, minor, patch, build])
10361028
}
10371029

1038-
/// Returns (Path to GDB, GDB Version, GDB has Rust Support)
1030+
/// Returns (Path to GDB, GDB Version)
10391031
fn analyze_gdb(
10401032
gdb: Option<String>,
10411033
target: &str,
10421034
android_cross_path: &PathBuf,
1043-
) -> (Option<String>, Option<u32>, bool) {
1035+
) -> (Option<String>, Option<u32>) {
10441036
#[cfg(not(windows))]
10451037
const GDB_FALLBACK: &str = "gdb";
10461038
#[cfg(windows)]
10471039
const GDB_FALLBACK: &str = "gdb.exe";
10481040

1049-
const MIN_GDB_WITH_RUST: u32 = 7011010;
1050-
10511041
let fallback_gdb = || {
10521042
if is_android_gdb_target(target) {
10531043
let mut gdb_path = match android_cross_path.to_str() {
@@ -1076,12 +1066,10 @@ fn analyze_gdb(
10761066

10771067
let version = match version_line {
10781068
Some(line) => extract_gdb_version(&line),
1079-
None => return (None, None, false),
1069+
None => return (None, None),
10801070
};
10811071

1082-
let gdb_native_rust = version.map_or(false, |v| v >= MIN_GDB_WITH_RUST);
1083-
1084-
(Some(gdb), version, gdb_native_rust)
1072+
(Some(gdb), version)
10851073
}
10861074

10871075
fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
@@ -1131,8 +1119,8 @@ fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
11311119
Some(((major * 1000) + minor) * 1000 + patch)
11321120
}
11331121

1134-
/// Returns (LLDB version, LLDB is rust-enabled)
1135-
fn extract_lldb_version(full_version_line: &str) -> Option<(u32, bool)> {
1122+
/// Returns LLDB version
1123+
fn extract_lldb_version(full_version_line: &str) -> Option<u32> {
11361124
// Extract the major LLDB version from the given version string.
11371125
// LLDB version strings are different for Apple and non-Apple platforms.
11381126
// The Apple variant looks like this:
@@ -1149,9 +1137,7 @@ fn extract_lldb_version(full_version_line: &str) -> Option<(u32, bool)> {
11491137
// There doesn't seem to be a way to correlate the Apple version
11501138
// with the upstream version, and since the tests were originally
11511139
// written against Apple versions, we make a fake Apple version by
1152-
// multiplying the first number by 100. This is a hack, but
1153-
// normally fine because the only non-Apple version we test is
1154-
// rust-enabled.
1140+
// multiplying the first number by 100. This is a hack.
11551141

11561142
let full_version_line = full_version_line.trim();
11571143

@@ -1160,12 +1146,12 @@ fn extract_lldb_version(full_version_line: &str) -> Option<(u32, bool)> {
11601146
{
11611147
if let Some(idx) = apple_ver.find(not_a_digit) {
11621148
let version: u32 = apple_ver[..idx].parse().unwrap();
1163-
return Some((version, full_version_line.contains("rust-enabled")));
1149+
return Some(version);
11641150
}
11651151
} else if let Some(lldb_ver) = full_version_line.strip_prefix("lldb version ") {
11661152
if let Some(idx) = lldb_ver.find(not_a_digit) {
11671153
let version: u32 = lldb_ver[..idx].parse().ok()?;
1168-
return Some((version * 100, full_version_line.contains("rust-enabled")));
1154+
return Some(version * 100);
11691155
}
11701156
}
11711157
None

src/tools/compiletest/src/runtest.rs

+3-17
Original file line numberDiff line numberDiff line change
@@ -856,12 +856,10 @@ impl<'test> TestCx<'test> {
856856
}
857857

858858
fn run_debuginfo_gdb_test_no_opt(&self) {
859-
let prefixes = &["gdb"];
860-
861859
let dbg_cmds = DebuggerCommands::parse_from(
862860
&self.testpaths.file,
863861
self.config,
864-
prefixes,
862+
&["gdb"],
865863
self.revision,
866864
)
867865
.unwrap_or_else(|e| self.fatal(&e));
@@ -1043,9 +1041,7 @@ impl<'test> TestCx<'test> {
10431041
.push_str(&format!("file {}\n", exe_file.to_str().unwrap().replace(r"\", r"\\")));
10441042

10451043
// Force GDB to print values in the Rust format.
1046-
if self.config.gdb_native_rust {
1047-
script_str.push_str("set language rust\n");
1048-
}
1044+
script_str.push_str("set language rust\n");
10491045

10501046
// Add line breakpoints
10511047
for line in &dbg_cmds.breakpoint_lines {
@@ -1130,21 +1126,11 @@ impl<'test> TestCx<'test> {
11301126
}
11311127
}
11321128

1133-
let prefixes = if self.config.lldb_native_rust {
1134-
static PREFIXES: &[&str] = &["lldb", "lldbr"];
1135-
println!("NOTE: compiletest thinks it is using LLDB with native rust support");
1136-
PREFIXES
1137-
} else {
1138-
static PREFIXES: &[&str] = &["lldb", "lldbg"];
1139-
println!("NOTE: compiletest thinks it is using LLDB without native rust support");
1140-
PREFIXES
1141-
};
1142-
11431129
// Parse debugger commands etc from test files
11441130
let dbg_cmds = DebuggerCommands::parse_from(
11451131
&self.testpaths.file,
11461132
self.config,
1147-
prefixes,
1133+
&["lldb"],
11481134
self.revision,
11491135
)
11501136
.unwrap_or_else(|e| self.fatal(&e));

0 commit comments

Comments
 (0)