Skip to content

Commit e8168ce

Browse files
committed
Merge commit '1eded3619d0e55d57521a259bf27a03906fdfad0' into sync_cg_clif-2023-07-22
1 parent 648f5e4 commit e8168ce

30 files changed

+668
-170
lines changed

.github/workflows/main.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v3
1414

15-
- name: Install rustfmt
15+
- name: Avoid installing rustc-dev
1616
run: |
17-
rustup component add rustfmt
17+
sed -i 's/components.*/components = ["rustfmt"]/' rust-toolchain
18+
echo 'profile = "minimal"' >> rust-toolchain
19+
rustfmt -v
1820
1921
- name: Rustfmt
2022
run: |
@@ -127,7 +129,7 @@ jobs:
127129
- uses: actions/checkout@v3
128130

129131
- name: Prepare dependencies
130-
run: ./y.rs prepare
132+
run: ./y.sh prepare
131133

132134
- name: Disable JIT tests
133135
run: |
@@ -136,7 +138,7 @@ jobs:
136138
- name: Test
137139
env:
138140
TARGET_TRIPLE: x86_64-unknown-linux-gnu
139-
run: ./y.rs test --use-backend llvm
141+
run: ./y.sh test --use-backend llvm
140142

141143
bench:
142144
runs-on: ubuntu-latest

Cargo.lock

+53-31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ crate-type = ["dylib"]
88

99
[dependencies]
1010
# These have to be in sync with each other
11-
cranelift-codegen = { version = "0.96.1", features = ["unwind", "all-arch"] }
12-
cranelift-frontend = { version = "0.96.1" }
13-
cranelift-module = { version = "0.96.1" }
14-
cranelift-native = { version = "0.96.1" }
15-
cranelift-jit = { version = "0.96.1", optional = true }
16-
cranelift-object = { version = "0.96.1" }
11+
cranelift-codegen = { version = "0.98", features = ["unwind", "all-arch"] }
12+
cranelift-frontend = { version = "0.98" }
13+
cranelift-module = { version = "0.98" }
14+
cranelift-native = { version = "0.98" }
15+
cranelift-jit = { version = "0.98", optional = true }
16+
cranelift-object = { version = "0.98" }
1717
target-lexicon = "0.12.0"
1818
gimli = { version = "0.27.2", default-features = false, features = ["write"]}
1919
object = { version = "0.30.3", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }
2020

21-
indexmap = "1.9.3"
21+
indexmap = "2.0.0"
2222
libloading = { version = "0.7.3", optional = true }
2323
smallvec = "1.8.1"
2424

Readme.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ to `./build/host/stage2/bin/`. Note that you would need to do this every time yo
6565
5. Copy cargo from another toolchain: `cp $(rustup which cargo) .build/<your hostname triple>/stage2/bin/cargo`
6666
* Another option is to build it at step 3 and copy with other executables at step 4.
6767
6. Link your new `rustc` to toolchain: `rustup toolchain link stage2 ./build/host/stage2/`.
68-
7. (Windows only) compile y.rs: `rustc +stage2 -O y.rs`.
69-
8. You need to prefix every `./y.rs` (or `y` if you built `y.rs`) command by `rustup run stage2` to make cg_clif use your local changes in rustc.
68+
7. (Windows only) compile the build system: `rustc +stage2 -O build_system/main.rs -o y.exe`.
69+
8. You need to prefix every `./y.sh` (or `y` if you built `build_system/main.rs` as `y`) command by `rustup run stage2` to make cg_clif use your local changes in rustc.
7070

71-
* `rustup run stage2 ./y.rs prepare`
72-
* `rustup run stage2 ./y.rs build`
73-
* (Optional) run tests: `rustup run stage2 ./y.rs test`
71+
* `rustup run stage2 ./y.sh prepare`
72+
* `rustup run stage2 ./y.sh build`
73+
* (Optional) run tests: `rustup run stage2 ./y.sh test`
7474
9. Now you can use your cg_clif build to compile other Rust programs, e.g. you can open any Rust crate and run commands like `$RustCheckoutDir/compiler/rustc_codegen_cranelift/dist/cargo-clif build --release`.
7575

