Skip to content

Commit 22c5249

Browse files
committed
Don't hard-code rustc path in get_rustc_version and get_default_sysroot
1 parent 4dbafef commit 22c5249

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

build_system/build_sysroot.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub(crate) fn build_sysroot(
5353
spawn_and_wait(build_cargo_wrapper_cmd);
5454
}
5555

56-
let default_sysroot = super::rustc_info::get_default_sysroot();
56+
let default_sysroot = super::rustc_info::get_default_sysroot(&bootstrap_host_compiler.rustc);
5757

5858
let host_rustlib_lib =
5959
RUSTLIB_DIR.to_path(dirs).join(&bootstrap_host_compiler.triple).join("lib");
@@ -182,7 +182,7 @@ fn build_clif_sysroot_for_triple(
182182
process::exit(1);
183183
}
184184
Ok(source_version) => {
185-
let rustc_version = get_rustc_version();
185+
let rustc_version = get_rustc_version(&compiler.rustc);
186186
if source_version != rustc_version {
187187
eprintln!("The patched sysroot source is outdated");
188188
eprintln!("Source version: {}", source_version.trim());

build_system/prepare.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub(crate) fn prepare(dirs: &Dirs) {
3535
}
3636

3737
fn prepare_sysroot(dirs: &Dirs) {
38-
let sysroot_src_orig = get_default_sysroot().join("lib/rustlib/src/rust");
38+
let sysroot_src_orig = get_default_sysroot(Path::new("rustc")).join("lib/rustlib/src/rust");
3939
assert!(sysroot_src_orig.exists());
4040

4141
eprintln!("[COPY] sysroot src");
@@ -50,7 +50,7 @@ fn prepare_sysroot(dirs: &Dirs) {
5050
&SYSROOT_SRC.to_path(dirs).join("library"),
5151
);
5252

53-
let rustc_version = get_rustc_version();
53+
let rustc_version = get_rustc_version(Path::new("rustc"));
5454
fs::write(SYSROOT_RUSTC_VERSION.to_path(dirs), &rustc_version).unwrap();
5555

5656
eprintln!("[GIT] init");

build_system/rustc_info.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use std::path::{Path, PathBuf};
22
use std::process::{Command, Stdio};
33

4-
pub(crate) fn get_rustc_version() -> String {
4+
pub(crate) fn get_rustc_version(rustc: &Path) -> String {
55
let version_info =
6-
Command::new("rustc").stderr(Stdio::inherit()).args(&["-V"]).output().unwrap().stdout;
6+
Command::new(rustc).stderr(Stdio::inherit()).args(&["-V"]).output().unwrap().stdout;
77
String::from_utf8(version_info).unwrap()
88
}
99

@@ -53,8 +53,8 @@ pub(crate) fn get_rustdoc_path() -> PathBuf {
5353
Path::new(String::from_utf8(rustc_path).unwrap().trim()).to_owned()
5454
}
5555

56-
pub(crate) fn get_default_sysroot() -> PathBuf {
57-
let default_sysroot = Command::new("rustc")
56+
pub(crate) fn get_default_sysroot(rustc: &Path) -> PathBuf {
57+
let default_sysroot = Command::new(rustc)
5858
.stderr(Stdio::inherit())
5959
.args(&["--print", "sysroot"])
6060
.output()

0 commit comments

Comments
 (0)