diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2023-01-14 13:08:55 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2023-01-14 14:18:11 +0000 |
| commit | 22c5249f68676f7ba8852fd59cd222c49a1523a2 (patch) | |
| tree | 9118cd19181c5899f7f3a5cb6e37ce9302d595d7 | |
| parent | 4dbafefe74f32ca7f76009e6ce3136348a017b3a (diff) | |
| download | rust-22c5249f68676f7ba8852fd59cd222c49a1523a2.tar.gz rust-22c5249f68676f7ba8852fd59cd222c49a1523a2.zip | |
Don't hard-code rustc path in get_rustc_version and get_default_sysroot
| -rw-r--r-- | build_system/build_sysroot.rs | 4 | ||||
| -rw-r--r-- | build_system/prepare.rs | 4 | ||||
| -rw-r--r-- | build_system/rustc_info.rs | 8 |
3 files changed, 8 insertions, 8 deletions
diff --git a/build_system/build_sysroot.rs b/build_system/build_sysroot.rs index 7902c7005e0..15a5e030193 100644 --- a/build_system/build_sysroot.rs +++ b/build_system/build_sysroot.rs @@ -53,7 +53,7 @@ pub(crate) fn build_sysroot( spawn_and_wait(build_cargo_wrapper_cmd); } - let default_sysroot = super::rustc_info::get_default_sysroot(); + let default_sysroot = super::rustc_info::get_default_sysroot(&bootstrap_host_compiler.rustc); let host_rustlib_lib = RUSTLIB_DIR.to_path(dirs).join(&bootstrap_host_compiler.triple).join("lib"); @@ -182,7 +182,7 @@ fn build_clif_sysroot_for_triple( process::exit(1); } Ok(source_version) => { - let rustc_version = get_rustc_version(); + let rustc_version = get_rustc_version(&compiler.rustc); if source_version != rustc_version { eprintln!("The patched sysroot source is outdated"); eprintln!("Source version: {}", source_version.trim()); diff --git a/build_system/prepare.rs b/build_system/prepare.rs index 4e898b30b7c..bc6c3223dc2 100644 --- a/build_system/prepare.rs +++ b/build_system/prepare.rs @@ -35,7 +35,7 @@ pub(crate) fn prepare(dirs: &Dirs) { } fn prepare_sysroot(dirs: &Dirs) { - let sysroot_src_orig = get_default_sysroot().join("lib/rustlib/src/rust"); + let sysroot_src_orig = get_default_sysroot(Path::new("rustc")).join("lib/rustlib/src/rust"); assert!(sysroot_src_orig.exists()); eprintln!("[COPY] sysroot src"); @@ -50,7 +50,7 @@ fn prepare_sysroot(dirs: &Dirs) { &SYSROOT_SRC.to_path(dirs).join("library"), ); - let rustc_version = get_rustc_version(); + let rustc_version = get_rustc_version(Path::new("rustc")); fs::write(SYSROOT_RUSTC_VERSION.to_path(dirs), &rustc_version).unwrap(); eprintln!("[GIT] init"); diff --git a/build_system/rustc_info.rs b/build_system/rustc_info.rs index 8e5ab688e13..6959d1e323c 100644 --- a/build_system/rustc_info.rs +++ b/build_system/rustc_info.rs @@ -1,9 +1,9 @@ use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; -pub(crate) fn get_rustc_version() -> String { +pub(crate) fn get_rustc_version(rustc: &Path) -> String { let version_info = - Command::new("rustc").stderr(Stdio::inherit()).args(&["-V"]).output().unwrap().stdout; + Command::new(rustc).stderr(Stdio::inherit()).args(&["-V"]).output().unwrap().stdout; String::from_utf8(version_info).unwrap() } @@ -53,8 +53,8 @@ pub(crate) fn get_rustdoc_path() -> PathBuf { Path::new(String::from_utf8(rustc_path).unwrap().trim()).to_owned() } -pub(crate) fn get_default_sysroot() -> PathBuf { - let default_sysroot = Command::new("rustc") +pub(crate) fn get_default_sysroot(rustc: &Path) -> PathBuf { + let default_sysroot = Command::new(rustc) .stderr(Stdio::inherit()) .args(&["--print", "sysroot"]) .output() |
