Skip to content

Commit 20a8cf9

Browse files
committed
Rollup merge of rust-lang#33084 - alexcrichton:osx-python-sanity, r=michaelwoerister
Sanity check Python on OSX for LLDB tests Two primary changes: * Don't get past the configure stage if `python` isn't coming from `/usr/bin` * Call `debugger.Terminate()` to prevent segfaults on newer versions of LLDB. Closes rust-lang#32994
2 parents 6c0e63e + cbe6292 commit 20a8cf9

File tree

7 files changed

+39
-8
lines changed

7 files changed

+39
-8
lines changed

configure

+13
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,19 @@ then
823823
fi
824824
fi
825825

826+
# LLDB tests on OSX require /usr/bin/python, not something like Homebrew's
827+
# /usr/local/bin/python. We're loading a compiled module for LLDB tests which is
828+
# only compatible with the system.
829+
case $CFG_BUILD in
830+
*-apple-darwin)
831+
CFG_LLDB_PYTHON=/usr/bin/python
832+
;;
833+
*)
834+
CFG_LLDB_PYTHON=$CFG_PYTHON
835+
;;
836+
esac
837+
putvar CFG_LLDB_PYTHON
838+
826839
step_msg "looking for target specific programs"
827840

828841
probe CFG_ADB adb

mk/tests.mk

+2-1
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,8 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
619619
--stage-id stage$(1)-$(2) \
620620
--target $(2) \
621621
--host $(3) \
622-
--python $$(CFG_PYTHON) \
622+
--docck-python $$(CFG_PYTHON) \
623+
--lldb-python $$(CFG_LLDB_PYTHON) \
623624
--gdb-version="$(CFG_GDB_VERSION)" \
624625
--lldb-version="$(CFG_LLDB_VERSION)" \
625626
--android-cross-path=$(CFG_ANDROID_CROSS_PATH) \

src/bootstrap/build/check.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,19 @@ pub fn compiletest(build: &Build,
8181

8282
// FIXME: needs android support
8383
cmd.arg("--android-cross-path").arg("");
84+
8485
// FIXME: CFG_PYTHON should probably be detected more robustly elsewhere
85-
cmd.arg("--python").arg("python");
86+
let python_default = "python";
87+
cmd.arg("--docck-python").arg(python_default);
88+
89+
if build.config.build.ends_with("apple-darwin") {
90+
// Force /usr/bin/python on OSX for LLDB tests because we're loading the
91+
// LLDB plugin's compiled module which only works with the system python
92+
// (namely not Homebrew-installed python)
93+
cmd.arg("--lldb-python").arg("/usr/bin/python");
94+
} else {
95+
cmd.arg("--lldb-python").arg(python_default);
96+
}
8697

8798
if let Some(ref vers) = build.gdb_version {
8899
cmd.arg("--gdb-version").arg(vers);

src/etc/lldb_batchmode.py

+1
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,5 @@ def watchdog():
216216
print("Aborting.", file=sys.stderr)
217217
sys.exit(1)
218218
finally:
219+
debugger.Terminate()
219220
script_file.close()

src/tools/compiletest/src/common.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,11 @@ pub struct Config {
8383
// The rustdoc executable
8484
pub rustdoc_path: PathBuf,
8585

86-
// The python executable
87-
pub python: String,
86+
// The python executable to use for LLDB
87+
pub lldb_python: String,
88+
89+
// The python executable to use for htmldocck
90+
pub docck_python: String,
8891

8992
// The llvm FileCheck binary path
9093
pub llvm_filecheck: Option<PathBuf>,

src/tools/compiletest/src/main.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ pub fn parse_config(args: Vec<String> ) -> Config {
7272
reqopt("", "run-lib-path", "path to target shared libraries", "PATH"),
7373
reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH"),
7474
reqopt("", "rustdoc-path", "path to rustdoc to use for compiling", "PATH"),
75-
reqopt("", "python", "path to python to use for doc tests", "PATH"),
75+
reqopt("", "lldb-python", "path to python to use for doc tests", "PATH"),
76+
reqopt("", "docck-python", "path to python to use for doc tests", "PATH"),
7677
optopt("", "valgrind-path", "path to Valgrind executable for Valgrind tests", "PROGRAM"),
7778
optflag("", "force-valgrind", "fail if Valgrind tests cannot be run under Valgrind"),
7879
optopt("", "llvm-filecheck", "path to LLVM's FileCheck binary", "DIR"),
@@ -142,7 +143,8 @@ pub fn parse_config(args: Vec<String> ) -> Config {
142143
run_lib_path: make_absolute(opt_path(matches, "run-lib-path")),
143144
rustc_path: opt_path(matches, "rustc-path"),
144145
rustdoc_path: opt_path(matches, "rustdoc-path"),
145-
python: matches.opt_str("python").unwrap(),
146+
lldb_python: matches.opt_str("lldb-python").unwrap(),
147+
docck_python: matches.opt_str("docck-python").unwrap(),
146148
valgrind_path: matches.opt_str("valgrind-path"),
147149
force_valgrind: matches.opt_present("force-valgrind"),
148150
llvm_filecheck: matches.opt_str("llvm-filecheck").map(|s| PathBuf::from(&s)),

src/tools/compiletest/src/runtest.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testpaths: &TestP
777777
let lldb_script_path = rust_src_root.join("src/etc/lldb_batchmode.py");
778778
cmd2procres(config,
779779
testpaths,
780-
Command::new(&config.python)
780+
Command::new(&config.lldb_python)
781781
.arg(&lldb_script_path)
782782
.arg(test_executable)
783783
.arg(debugger_script)
@@ -1835,7 +1835,7 @@ fn run_rustdoc_test(config: &Config, props: &TestProps, testpaths: &TestPaths) {
18351835

18361836
let res = cmd2procres(config,
18371837
testpaths,
1838-
Command::new(&config.python)
1838+
Command::new(&config.docck_python)
18391839
.arg(root.join("src/etc/htmldocck.py"))
18401840
.arg(out_dir)
18411841
.arg(&testpaths.file));

0 commit comments

Comments
 (0)