about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-01-13 11:41:40 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-01-13 11:41:40 +0000
commitdbfbb29717dbaf94b3e83a30e4b9104241471dca (patch)
treef6c91e588b258c83ce538dd91253f9995496d64f
parent868638393eb79bf53ba00be6000930f9ecf8751e (diff)
downloadrust-dbfbb29717dbaf94b3e83a30e4b9104241471dca.tar.gz
rust-dbfbb29717dbaf94b3e83a30e4b9104241471dca.zip
Move LLVM simple-raytracer build to ./y.rs bench
cc #1290
-rw-r--r--build_system/bench.rs20
-rw-r--r--build_system/prepare.rs18
2 files changed, 21 insertions, 17 deletions
diff --git a/build_system/bench.rs b/build_system/bench.rs
index 0ad8863223d..e0956cb44ba 100644
--- a/build_system/bench.rs
+++ b/build_system/bench.rs
@@ -5,7 +5,7 @@ use std::path::Path;
 use super::path::{Dirs, RelPath};
 use super::prepare::GitRepo;
 use super::rustc_info::{get_file_name, get_wrapper_file_name};
-use super::utils::{hyperfine_command, is_ci, spawn_and_wait, CargoProject};
+use super::utils::{hyperfine_command, is_ci, spawn_and_wait, CargoProject, Compiler};
 
 pub(crate) static SIMPLE_RAYTRACER_REPO: GitRepo = GitRepo::github(
     "ebobby",
@@ -14,6 +14,10 @@ pub(crate) static SIMPLE_RAYTRACER_REPO: GitRepo = GitRepo::github(
     "<none>",
 );
 
+// Use a separate target dir for the initial LLVM build to reduce unnecessary recompiles
+pub(crate) static SIMPLE_RAYTRACER_LLVM: CargoProject =
+    CargoProject::new(&SIMPLE_RAYTRACER_REPO.source_dir(), "simple_raytracer_llvm");
+
 pub(crate) static SIMPLE_RAYTRACER: CargoProject =
     CargoProject::new(&SIMPLE_RAYTRACER_REPO.source_dir(), "simple_raytracer");
 
@@ -28,6 +32,20 @@ fn benchmark_simple_raytracer(dirs: &Dirs) {
         std::process::exit(1);
     }
 
+    eprintln!("[LLVM BUILD] simple-raytracer");
+    let host_compiler = Compiler::host();
+    let build_cmd = SIMPLE_RAYTRACER_LLVM.build(&host_compiler, dirs);
+    spawn_and_wait(build_cmd);
+    fs::copy(
+        SIMPLE_RAYTRACER_LLVM
+            .target_dir(dirs)
+            .join(&host_compiler.triple)
+            .join("debug")
+            .join(get_file_name("main", "bin")),
+        RelPath::BUILD.to_path(dirs).join(get_file_name("raytracer_cg_llvm", "bin")),
+    )
+    .unwrap();
+
     let run_runs = env::var("RUN_RUNS")
         .unwrap_or(if is_ci() { "2" } else { "10" }.to_string())
         .parse()
diff --git a/build_system/prepare.rs b/build_system/prepare.rs
index 106b06296b4..4c92987ba5b 100644
--- a/build_system/prepare.rs
+++ b/build_system/prepare.rs
@@ -7,8 +7,8 @@ use crate::build_system::rustc_info::get_default_sysroot;
 
 use super::build_sysroot::{BUILD_SYSROOT, ORIG_BUILD_SYSROOT, SYSROOT_RUSTC_VERSION, SYSROOT_SRC};
 use super::path::{Dirs, RelPath};
-use super::rustc_info::{get_file_name, get_rustc_version};
-use super::utils::{copy_dir_recursively, retry_spawn_and_wait, spawn_and_wait, Compiler};
+use super::rustc_info::get_rustc_version;
+use super::utils::{copy_dir_recursively, retry_spawn_and_wait, spawn_and_wait};
 
 pub(crate) fn prepare(dirs: &Dirs) {
     if RelPath::DOWNLOAD.to_path(dirs).exists() {
@@ -23,20 +23,6 @@ pub(crate) fn prepare(dirs: &Dirs) {
     super::tests::REGEX_REPO.fetch(dirs);
     super::tests::PORTABLE_SIMD_REPO.fetch(dirs);
     super::bench::SIMPLE_RAYTRACER_REPO.fetch(dirs);
-
-    eprintln!("[LLVM BUILD] simple-raytracer");
-    let host_compiler = Compiler::host();
-    let build_cmd = super::bench::SIMPLE_RAYTRACER.build(&host_compiler, dirs);
-    spawn_and_wait(build_cmd);
-    fs::copy(
-        super::bench::SIMPLE_RAYTRACER
-            .target_dir(dirs)
-            .join(&host_compiler.triple)
-            .join("debug")
-            .join(get_file_name("main", "bin")),
-        RelPath::BUILD.to_path(dirs).join(get_file_name("raytracer_cg_llvm", "bin")),
-    )
-    .unwrap();
 }
 
 fn prepare_sysroot(dirs: &Dirs) {