Skip to content

Commit dce4600

Browse files
committed
detect gdb version & rust support in compiletest
1 parent 6554fb0 commit dce4600

File tree

11 files changed

+180
-89
lines changed

11 files changed

+180
-89
lines changed

configure

-7
Original file line numberDiff line numberDiff line change
@@ -862,13 +862,6 @@ then
862862
fi
863863
fi
864864

865-
if [ -n "$CFG_GDB" ]
866-
then
867-
# Store GDB's version
868-
CFG_GDB_VERSION=$($CFG_GDB --version 2>/dev/null | head -1)
869-
putvar CFG_GDB_VERSION
870-
fi
871-
872865
if [ -n "$CFG_LLDB" ]
873866
then
874867
# Store LLDB's version

mk/tests.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) = \
648648
--host $(3) \
649649
--docck-python $$(CFG_PYTHON) \
650650
--lldb-python $$(CFG_LLDB_PYTHON) \
651-
--gdb-version="$(CFG_GDB_VERSION)" \
651+
--gdb="$(CFG_GDB)" \
652652
--lldb-version="$(CFG_LLDB_VERSION)" \
653653
--llvm-version="$$(LLVM_VERSION_$(3))" \
654654
--android-cross-path=$(CFG_ARM_LINUX_ANDROIDEABI_NDK) \

src/bootstrap/check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ pub fn compiletest(build: &Build,
168168
cmd.arg("--lldb-python").arg(python_default);
169169
}
170170

171-
if let Some(ref vers) = build.gdb_version {
172-
cmd.arg("--gdb-version").arg(vers);
171+
if let Some(ref gdb) = build.config.gdb {
172+
cmd.arg("--gdb").arg(gdb);
173173
}
174174
if let Some(ref vers) = build.lldb_version {
175175
cmd.arg("--lldb-version").arg(vers);

src/bootstrap/config.rs

+6
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ pub struct Config {
8585
pub mandir: Option<String>,
8686
pub codegen_tests: bool,
8787
pub nodejs: Option<PathBuf>,
88+
pub gdb: Option<PathBuf>,
8889
}
8990

9091
/// Per-target configuration stored in the global configuration structure.
@@ -122,6 +123,7 @@ struct Build {
122123
compiler_docs: Option<bool>,
123124
docs: Option<bool>,
124125
submodules: Option<bool>,
126+
gdb: Option<String>,
125127
}
126128

127129
/// TOML representation of how the LLVM build is configured.
@@ -226,6 +228,7 @@ impl Config {
226228
}
227229
config.rustc = build.rustc.map(PathBuf::from);
228230
config.cargo = build.cargo.map(PathBuf::from);
231+
config.gdb = build.gdb.map(PathBuf::from);
229232
set(&mut config.compiler_docs, build.compiler_docs);
230233
set(&mut config.docs, build.docs);
231234
set(&mut config.submodules, build.submodules);
@@ -392,6 +395,9 @@ impl Config {
392395
"CFG_DEFAULT_LINKER" if value.len() > 0 => {
393396
self.rustc_default_linker = Some(value.to_string());
394397
}
398+
"CFG_GDB" if value.len() > 0 => {
399+
self.gdb = Some(PathBuf::from(value));
400+
}
395401
"CFG_RELEASE_CHANNEL" => {
396402
self.channel = value.to_string();
397403
}

src/bootstrap/config.toml.example

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@
7979
# Indicate whether submodules are managed and updated automatically.
8080
#submodules = true
8181

82+
# The path to (or name of) the GDB executable to use
83+
#gdb = "gdb"
84+
8285
# =============================================================================
8386
# Options for compiling Rust code itself
8487
# =============================================================================

src/bootstrap/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ pub struct Build {
123123
bootstrap_key_stage0: String,
124124

125125
// Probed tools at runtime
126-
gdb_version: Option<String>,
127126
lldb_version: Option<String>,
128127
lldb_python_dir: Option<String>,
129128

@@ -196,7 +195,6 @@ impl Build {
196195
package_vers: String::new(),
197196
cc: HashMap::new(),
198197
cxx: HashMap::new(),
199-
gdb_version: None,
200198
lldb_version: None,
201199
lldb_python_dir: None,
202200
}

src/bootstrap/sanity.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ pub fn check(build: &mut Build) {
9292
need_cmd(s.as_ref());
9393
}
9494

95+
if let Some(ref gdb) = build.config.gdb {
96+
need_cmd(gdb.as_ref());
97+
} else {
98+
build.config.gdb = have_cmd("gdb".as_ref());
99+
}
100+
95101
// We're gonna build some custom C code here and there, host triples
96102
// also build some C++ shims for LLVM so we need a C++ compiler.
97103
for target in build.config.target.iter() {
@@ -198,7 +204,6 @@ $ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
198204
.to_string()
199205
})
200206
};
201-
build.gdb_version = run(Command::new("gdb").arg("--version")).ok();
202207
build.lldb_version = run(Command::new("lldb").arg("--version")).ok();
203208
if build.lldb_version.is_some() {
204209
build.lldb_python_dir = run(Command::new("lldb").arg("-P")).ok();

src/tools/compiletest/src/common.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,11 @@ pub struct Config {
146146
// Host triple for the compiler being invoked
147147
pub host: String,
148148

149-
// Version of GDB
150-
pub gdb_version: Option<String>,
149+
// Path to / name of the GDB executable
150+
pub gdb: Option<String>,
151+
152+
// Version of GDB, encoded as ((major * 1000) + minor) * 1000 + patch
153+
pub gdb_version: Option<u32>,
151154

152155
// Whether GDB has native rust support
153156
pub gdb_native_rust: bool,

src/tools/compiletest/src/header.rs

+4-19
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ use common::Config;
1818
use common;
1919
use util;
2020

21+
use extract_gdb_version;
22+
2123
/// Properties which must be known very early, before actually running
2224
/// the test.
2325
pub struct EarlyProps {
@@ -75,15 +77,15 @@ impl EarlyProps {
7577
return true;
7678
}
7779

78-
if let Some(ref actual_version) = config.gdb_version {
80+
if let Some(actual_version) = config.gdb_version {
7981
if line.contains("min-gdb-version") {
8082
let min_version = line.trim()
8183
.split(' ')
8284
.last()
8385
.expect("Malformed GDB version directive");
8486
// Ignore if actual version is smaller the minimum required
8587
// version
86-
gdb_version_to_int(actual_version) < gdb_version_to_int(min_version)
88+
actual_version < extract_gdb_version(min_version).unwrap()
8789
} else {
8890
false
8991
}
@@ -464,23 +466,6 @@ pub fn parse_name_value_directive(line: &str, directive: &str) -> Option<String>
464466
}
465467
}
466468

467-
pub fn gdb_version_to_int(version_string: &str) -> isize {
468-
let error_string = format!("Encountered GDB version string with unexpected format: {}",
469-
version_string);
470-
let error_string = error_string;
471-
472-
let components: Vec<&str> = version_string.trim().split('.').collect();
473-
474-
if components.len() != 2 {
475-
panic!("{}", error_string);
476-
}
477-
478-
let major: isize = components[0].parse().ok().expect(&error_string);
479-
let minor: isize = components[1].parse().ok().expect(&error_string);
480-
481-
return major * 1000 + minor;
482-
}
483-
484469
pub fn lldb_version_to_int(version_string: &str) -> isize {
485470
let error_string = format!("Encountered LLDB version string with unexpected format: {}",
486471
version_string);

0 commit comments

Comments
 (0)