Skip to content

Commit b314ca3

Browse files
Auto merge of #148646 - jieyouxu:no-pythonpath, r=<try>
compiletest: don't pickup a Python from `PYTHONPATH` in debuginfo try-job: aarch64-apple
2 parents 0bbef55 + 790ea73 commit b314ca3

File tree

6 files changed

+15
-28
lines changed

6 files changed

+15
-28
lines changed

bootstrap.example.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,9 @@
322322
# Python interpreter to use for various tasks throughout the build, notably
323323
# rustdoc tests, the lldb python interpreter, and some dist bits and pieces.
324324
#
325-
# Defaults to the Python interpreter used to execute x.py.
325+
# Defaults to the Python interpreter used to execute x.py, or /usr/bin/python3
326+
# on macOS. Note that LLDB tests require a Python version compatible with the
327+
# LLDB plugin to be loaded.
326328
#build.python = "python"
327329

328330
# The path to (or name of) the resource compiler executable to use on Windows.

src/bootstrap/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,10 +1525,11 @@ impl Build {
15251525
/// Path to the python interpreter to use
15261526
fn python(&self) -> &Path {
15271527
if self.config.host_target.ends_with("apple-darwin") {
1528-
// Force /usr/bin/python3 on macOS for LLDB tests because we're loading the
1529-
// LLDB plugin's compiled module which only works with the system python
1530-
// (namely not Homebrew-installed python)
1531-
Path::new("/usr/bin/python3")
1528+
// LLDB tests require the Python version the LLDB plugin was built for.
1529+
// On macOS, the system Python/LLDB are compatible. Many users install
1530+
// Homebrew Python but not Homebrew LLVM, so default to system Python.
1531+
// Can be overridden via `build.python` for custom LLVM installations.
1532+
self.config.python.as_deref().unwrap_or_else(|| Path::new("/usr/bin/python3"))
15321533
} else {
15331534
self.config
15341535
.python

src/bootstrap/src/utils/change_tracker.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,4 +576,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
576576
severity: ChangeSeverity::Info,
577577
summary: "`llvm.enzyme` now works with `download-ci-llvm=true`.",
578578
},
579+
ChangeInfo {
580+
change_id: 148636,
581+
severity: ChangeSeverity::Info,
582+
summary: "The `build.python` option is now respected on macOS (previously ignored).",
583+
},
579584
];

src/tools/compiletest/src/common.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,6 @@ pub struct Config {
524524
///
525525
/// FIXME: the fallback path when `gdb` isn't provided tries to find *a* `gdb` or `gdb.exe` from
526526
/// `PATH`, which is... arguably questionable.
527-
///
528-
/// FIXME: we are propagating a python from `PYTHONPATH`, not from an explicit config for gdb
529-
/// debugger script.
530527
pub gdb: Option<String>,
531528

532529
/// Version of GDB, encoded as ((major * 1000) + minor) * 1000 + patch
@@ -587,8 +584,6 @@ pub struct Config {
587584
pub adb_device_status: bool,
588585

589586
/// Path containing LLDB's Python module.
590-
///
591-
/// FIXME: `PYTHONPATH` takes precedence over this flag...? See `runtest::run_lldb`.
592587
pub lldb_python_dir: Option<String>,
593588

594589
/// Verbose dump a lot of info.

src/tools/compiletest/src/runtest.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,12 @@ pub fn compute_stamp_hash(config: &Config) -> String {
196196
Some(Debugger::Gdb) => {
197197
config.gdb.hash(&mut hash);
198198
env::var_os("PATH").hash(&mut hash);
199-
env::var_os("PYTHONPATH").hash(&mut hash);
200199
}
201200

202201
Some(Debugger::Lldb) => {
203202
config.python.hash(&mut hash);
204203
config.lldb_python_dir.hash(&mut hash);
205204
env::var_os("PATH").hash(&mut hash);
206-
env::var_os("PYTHONPATH").hash(&mut hash);
207205
}
208206

209207
None => {}

src/tools/compiletest/src/runtest/debuginfo.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -303,14 +303,7 @@ impl TestCx<'_> {
303303
&["-quiet".as_ref(), "-batch".as_ref(), "-nx".as_ref(), &debugger_script];
304304

305305
let mut gdb = Command::new(self.config.gdb.as_ref().unwrap());
306-
307-
// FIXME: we are propagating `PYTHONPATH` from the environment, not a compiletest flag!
308-
let pythonpath = if let Ok(pp) = std::env::var("PYTHONPATH") {
309-
format!("{pp}:{rust_pp_module_abs_path}")
310-
} else {
311-
rust_pp_module_abs_path.to_string()
312-
};
313-
gdb.args(debugger_opts).env("PYTHONPATH", pythonpath);
306+
gdb.args(debugger_opts);
314307

315308
debugger_run_result =
316309
self.compose_and_run(gdb, self.config.run_lib_path.as_path(), None, None);
@@ -449,19 +442,12 @@ impl TestCx<'_> {
449442
// Prepare the lldb_batchmode which executes the debugger script
450443
let lldb_script_path = self.config.src_root.join("src/etc/lldb_batchmode.py");
451444

452-
// FIXME: `PYTHONPATH` takes precedence over the flag...?
453-
let pythonpath = if let Ok(pp) = std::env::var("PYTHONPATH") {
454-
format!("{pp}:{}", self.config.lldb_python_dir.as_ref().unwrap())
455-
} else {
456-
self.config.lldb_python_dir.clone().unwrap()
457-
};
458445
self.run_command_to_procres(
459446
Command::new(&self.config.python)
460447
.arg(&lldb_script_path)
461448
.arg(test_executable)
462449
.arg(debugger_script)
463-
.env("PYTHONUNBUFFERED", "1") // Help debugging #78665
464-
.env("PYTHONPATH", pythonpath),
450+
.env("PYTHONUNBUFFERED", "1"), // Help debugging #78665
465451
)
466452
}
467453
}

0 commit comments

Comments
 (0)