Skip to content

Commit bbb7a3b

Browse files
committed
Rename Compiler variables for clarity
1 parent fd1e824 commit bbb7a3b

File tree

7 files changed

+54
-41
lines changed

7 files changed

+54
-41
lines changed

build_system/abi_cafe.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub(crate) fn run(
1818
sysroot_kind: SysrootKind,
1919
dirs: &Dirs,
2020
cg_clif_dylib: &Path,
21-
host_compiler: &Compiler,
21+
bootstrap_host_compiler: &Compiler,
2222
) {
2323
if !config::get_bool("testsuite.abi-cafe") {
2424
eprintln!("[RUN] abi-cafe (skipped)");
@@ -31,15 +31,15 @@ pub(crate) fn run(
3131
channel,
3232
sysroot_kind,
3333
cg_clif_dylib,
34-
host_compiler,
35-
&host_compiler.triple,
34+
bootstrap_host_compiler,
35+
&bootstrap_host_compiler.triple,
3636
);
3737

3838
eprintln!("Running abi-cafe");
3939

4040
let pairs = ["rustc_calls_cgclif", "cgclif_calls_rustc", "cgclif_calls_cc", "cc_calls_cgclif"];
4141

42-
let mut cmd = ABI_CAFE.run(host_compiler, dirs);
42+
let mut cmd = ABI_CAFE.run(bootstrap_host_compiler, dirs);
4343
cmd.arg("--");
4444
cmd.arg("--pairs");
4545
cmd.args(pairs);

build_system/bench.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,24 @@ pub(crate) static SIMPLE_RAYTRACER_LLVM: CargoProject =
2121
pub(crate) static SIMPLE_RAYTRACER: CargoProject =
2222
CargoProject::new(&SIMPLE_RAYTRACER_REPO.source_dir(), "simple_raytracer");
2323

24-
pub(crate) fn benchmark(dirs: &Dirs, host_compiler: &Compiler) {
25-
benchmark_simple_raytracer(dirs, host_compiler);
24+
pub(crate) fn benchmark(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
25+
benchmark_simple_raytracer(dirs, bootstrap_host_compiler);
2626
}
2727

28-
fn benchmark_simple_raytracer(dirs: &Dirs, host_compiler: &Compiler) {
28+
fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
2929
if std::process::Command::new("hyperfine").output().is_err() {
3030
eprintln!("Hyperfine not installed");
3131
eprintln!("Hint: Try `cargo install hyperfine` to install hyperfine");
3232
std::process::exit(1);
3333
}
3434

3535
eprintln!("[LLVM BUILD] simple-raytracer");
36-
let build_cmd = SIMPLE_RAYTRACER_LLVM.build(host_compiler, dirs);
36+
let build_cmd = SIMPLE_RAYTRACER_LLVM.build(bootstrap_host_compiler, dirs);
3737
spawn_and_wait(build_cmd);
3838
fs::copy(
3939
SIMPLE_RAYTRACER_LLVM
4040
.target_dir(dirs)
41-
.join(&host_compiler.triple)
41+
.join(&bootstrap_host_compiler.triple)
4242
.join("debug")
4343
.join(get_file_name("main", "bin")),
4444
RelPath::BUILD.to_path(dirs).join(get_file_name("raytracer_cg_llvm", "bin")),

build_system/build_backend.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ pub(crate) static CG_CLIF: CargoProject = CargoProject::new(&RelPath::SOURCE, "c
1010
pub(crate) fn build_backend(
1111
dirs: &Dirs,
1212
channel: &str,
13-
host_compiler: &Compiler,
13+
bootstrap_host_compiler: &Compiler,
1414
use_unstable_features: bool,
1515
) -> PathBuf {
16-
let mut cmd = CG_CLIF.build(&host_compiler, dirs);
16+
let mut cmd = CG_CLIF.build(&bootstrap_host_compiler, dirs);
1717

1818
cmd.env("CARGO_BUILD_INCREMENTAL", "true"); // Force incr comp even in release mode
1919

@@ -48,7 +48,7 @@ pub(crate) fn build_backend(
4848

4949
CG_CLIF
5050
.target_dir(dirs)
51-
.join(&host_compiler.triple)
51+
.join(&bootstrap_host_compiler.triple)
5252
.join(channel)
5353
.join(get_file_name("rustc_codegen_cranelift", "dylib"))
5454
}

build_system/build_sysroot.rs

+15-10
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(crate) fn build_sysroot(
1717
channel: &str,
1818
sysroot_kind: SysrootKind,
1919
cg_clif_dylib_src: &Path,
20-
host_compiler: &Compiler,
20+
bootstrap_host_compiler: &Compiler,
2121
target_triple: &str,
2222
) {
2323
eprintln!("[BUILD] sysroot {:?}", sysroot_kind);
@@ -53,7 +53,8 @@ pub(crate) fn build_sysroot(
5353

5454
let default_sysroot = super::rustc_info::get_default_sysroot();
5555

56-
let host_rustlib_lib = RUSTLIB_DIR.to_path(dirs).join(&host_compiler.triple).join("lib");
56+
let host_rustlib_lib =
57+
RUSTLIB_DIR.to_path(dirs).join(&bootstrap_host_compiler.triple).join("lib");
5758
let target_rustlib_lib = RUSTLIB_DIR.to_path(dirs).join(target_triple).join("lib");
5859
fs::create_dir_all(&host_rustlib_lib).unwrap();
5960
fs::create_dir_all(&target_rustlib_lib).unwrap();
@@ -83,7 +84,11 @@ pub(crate) fn build_sysroot(
8384
SysrootKind::None => {} // Nothing to do
8485
SysrootKind::Llvm => {
8586
for file in fs::read_dir(
86-
default_sysroot.join("lib").join("rustlib").join(&host_compiler.triple).join("lib"),
87+
default_sysroot
88+
.join("lib")
89+
.join("rustlib")
90+
.join(&bootstrap_host_compiler.triple)
91+
.join("lib"),
8792
)
8893
.unwrap()
8994
{
@@ -103,7 +108,7 @@ pub(crate) fn build_sysroot(
103108
try_hard_link(&file, host_rustlib_lib.join(file.file_name().unwrap()));
104109
}
105110

106-
if target_triple != host_compiler.triple {
111+
if target_triple != bootstrap_host_compiler.triple {
107112
for file in fs::read_dir(
108113
default_sysroot.join("lib").join("rustlib").join(target_triple).join("lib"),
109114
)
@@ -118,19 +123,19 @@ pub(crate) fn build_sysroot(
118123
build_clif_sysroot_for_triple(
119124
dirs,
120125
channel,
121-
host_compiler.clone(),
126+
bootstrap_host_compiler.clone(),
122127
&cg_clif_dylib_path,
123128
);
124129

125-
if host_compiler.triple != target_triple {
130+
if bootstrap_host_compiler.triple != target_triple {
126131
build_clif_sysroot_for_triple(
127132
dirs,
128133
channel,
129134
{
130-
let mut target_compiler = host_compiler.clone();
131-
target_compiler.triple = target_triple.to_owned();
132-
target_compiler.set_cross_linker_and_runner();
133-
target_compiler
135+
let mut bootstrap_target_compiler = bootstrap_host_compiler.clone();
136+
bootstrap_target_compiler.triple = target_triple.to_owned();
137+
bootstrap_target_compiler.set_cross_linker_and_runner();
138+
bootstrap_target_compiler
134139
},
135140
&cg_clif_dylib_path,
136141
);

build_system/mod.rs

+20-10
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub fn main() {
9797
}
9898
}
9999

100-
let host_compiler = Compiler::llvm_with_triple(
100+
let bootstrap_host_compiler = Compiler::bootstrap_with_triple(
101101
std::env::var("HOST_TRIPLE")
102102
.ok()
103103
.or_else(|| config::get_value("host"))
@@ -106,7 +106,7 @@ pub fn main() {
106106
let target_triple = std::env::var("TARGET_TRIPLE")
107107
.ok()
108108
.or_else(|| config::get_value("target"))
109-
.unwrap_or_else(|| host_compiler.triple.clone());
109+
.unwrap_or_else(|| bootstrap_host_compiler.triple.clone());
110110

111111
// FIXME allow changing the location of these dirs using cli arguments
112112
let current_dir = std::env::current_dir().unwrap();
@@ -137,8 +137,12 @@ pub fn main() {
137137
env::set_var("RUSTC", "rustc_should_be_set_explicitly");
138138
env::set_var("RUSTDOC", "rustdoc_should_be_set_explicitly");
139139

140-
let cg_clif_dylib =
141-
build_backend::build_backend(&dirs, channel, &host_compiler, use_unstable_features);
140+
let cg_clif_dylib = build_backend::build_backend(
141+
&dirs,
142+
channel,
143+
&bootstrap_host_compiler,
144+
use_unstable_features,
145+
);
142146
match command {
143147
Command::Prepare => {
144148
// Handled above
@@ -149,12 +153,18 @@ pub fn main() {
149153
channel,
150154
sysroot_kind,
151155
&cg_clif_dylib,
152-
&host_compiler,
156+
&bootstrap_host_compiler,
153157
&target_triple,
154158
);
155159

156-
if host_compiler.triple == target_triple {
157-
abi_cafe::run(channel, sysroot_kind, &dirs, &cg_clif_dylib, &host_compiler);
160+
if bootstrap_host_compiler.triple == target_triple {
161+
abi_cafe::run(
162+
channel,
163+
sysroot_kind,
164+
&dirs,
165+
&cg_clif_dylib,
166+
&bootstrap_host_compiler,
167+
);
158168
} else {
159169
eprintln!("[RUN] abi-cafe (skipped, cross-compilation not supported)");
160170
return;
@@ -166,7 +176,7 @@ pub fn main() {
166176
channel,
167177
sysroot_kind,
168178
&cg_clif_dylib,
169-
&host_compiler,
179+
&bootstrap_host_compiler,
170180
&target_triple,
171181
);
172182
}
@@ -176,10 +186,10 @@ pub fn main() {
176186
channel,
177187
sysroot_kind,
178188
&cg_clif_dylib,
179-
&host_compiler,
189+
&bootstrap_host_compiler,
180190
&target_triple,
181191
);
182-
bench::benchmark(&dirs, &host_compiler);
192+
bench::benchmark(&dirs, &bootstrap_host_compiler);
183193
}
184194
}
185195
}

build_system/tests.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use super::build_sysroot::{self, SYSROOT_SRC};
33
use super::config;
44
use super::path::{Dirs, RelPath};
55
use super::prepare::GitRepo;
6+
use super::rustc_info::get_host_triple;
67
use super::utils::{spawn_and_wait, spawn_and_wait_with_input, CargoProject, Compiler};
78
use super::SysrootKind;
89
use std::env;
@@ -240,22 +241,19 @@ pub(crate) fn run_tests(
240241
channel: &str,
241242
sysroot_kind: SysrootKind,
242243
cg_clif_dylib: &Path,
243-
host_compiler: &Compiler,
244+
bootstrap_host_compiler: &Compiler,
244245
target_triple: &str,
245246
) {
246-
let runner = TestRunner::new(
247-
dirs.clone(),
248-
target_triple.to_owned(),
249-
host_compiler.triple == target_triple,
250-
);
247+
let runner =
248+
TestRunner::new(dirs.clone(), target_triple.to_owned(), get_host_triple() == target_triple);
251249

252250
if config::get_bool("testsuite.no_sysroot") {
253251
build_sysroot::build_sysroot(
254252
dirs,
255253
channel,
256254
SysrootKind::None,
257255
cg_clif_dylib,
258-
host_compiler,
256+
bootstrap_host_compiler,
259257
&target_triple,
260258
);
261259

@@ -274,7 +272,7 @@ pub(crate) fn run_tests(
274272
channel,
275273
sysroot_kind,
276274
cg_clif_dylib,
277-
host_compiler,
275+
bootstrap_host_compiler,
278276
&target_triple,
279277
);
280278
}

build_system/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(crate) struct Compiler {
1919
}
2020

2121
impl Compiler {
22-
pub(crate) fn llvm_with_triple(triple: String) -> Compiler {
22+
pub(crate) fn bootstrap_with_triple(triple: String) -> Compiler {
2323
Compiler {
2424
cargo: get_cargo_path(),
2525
rustc: get_rustc_path(),

0 commit comments

Comments
 (0)