Skip to content

Commit 53f8a7b

Browse files
committed
Make it clearer what exactly is being benchmarked
1 parent 0670b60 commit 53f8a7b

File tree

4 files changed

+35
-23
lines changed

4 files changed

+35
-23
lines changed

build_system/bench.rs

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,46 @@ pub(crate) fn benchmark(dirs: &Dirs, compiler: &Compiler) {
3939
let rustc_clif = &compiler.rustc;
4040
let rustflags = &compiler.rustflags.join("\x1f");
4141
let manifest_path = SIMPLE_RAYTRACER_REPO.source_dir().to_path(dirs).join("Cargo.toml");
42-
let target_dir = dirs.build_dir.join("simple_raytracer");
42+
let target_dir = dirs.build_dir.join("simple-raytracer_target");
43+
44+
let raytracer_cg_llvm = dirs
45+
.build_dir
46+
.join(get_file_name(&compiler.rustc, "raytracer_cg_llvm", "bin"))
47+
.to_str()
48+
.unwrap()
49+
.to_owned();
50+
let raytracer_cg_clif = dirs
51+
.build_dir
52+
.join(get_file_name(&compiler.rustc, "raytracer_cg_clif", "bin"))
53+
.to_str()
54+
.unwrap()
55+
.to_owned();
56+
let raytracer_cg_clif_opt = dirs
57+
.build_dir
58+
.join(get_file_name(&compiler.rustc, "raytracer_cg_clif_opt", "bin"))
59+
.to_str()
60+
.unwrap()
61+
.to_owned();
4362

4463
let clean_cmd = format!(
4564
"RUSTC=rustc cargo clean --manifest-path {manifest_path} --target-dir {target_dir}",
4665
manifest_path = manifest_path.display(),
4766
target_dir = target_dir.display(),
4867
);
4968
let llvm_build_cmd = format!(
50-
"RUSTC=rustc cargo build --manifest-path {manifest_path} --target-dir {target_dir} && (rm build/raytracer_cg_llvm || true) && ln build/simple_raytracer/debug/main build/raytracer_cg_llvm",
69+
"RUSTC=rustc cargo build --manifest-path {manifest_path} --target-dir {target_dir} && (rm {raytracer_cg_llvm} || true) && ln {target_dir}/debug/main {raytracer_cg_llvm}",
5170
manifest_path = manifest_path.display(),
5271
target_dir = target_dir.display(),
5372
);
5473
let clif_build_cmd = format!(
55-
"RUSTC={rustc_clif} CARGO_ENCODED_RUSTFLAGS=\"{rustflags}\" {cargo_clif} build --manifest-path {manifest_path} --target-dir {target_dir} && (rm build/raytracer_cg_clif || true) && ln build/simple_raytracer/debug/main build/raytracer_cg_clif",
74+
"RUSTC={rustc_clif} CARGO_ENCODED_RUSTFLAGS=\"{rustflags}\" {cargo_clif} build --manifest-path {manifest_path} --target-dir {target_dir} && (rm {raytracer_cg_clif} || true) && ln {target_dir}/debug/main {raytracer_cg_clif}",
5675
cargo_clif = cargo_clif.display(),
5776
rustc_clif = rustc_clif.display(),
5877
manifest_path = manifest_path.display(),
5978
target_dir = target_dir.display(),
6079
);
6180
let clif_build_opt_cmd = format!(
62-
"RUSTC={rustc_clif} CARGO_ENCODED_RUSTFLAGS=\"{rustflags}\" {cargo_clif} build --manifest-path {manifest_path} --target-dir {target_dir} --release && (rm build/raytracer_cg_clif_opt || true) && ln build/simple_raytracer/release/main build/raytracer_cg_clif_opt",
81+
"RUSTC={rustc_clif} CARGO_ENCODED_RUSTFLAGS=\"{rustflags}\" CARGO_BUILD_INCREMENTAL=true {cargo_clif} build --manifest-path {manifest_path} --target-dir {target_dir} --release && (rm {raytracer_cg_clif_opt} || true) && ln {target_dir}/release/main {raytracer_cg_clif_opt}",
6382
cargo_clif = cargo_clif.display(),
6483
rustc_clif = rustc_clif.display(),
6584
manifest_path = manifest_path.display(),
@@ -92,24 +111,13 @@ pub(crate) fn benchmark(dirs: &Dirs, compiler: &Compiler) {
92111

93112
let bench_run_markdown = dirs.build_dir.join("bench_run.md");
94113

95-
let raytracer_cg_llvm =
96-
Path::new(".").join(get_file_name(&compiler.rustc, "raytracer_cg_llvm", "bin"));
97-
let raytracer_cg_clif =
98-
Path::new(".").join(get_file_name(&compiler.rustc, "raytracer_cg_clif", "bin"));
99-
let raytracer_cg_clif_opt =
100-
Path::new(".").join(get_file_name(&compiler.rustc, "raytracer_cg_clif_opt", "bin"));
101-
let mut bench_run = hyperfine_command(
114+
let bench_run = hyperfine_command(
102115
0,
103116
bench_runs,
104117
None,
105-
&[
106-
("", raytracer_cg_llvm.to_str().unwrap()),
107-
("", raytracer_cg_clif.to_str().unwrap()),
108-
("", raytracer_cg_clif_opt.to_str().unwrap()),
109-
],
118+
&[("", &raytracer_cg_llvm), ("", &raytracer_cg_clif), ("", &raytracer_cg_clif_opt)],
110119
&bench_run_markdown,
111120
);
112-
bench_run.current_dir(&dirs.build_dir);
113121
spawn_and_wait(bench_run);
114122

115123
if let Some(gha_step_summary) = gha_step_summary.as_mut() {

build_system/build_backend.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ pub(crate) fn build_backend(
2222
rustflags.push("-Zallow-features=rustc_private,f16,f128".to_owned());
2323
rustflags_to_cmd_env(&mut cmd, "RUSTFLAGS", &rustflags);
2424

25+
// Use incr comp despite release mode unless incremental builds are explicitly disabled
26+
if env::var_os("CARGO_BUILD_INCREMENTAL").is_none() {
27+
cmd.env("CARGO_BUILD_INCREMENTAL", "true");
28+
}
29+
2530
if env::var("CG_CLIF_EXPENSIVE_CHECKS").is_ok() {
2631
// Enabling debug assertions implicitly enables the clif ir verifier
2732
cmd.env("CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS", "true");

build_system/build_sysroot.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ fn build_clif_sysroot_for_triple(
234234
if compiler.triple.contains("apple") {
235235
build_cmd.env("CARGO_PROFILE_RELEASE_SPLIT_DEBUGINFO", "packed");
236236
}
237+
// Use incr comp despite release mode unless incremental builds are explicitly disabled
238+
if env::var_os("CARGO_BUILD_INCREMENTAL").is_none() {
239+
build_cmd.env("CARGO_BUILD_INCREMENTAL", "true");
240+
}
237241
spawn_and_wait(build_cmd);
238242

239243
for entry in fs::read_dir(build_dir.join("deps")).unwrap() {

build_system/main.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ fn main() {
5959
}
6060
env::set_var("CG_CLIF_DISABLE_INCR_CACHE", "1");
6161

62-
// Force incr comp even in release mode unless in CI or incremental builds are explicitly disabled
63-
if env::var_os("CARGO_BUILD_INCREMENTAL").is_none() {
64-
env::set_var("CARGO_BUILD_INCREMENTAL", "true");
65-
}
66-
6762
let mut args = env::args().skip(1);
6863
let command = match args.next().as_deref() {
6964
Some("prepare") => Command::Prepare,
@@ -79,7 +74,7 @@ fn main() {
7974
}
8075
};
8176

82-
let mut out_dir = PathBuf::from(".");
77+
let mut out_dir = std::env::current_dir().unwrap();
8378
let mut download_dir = None;
8479
let mut sysroot_kind = SysrootKind::Clif;
8580
let mut use_unstable_features = true;

0 commit comments

Comments
 (0)