]> git.lizzy.rs Git - rust.git/commitdiff
Rename Compiler variables for clarity
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>
Sat, 14 Jan 2023 12:53:33 +0000 (12:53 +0000)
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>
Sat, 14 Jan 2023 14:18:11 +0000 (14:18 +0000)
build_system/abi_cafe.rs
build_system/bench.rs
build_system/build_backend.rs
build_system/build_sysroot.rs
build_system/mod.rs
build_system/tests.rs
build_system/utils.rs

index 1b4c7c9da214087e7369626016ac4a5d11b6b3fe..8352c1a965a75d8b9447079363d365730531081a 100644 (file)
@@ -18,7 +18,7 @@ pub(crate) fn run(
     sysroot_kind: SysrootKind,
     dirs: &Dirs,
     cg_clif_dylib: &Path,
-    host_compiler: &Compiler,
+    bootstrap_host_compiler: &Compiler,
 ) {
     if !config::get_bool("testsuite.abi-cafe") {
         eprintln!("[RUN] abi-cafe (skipped)");
@@ -31,15 +31,15 @@ pub(crate) fn run(
         channel,
         sysroot_kind,
         cg_clif_dylib,
-        host_compiler,
-        &host_compiler.triple,
+        bootstrap_host_compiler,
+        &bootstrap_host_compiler.triple,
     );
 
     eprintln!("Running abi-cafe");
 
     let pairs = ["rustc_calls_cgclif", "cgclif_calls_rustc", "cgclif_calls_cc", "cc_calls_cgclif"];
 
-    let mut cmd = ABI_CAFE.run(host_compiler, dirs);
+    let mut cmd = ABI_CAFE.run(bootstrap_host_compiler, dirs);
     cmd.arg("--");
     cmd.arg("--pairs");
     cmd.args(pairs);
index f5c5d92cb328679b7fe9ae53c01e4f5b772706e0..1e83f21ba577b8bf870b77792ecc2094beee0294 100644 (file)
 pub(crate) static SIMPLE_RAYTRACER: CargoProject =
     CargoProject::new(&SIMPLE_RAYTRACER_REPO.source_dir(), "simple_raytracer");
 
-pub(crate) fn benchmark(dirs: &Dirs, host_compiler: &Compiler) {
-    benchmark_simple_raytracer(dirs, host_compiler);
+pub(crate) fn benchmark(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
+    benchmark_simple_raytracer(dirs, bootstrap_host_compiler);
 }
 
-fn benchmark_simple_raytracer(dirs: &Dirs, host_compiler: &Compiler) {
+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");
@@ -33,12 +33,12 @@ fn benchmark_simple_raytracer(dirs: &Dirs, host_compiler: &Compiler) {
     }
 
     eprintln!("[LLVM BUILD] simple-raytracer");
-    let build_cmd = SIMPLE_RAYTRACER_LLVM.build(host_compiler, dirs);
+    let build_cmd = SIMPLE_RAYTRACER_LLVM.build(bootstrap_host_compiler, dirs);
     spawn_and_wait(build_cmd);
     fs::copy(
         SIMPLE_RAYTRACER_LLVM
             .target_dir(dirs)
-            .join(&host_compiler.triple)
+            .join(&bootstrap_host_compiler.triple)
             .join("debug")
             .join(get_file_name("main", "bin")),
         RelPath::BUILD.to_path(dirs).join(get_file_name("raytracer_cg_llvm", "bin")),
index 6ab39e48f214f11febd63b3c0a94e3981c3690e8..514404305a3fa0416635e45dc7ad0b9a6a34357a 100644 (file)
 pub(crate) fn build_backend(
     dirs: &Dirs,
     channel: &str,
-    host_compiler: &Compiler,
+    bootstrap_host_compiler: &Compiler,
     use_unstable_features: bool,
 ) -> PathBuf {
-    let mut cmd = CG_CLIF.build(&host_compiler, dirs);
+    let mut cmd = CG_CLIF.build(&bootstrap_host_compiler, dirs);
 
     cmd.env("CARGO_BUILD_INCREMENTAL", "true"); // Force incr comp even in release mode
 
@@ -48,7 +48,7 @@ pub(crate) fn build_backend(
 
     CG_CLIF
         .target_dir(dirs)
-        .join(&host_compiler.triple)
+        .join(&bootstrap_host_compiler.triple)
         .join(channel)
         .join(get_file_name("rustc_codegen_cranelift", "dylib"))
 }
index b7228968f631307ab0d90157cc4ac57c941aaa58..92d01750fab00e6da9e6a7c7c725495cc4e8f87b 100644 (file)
@@ -17,7 +17,7 @@ pub(crate) fn build_sysroot(
     channel: &str,
     sysroot_kind: SysrootKind,
     cg_clif_dylib_src: &Path,
-    host_compiler: &Compiler,
+    bootstrap_host_compiler: &Compiler,
     target_triple: &str,
 ) {
     eprintln!("[BUILD] sysroot {:?}", sysroot_kind);
@@ -53,7 +53,8 @@ pub(crate) fn build_sysroot(
 
     let default_sysroot = super::rustc_info::get_default_sysroot();
 
-    let host_rustlib_lib = RUSTLIB_DIR.to_path(dirs).join(&host_compiler.triple).join("lib");
+    let host_rustlib_lib =
+        RUSTLIB_DIR.to_path(dirs).join(&bootstrap_host_compiler.triple).join("lib");
     let target_rustlib_lib = RUSTLIB_DIR.to_path(dirs).join(target_triple).join("lib");
     fs::create_dir_all(&host_rustlib_lib).unwrap();
     fs::create_dir_all(&target_rustlib_lib).unwrap();
@@ -83,7 +84,11 @@ pub(crate) fn build_sysroot(
         SysrootKind::None => {} // Nothing to do
         SysrootKind::Llvm => {
             for file in fs::read_dir(
-                default_sysroot.join("lib").join("rustlib").join(&host_compiler.triple).join("lib"),
+                default_sysroot
+                    .join("lib")
+                    .join("rustlib")
+                    .join(&bootstrap_host_compiler.triple)
+                    .join("lib"),
             )
             .unwrap()
             {
@@ -103,7 +108,7 @@ pub(crate) fn build_sysroot(
                 try_hard_link(&file, host_rustlib_lib.join(file.file_name().unwrap()));
             }
 
-            if target_triple != host_compiler.triple {
+            if target_triple != bootstrap_host_compiler.triple {
                 for file in fs::read_dir(
                     default_sysroot.join("lib").join("rustlib").join(target_triple).join("lib"),
                 )
@@ -118,19 +123,19 @@ pub(crate) fn build_sysroot(
             build_clif_sysroot_for_triple(
                 dirs,
                 channel,
-                host_compiler.clone(),
+                bootstrap_host_compiler.clone(),
                 &cg_clif_dylib_path,
             );
 
-            if host_compiler.triple != target_triple {
+            if bootstrap_host_compiler.triple != target_triple {
                 build_clif_sysroot_for_triple(
                     dirs,
                     channel,
                     {
-                        let mut target_compiler = host_compiler.clone();
-                        target_compiler.triple = target_triple.to_owned();
-                        target_compiler.set_cross_linker_and_runner();
-                        target_compiler
+                        let mut bootstrap_target_compiler = bootstrap_host_compiler.clone();
+                        bootstrap_target_compiler.triple = target_triple.to_owned();
+                        bootstrap_target_compiler.set_cross_linker_and_runner();
+                        bootstrap_target_compiler
                     },
                     &cg_clif_dylib_path,
                 );
index 265416c48fcca2b47086c19597b3e579fd56ef3a..910213be85e2cda8c1405d5f4029f3c6bba54764 100644 (file)
@@ -97,7 +97,7 @@ pub fn main() {
         }
     }
 
-    let host_compiler = Compiler::llvm_with_triple(
+    let bootstrap_host_compiler = Compiler::bootstrap_with_triple(
         std::env::var("HOST_TRIPLE")
             .ok()
             .or_else(|| config::get_value("host"))
@@ -106,7 +106,7 @@ pub fn main() {
     let target_triple = std::env::var("TARGET_TRIPLE")
         .ok()
         .or_else(|| config::get_value("target"))
-        .unwrap_or_else(|| host_compiler.triple.clone());
+        .unwrap_or_else(|| bootstrap_host_compiler.triple.clone());
 
     // FIXME allow changing the location of these dirs using cli arguments
     let current_dir = std::env::current_dir().unwrap();
@@ -137,8 +137,12 @@ pub fn main() {
     env::set_var("RUSTC", "rustc_should_be_set_explicitly");
     env::set_var("RUSTDOC", "rustdoc_should_be_set_explicitly");
 
-    let cg_clif_dylib =
-        build_backend::build_backend(&dirs, channel, &host_compiler, use_unstable_features);
+    let cg_clif_dylib = build_backend::build_backend(
+        &dirs,
+        channel,
+        &bootstrap_host_compiler,
+        use_unstable_features,
+    );
     match command {
         Command::Prepare => {
             // Handled above
@@ -149,12 +153,18 @@ pub fn main() {
                 channel,
                 sysroot_kind,
                 &cg_clif_dylib,
-                &host_compiler,
+                &bootstrap_host_compiler,
                 &target_triple,
             );
 
-            if host_compiler.triple == target_triple {
-                abi_cafe::run(channel, sysroot_kind, &dirs, &cg_clif_dylib, &host_compiler);
+            if bootstrap_host_compiler.triple == target_triple {
+                abi_cafe::run(
+                    channel,
+                    sysroot_kind,
+                    &dirs,
+                    &cg_clif_dylib,
+                    &bootstrap_host_compiler,
+                );
             } else {
                 eprintln!("[RUN] abi-cafe (skipped, cross-compilation not supported)");
                 return;
@@ -166,7 +176,7 @@ pub fn main() {
                 channel,
                 sysroot_kind,
                 &cg_clif_dylib,
-                &host_compiler,
+                &bootstrap_host_compiler,
                 &target_triple,
             );
         }
@@ -176,10 +186,10 @@ pub fn main() {
                 channel,
                 sysroot_kind,
                 &cg_clif_dylib,
-                &host_compiler,
+                &bootstrap_host_compiler,
                 &target_triple,
             );
-            bench::benchmark(&dirs, &host_compiler);
+            bench::benchmark(&dirs, &bootstrap_host_compiler);
         }
     }
 }
index 6c4d0e2e35e7da3b1632f0d8021823e23b145431..e915ed2a381d5d01ecc301ecadf8bb251d5e2a01 100644 (file)
@@ -3,6 +3,7 @@
 use super::config;
 use super::path::{Dirs, RelPath};
 use super::prepare::GitRepo;
+use super::rustc_info::get_host_triple;
 use super::utils::{spawn_and_wait, spawn_and_wait_with_input, CargoProject, Compiler};
 use super::SysrootKind;
 use std::env;
@@ -240,14 +241,11 @@ pub(crate) fn run_tests(
     channel: &str,
     sysroot_kind: SysrootKind,
     cg_clif_dylib: &Path,
-    host_compiler: &Compiler,
+    bootstrap_host_compiler: &Compiler,
     target_triple: &str,
 ) {
-    let runner = TestRunner::new(
-        dirs.clone(),
-        target_triple.to_owned(),
-        host_compiler.triple == target_triple,
-    );
+    let runner =
+        TestRunner::new(dirs.clone(), target_triple.to_owned(), get_host_triple() == target_triple);
 
     if config::get_bool("testsuite.no_sysroot") {
         build_sysroot::build_sysroot(
@@ -255,7 +253,7 @@ pub(crate) fn run_tests(
             channel,
             SysrootKind::None,
             cg_clif_dylib,
-            host_compiler,
+            bootstrap_host_compiler,
             &target_triple,
         );
 
@@ -274,7 +272,7 @@ pub(crate) fn run_tests(
             channel,
             sysroot_kind,
             cg_clif_dylib,
-            host_compiler,
+            bootstrap_host_compiler,
             &target_triple,
         );
     }
index 935177a00ba87f8d43b795879f7bc6baa4baf821..07ea482fbbeaa07e4d0d5128bcc7793fade8962e 100644 (file)
@@ -19,7 +19,7 @@ pub(crate) struct Compiler {
 }
 
 impl Compiler {
-    pub(crate) fn llvm_with_triple(triple: String) -> Compiler {
+    pub(crate) fn bootstrap_with_triple(triple: String) -> Compiler {
         Compiler {
             cargo: get_cargo_path(),
             rustc: get_rustc_path(),