From a726de23054fd4e5bec6d5df818ea5ddbbeb4356 Mon Sep 17 00:00:00 2001 From: Seth Junot Date: Thu, 6 Nov 2025 23:00:35 -0800 Subject: [PATCH 1/2] bootstrap: respect `build.python` on macOS The `python()` method was hardcoded to return `/usr/bin/python3` on macOS, ignoring the `build.python` config option. This change respects the config and removes the macOS-specific default. --- src/bootstrap/src/core/build_steps/test.rs | 8 ++++++-- src/bootstrap/src/core/sanity.rs | 11 ++++++----- src/bootstrap/src/lib.rs | 15 --------------- src/bootstrap/src/utils/change_tracker.rs | 5 +++++ 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index b3f4672bd6d1..be05b92a0973 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -2075,7 +2075,9 @@ fn run(self, builder: &Builder<'_>) { cmd.arg("--target-rustcflags").arg(flag); } - cmd.arg("--python").arg(builder.python()); + cmd.arg("--python").arg( + builder.config.python.as_ref().expect("python is required for running rustdoc tests"), + ); // FIXME(#148099): Currently we set these Android-related flags in all // modes, even though they should only be needed in "debuginfo" mode, @@ -3359,7 +3361,9 @@ fn make_run(run: RunConfig<'_>) { } fn run(self, builder: &Builder<'_>) -> Self::Output { - let mut check_bootstrap = command(builder.python()); + let mut check_bootstrap = command( + builder.config.python.as_ref().expect("python is required for running bootstrap tests"), + ); check_bootstrap .args(["-m", "unittest", "bootstrap_test.py"]) // Forward command-line args after `--` to unittest, for filtering etc. diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index ed63b2aae452..e5afb31213ce 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -1,9 +1,10 @@ -//! Sanity checking performed by bootstrap before actually executing anything. +//! Sanity checking and tool selection performed by bootstrap. //! -//! This module contains the implementation of ensuring that the build -//! environment looks reasonable before progressing. This will verify that -//! various programs like git and python exist, along with ensuring that all C -//! compilers for cross-compiling are found. +//! This module ensures that the build environment is correctly set up before +//! executing any build tasks. It verifies required programs exist (like git and +//! cmake when needed), selects some tools based on the environment (like the +//! Python interpreter), and validates that C compilers for cross-compiling are +//! available. //! //! In theory if we get past this phase it's a bug if a build fails, but in //! practice that's likely not true! diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index d646e3badb41..093db739e6cb 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -1522,21 +1522,6 @@ fn qemu_rootfs(&self, target: TargetSelection) -> Option<&Path> { self.config.target_config.get(&target).and_then(|t| t.qemu_rootfs.as_ref()).map(|p| &**p) } - /// Path to the python interpreter to use - fn python(&self) -> &Path { - if self.config.host_target.ends_with("apple-darwin") { - // Force /usr/bin/python3 on macOS for LLDB tests because we're loading the - // LLDB plugin's compiled module which only works with the system python - // (namely not Homebrew-installed python) - Path::new("/usr/bin/python3") - } else { - self.config - .python - .as_ref() - .expect("python is required for running LLDB or rustdoc tests") - } - } - /// Temporary directory that extended error information is emitted to. fn extended_error_dir(&self) -> PathBuf { self.out.join("tmp/extended-error-metadata") diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index 921f57eb66d6..3766eab1f4be 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -576,4 +576,9 @@ pub fn human_readable_changes(changes: &[ChangeInfo]) -> String { severity: ChangeSeverity::Info, summary: "`llvm.enzyme` now works with `download-ci-llvm=true`.", }, + ChangeInfo { + change_id: 148636, + severity: ChangeSeverity::Info, + summary: "The `build.python` option is now respected on macOS (previously ignored).", + }, ]; From 191a3e3c194b1479c5a8866af5b1fc410011ff34 Mon Sep 17 00:00:00 2001 From: Seth Junot Date: Mon, 10 Nov 2025 13:32:39 -0800 Subject: [PATCH 2/2] Noted the previous forced default in the change tracker --- src/bootstrap/src/utils/change_tracker.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index 3766eab1f4be..59140b9ce84c 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -579,6 +579,6 @@ pub fn human_readable_changes(changes: &[ChangeInfo]) -> String { ChangeInfo { change_id: 148636, severity: ChangeSeverity::Info, - summary: "The `build.python` option is now respected on macOS (previously ignored).", + summary: "The `build.python` option is now respected on macOS (previously ignored and forced to be /usr/bin/python3).", }, ];