From de8a4d5d46f6f270ea35192a03d701230d0552e8 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 10 Feb 2023 09:45:50 +0000 Subject: [PATCH] Remove all implicit "rustc" from rustc_info.rs --- build_system/bench.rs | 28 +++++++++++++++++++--------- build_system/build_backend.rs | 2 +- build_system/build_sysroot.rs | 2 +- build_system/mod.rs | 6 +++--- build_system/rustc_info.rs | 8 ++++---- 5 files changed, 28 insertions(+), 18 deletions(-) diff --git a/build_system/bench.rs b/build_system/bench.rs index 49f2954d57f..d24803eb7c6 100644 --- a/build_system/bench.rs +++ b/build_system/bench.rs @@ -4,7 +4,7 @@ use super::path::{Dirs, RelPath}; use super::prepare::GitRepo; use super::rustc_info::get_file_name; -use super::utils::{hyperfine_command, spawn_and_wait}; +use super::utils::{hyperfine_command, spawn_and_wait, Compiler}; static SIMPLE_RAYTRACER_REPO: GitRepo = GitRepo::github( "ebobby", @@ -13,11 +13,11 @@ "", ); -pub(crate) fn benchmark(dirs: &Dirs) { - benchmark_simple_raytracer(dirs); +pub(crate) fn benchmark(dirs: &Dirs, bootstrap_host_compiler: &Compiler) { + benchmark_simple_raytracer(dirs, bootstrap_host_compiler); } -fn benchmark_simple_raytracer(dirs: &Dirs) { +fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) { if std::process::Command::new("hyperfine").output().is_err() { eprintln!("Hyperfine not installed"); eprintln!("Hint: Try `cargo install hyperfine` to install hyperfine"); @@ -31,8 +31,9 @@ fn benchmark_simple_raytracer(dirs: &Dirs) { let bench_runs = env::var("BENCH_RUNS").unwrap_or_else(|_| "10".to_string()).parse().unwrap(); eprintln!("[BENCH COMPILE] ebobby/simple-raytracer"); - let cargo_clif = - RelPath::DIST.to_path(dirs).join(get_file_name("cargo_clif", "bin").replace('_', "-")); + let cargo_clif = RelPath::DIST + .to_path(dirs) + .join(get_file_name(&bootstrap_host_compiler.rustc, "cargo_clif", "bin").replace('_', "-")); let manifest_path = SIMPLE_RAYTRACER_REPO.source_dir().to_path(dirs).join("Cargo.toml"); let target_dir = RelPath::BUILD.join("simple_raytracer").to_path(dirs); @@ -75,9 +76,18 @@ fn benchmark_simple_raytracer(dirs: &Dirs) { bench_runs, None, &[ - Path::new(".").join(get_file_name("raytracer_cg_llvm", "bin")).to_str().unwrap(), - Path::new(".").join(get_file_name("raytracer_cg_clif", "bin")).to_str().unwrap(), - Path::new(".").join(get_file_name("raytracer_cg_clif_opt", "bin")).to_str().unwrap(), + Path::new(".") + .join(get_file_name(&bootstrap_host_compiler.rustc, "raytracer_cg_llvm", "bin")) + .to_str() + .unwrap(), + Path::new(".") + .join(get_file_name(&bootstrap_host_compiler.rustc, "raytracer_cg_clif", "bin")) + .to_str() + .unwrap(), + Path::new(".") + .join(get_file_name(&bootstrap_host_compiler.rustc, "raytracer_cg_clif_opt", "bin")) + .to_str() + .unwrap(), ], ); bench_run.current_dir(RelPath::BUILD.to_path(dirs)); diff --git a/build_system/build_backend.rs b/build_system/build_backend.rs index 4b740fa2db6..fc0965999e3 100644 --- a/build_system/build_backend.rs +++ b/build_system/build_backend.rs @@ -52,5 +52,5 @@ pub(crate) fn build_backend( .target_dir(dirs) .join(&bootstrap_host_compiler.triple) .join(channel) - .join(get_file_name("rustc_codegen_cranelift", "dylib")) + .join(get_file_name(&bootstrap_host_compiler.rustc, "rustc_codegen_cranelift", "dylib")) } diff --git a/build_system/build_sysroot.rs b/build_system/build_sysroot.rs index d6e231c53b5..67c4cfa4417 100644 --- a/build_system/build_sysroot.rs +++ b/build_system/build_sysroot.rs @@ -40,7 +40,7 @@ pub(crate) fn build_sysroot( try_hard_link(cg_clif_dylib_src, &cg_clif_dylib_path); // Build and copy rustc and cargo wrappers - let wrapper_base_name = get_file_name("____", "bin"); + let wrapper_base_name = get_file_name(&bootstrap_host_compiler.rustc, "____", "bin"); let toolchain_name = get_toolchain_name(); for wrapper in ["rustc-clif", "rustdoc-clif", "cargo-clif"] { let wrapper_name = wrapper_base_name.replace("____", wrapper); diff --git a/build_system/mod.rs b/build_system/mod.rs index b3293486c13..0a83ea93778 100644 --- a/build_system/mod.rs +++ b/build_system/mod.rs @@ -1,5 +1,5 @@ use std::env; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::process; use self::utils::{is_ci, is_ci_opt, Compiler}; @@ -105,7 +105,7 @@ pub(crate) fn main() { std::env::var("HOST_TRIPLE") .ok() .or_else(|| config::get_value("host")) - .unwrap_or_else(|| rustc_info::get_host_triple()), + .unwrap_or_else(|| rustc_info::get_host_triple(Path::new("rustc"))), ); let target_triple = std::env::var("TARGET_TRIPLE") .ok() @@ -187,7 +187,7 @@ pub(crate) fn main() { &bootstrap_host_compiler, target_triple, ); - bench::benchmark(&dirs); + bench::benchmark(&dirs, &bootstrap_host_compiler); } } } diff --git a/build_system/rustc_info.rs b/build_system/rustc_info.rs index a70453b4422..63f41ad5662 100644 --- a/build_system/rustc_info.rs +++ b/build_system/rustc_info.rs @@ -7,9 +7,9 @@ pub(crate) fn get_rustc_version(rustc: &Path) -> String { String::from_utf8(version_info).unwrap() } -pub(crate) fn get_host_triple() -> String { +pub(crate) fn get_host_triple(rustc: &Path) -> String { let version_info = - Command::new("rustc").stderr(Stdio::inherit()).args(&["-vV"]).output().unwrap().stdout; + Command::new(rustc).stderr(Stdio::inherit()).args(&["-vV"]).output().unwrap().stdout; String::from_utf8(version_info) .unwrap() .lines() @@ -73,8 +73,8 @@ pub(crate) fn get_default_sysroot(rustc: &Path) -> PathBuf { Path::new(String::from_utf8(default_sysroot).unwrap().trim()).to_owned() } -pub(crate) fn get_file_name(crate_name: &str, crate_type: &str) -> String { - let file_name = Command::new("rustc") +pub(crate) fn get_file_name(rustc: &Path, crate_name: &str, crate_type: &str) -> String { + let file_name = Command::new(rustc) .stderr(Stdio::inherit()) .args(&[ "--crate-name",