Remove all implicit "rustc" from rustc_info.rs

This commit is contained in:
bjorn3 2023-02-10 09:45:50 +00:00
parent 6900c9943d
commit de8a4d5d46
5 changed files with 28 additions and 18 deletions

View File

@ -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 @@
"<none>",
);
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));

View File

@ -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"))
}

View File

@ -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);

View File

@ -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);
}
}
}

View File

@ -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",