Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit de8a4d5

Browse files
committed
Remove all implicit "rustc" from rustc_info.rs
1 parent 6900c99 commit de8a4d5

File tree

5 files changed

+28
-18
lines changed

5 files changed

+28
-18
lines changed

build_system/bench.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::path::Path;
44
use super::path::{Dirs, RelPath};
55
use super::prepare::GitRepo;
66
use super::rustc_info::get_file_name;
7-
use super::utils::{hyperfine_command, spawn_and_wait};
7+
use super::utils::{hyperfine_command, spawn_and_wait, Compiler};
88

99
static SIMPLE_RAYTRACER_REPO: GitRepo = GitRepo::github(
1010
"ebobby",
@@ -13,11 +13,11 @@ static SIMPLE_RAYTRACER_REPO: GitRepo = GitRepo::github(
1313
"<none>",
1414
);
1515

16-
pub(crate) fn benchmark(dirs: &Dirs) {
17-
benchmark_simple_raytracer(dirs);
16+
pub(crate) fn benchmark(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
17+
benchmark_simple_raytracer(dirs, bootstrap_host_compiler);
1818
}
1919

20-
fn benchmark_simple_raytracer(dirs: &Dirs) {
20+
fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
2121
if std::process::Command::new("hyperfine").output().is_err() {
2222
eprintln!("Hyperfine not installed");
2323
eprintln!("Hint: Try `cargo install hyperfine` to install hyperfine");
@@ -31,8 +31,9 @@ fn benchmark_simple_raytracer(dirs: &Dirs) {
3131
let bench_runs = env::var("BENCH_RUNS").unwrap_or_else(|_| "10".to_string()).parse().unwrap();
3232

3333
eprintln!("[BENCH COMPILE] ebobby/simple-raytracer");
34-
let cargo_clif =
35-
RelPath::DIST.to_path(dirs).join(get_file_name("cargo_clif", "bin").replace('_', "-"));
34+
let cargo_clif = RelPath::DIST
35+
.to_path(dirs)
36+
.join(get_file_name(&bootstrap_host_compiler.rustc, "cargo_clif", "bin").replace('_', "-"));
3637
let manifest_path = SIMPLE_RAYTRACER_REPO.source_dir().to_path(dirs).join("Cargo.toml");
3738
let target_dir = RelPath::BUILD.join("simple_raytracer").to_path(dirs);
3839

@@ -75,9 +76,18 @@ fn benchmark_simple_raytracer(dirs: &Dirs) {
7576
bench_runs,
7677
None,
7778
&[
78-
Path::new(".").join(get_file_name("raytracer_cg_llvm", "bin")).to_str().unwrap(),
79-
Path::new(".").join(get_file_name("raytracer_cg_clif", "bin")).to_str().unwrap(),
80-
Path::new(".").join(get_file_name("raytracer_cg_clif_opt", "bin")).to_str().unwrap(),
79+
Path::new(".")
80+
.join(get_file_name(&bootstrap_host_compiler.rustc, "raytracer_cg_llvm", "bin"))
81+
.to_str()
82+
.unwrap(),
83+
Path::new(".")
84+
.join(get_file_name(&bootstrap_host_compiler.rustc, "raytracer_cg_clif", "bin"))
85+
.to_str()
86+
.unwrap(),
87+
Path::new(".")
88+
.join(get_file_name(&bootstrap_host_compiler.rustc, "raytracer_cg_clif_opt", "bin"))
89+
.to_str()
90+
.unwrap(),
8191
],
8292
);
8393
bench_run.current_dir(RelPath::BUILD.to_path(dirs));

build_system/build_backend.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ pub(crate) fn build_backend(
5252
.target_dir(dirs)
5353
.join(&bootstrap_host_compiler.triple)
5454
.join(channel)
55-
.join(get_file_name("rustc_codegen_cranelift", "dylib"))
55+
.join(get_file_name(&bootstrap_host_compiler.rustc, "rustc_codegen_cranelift", "dylib"))
5656
}

build_system/build_sysroot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub(crate) fn build_sysroot(
4040
try_hard_link(cg_clif_dylib_src, &cg_clif_dylib_path);
4141

4242
// Build and copy rustc and cargo wrappers
43-
let wrapper_base_name = get_file_name("____", "bin");
43+
let wrapper_base_name = get_file_name(&bootstrap_host_compiler.rustc, "____", "bin");
4444
let toolchain_name = get_toolchain_name();
4545
for wrapper in ["rustc-clif", "rustdoc-clif", "cargo-clif"] {
4646
let wrapper_name = wrapper_base_name.replace("____", wrapper);

build_system/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::env;
2-
use std::path::PathBuf;
2+
use std::path::{Path, PathBuf};
33
use std::process;
44

55
use self::utils::{is_ci, is_ci_opt, Compiler};
@@ -105,7 +105,7 @@ pub(crate) fn main() {
105105
std::env::var("HOST_TRIPLE")
106106
.ok()
107107
.or_else(|| config::get_value("host"))
108-
.unwrap_or_else(|| rustc_info::get_host_triple()),
108+
.unwrap_or_else(|| rustc_info::get_host_triple(Path::new("rustc"))),
109109
);
110110
let target_triple = std::env::var("TARGET_TRIPLE")
111111
.ok()
@@ -187,7 +187,7 @@ pub(crate) fn main() {
187187
&bootstrap_host_compiler,
188188
target_triple,
189189
);
190-
bench::benchmark(&dirs);
190+
bench::benchmark(&dirs, &bootstrap_host_compiler);
191191
}
192192
}
193193
}

build_system/rustc_info.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ pub(crate) fn get_rustc_version(rustc: &Path) -> String {
77
String::from_utf8(version_info).unwrap()
88
}
99

10-
pub(crate) fn get_host_triple() -> String {
10+
pub(crate) fn get_host_triple(rustc: &Path) -> String {
1111
let version_info =
12-
Command::new("rustc").stderr(Stdio::inherit()).args(&["-vV"]).output().unwrap().stdout;
12+
Command::new(rustc).stderr(Stdio::inherit()).args(&["-vV"]).output().unwrap().stdout;
1313
String::from_utf8(version_info)
1414
.unwrap()
1515
.lines()
@@ -73,8 +73,8 @@ pub(crate) fn get_default_sysroot(rustc: &Path) -> PathBuf {
7373
Path::new(String::from_utf8(default_sysroot).unwrap().trim()).to_owned()
7474
}
7575

76-
pub(crate) fn get_file_name(crate_name: &str, crate_type: &str) -> String {
77-
let file_name = Command::new("rustc")
76+
pub(crate) fn get_file_name(rustc: &Path, crate_name: &str, crate_type: &str) -> String {
77+
let file_name = Command::new(rustc)
7878
.stderr(Stdio::inherit())
7979
.args(&[
8080
"--crate-name",

0 commit comments

Comments
 (0)