7676
## Configuration

build_system/bench.rs

+48-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::env;
2+
use std::io::Write;
23
use std::path::Path;
34

45
use super::path::{Dirs, RelPath};
@@ -30,6 +31,12 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
3031

3132
let bench_runs = env::var("BENCH_RUNS").unwrap_or_else(|_| "10".to_string()).parse().unwrap();
3233

34+
let mut gha_step_summary = if let Ok(file) = std::env::var("GITHUB_STEP_SUMMARY") {
35+
Some(std::fs::OpenOptions::new().append(true).open(file).unwrap())
36+
} else {
37+
None
38+
};
39+
3340
eprintln!("[BENCH COMPILE] ebobby/simple-raytracer");
3441
let cargo_clif = RelPath::DIST
3542
.to_path(dirs)
@@ -60,36 +67,64 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
6067
target_dir = target_dir.display(),
6168
);
6269

70+
let bench_compile_markdown = RelPath::DIST.to_path(dirs).join("bench_compile.md");
71+
6372
let bench_compile = hyperfine_command(
6473
1,
6574
bench_runs,
6675
Some(&clean_cmd),
67-
&[&llvm_build_cmd, &clif_build_cmd, &clif_build_opt_cmd],
76+
&[
77+
("cargo build", &llvm_build_cmd),
78+
("cargo-clif build", &clif_build_cmd),
79+
("cargo-clif build --release", &clif_build_opt_cmd),
80+
],
81+
&bench_compile_markdown,
6882
);
6983

7084
spawn_and_wait(bench_compile);
7185

86+
if let Some(gha_step_summary) = gha_step_summary.as_mut() {
87+
gha_step_summary.write_all(b"## Compile ebobby/simple-raytracer\n\n").unwrap();
88+
gha_step_summary.write_all(&std::fs::read(bench_compile_markdown).unwrap()).unwrap();
89+
gha_step_summary.write_all(b"\n").unwrap();
90+
}
91+
7292
eprintln!("[BENCH RUN] ebobby/simple-raytracer");
7393

94+
let bench_run_markdown = RelPath::DIST.to_path(dirs).join("bench_run.md");
95+
96+
let raytracer_cg_llvm = Path::new(".").join(get_file_name(
97+
&bootstrap_host_compiler.rustc,
98+
"raytracer_cg_llvm",
99+
"bin",
100+
));
101+
let raytracer_cg_clif = Path::new(".").join(get_file_name(
102+
&bootstrap_host_compiler.rustc,
103+
"raytracer_cg_clif",
104+
"bin",
105+
));
106+
let raytracer_cg_clif_opt = Path::new(".").join(get_file_name(
107+
&bootstrap_host_compiler.rustc,
108+
"raytracer_cg_clif_opt",
109+
"bin",
110+
));
74111
let mut bench_run = hyperfine_command(
75112
0,
76113
bench_runs,
77114
None,
78115
&[
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(),
116+
("", raytracer_cg_llvm.to_str().unwrap()),
117+
("", raytracer_cg_clif.to_str().unwrap()),
118+
("", raytracer_cg_clif_opt.to_str().unwrap()),
91119
],
120+
&bench_run_markdown,
92121
);
93122
bench_run.current_dir(RelPath::BUILD.to_path(dirs));
94123
spawn_and_wait(bench_run);
124+
125+
if let Some(gha_step_summary) = gha_step_summary.as_mut() {
126+
gha_step_summary.write_all(b"## Run ebobby/simple-raytracer\n\n").unwrap();
127+
gha_step_summary.write_all(&std::fs::read(bench_run_markdown).unwrap()).unwrap();
128+
gha_step_summary.write_all(b"\n").unwrap();
129+
}
95130
}

0 commit comments

Comments
 (0)