Skip to content

Commit f2895f3

Browse files
authored
Merge pull request #1357 from bjorn3/build_system_rework6
Support testing of cg_clif in rust's CI
2 parents 45781e1 + e9bd63a commit f2895f3

35 files changed

+1602
-258
lines changed

.cirrus.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ task:
1010
folder: target
1111
prepare_script:
1212
- . $HOME/.cargo/env
13-
- ./y.rs prepare
13+
- ./y.sh prepare
1414
test_script:
1515
- . $HOME/.cargo/env
16-
- ./y.rs test
16+
- ./y.sh test

.github/workflows/abi-cafe.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ jobs:
4646
run: rustup set default-host x86_64-pc-windows-gnu
4747

4848
- name: Prepare dependencies
49-
run: ./y.rs prepare
49+
run: ./y.sh prepare
5050

5151
- name: Build
52-
run: ./y.rs build --sysroot none
52+
run: ./y.sh build --sysroot none
5353

5454
- name: Test abi-cafe
5555
env:
5656
TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
57-
run: ./y.rs abi-cafe
57+
run: ./y.sh abi-cafe

.github/workflows/main.yml

+11-11
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Rustfmt
2020
run: |
2121
cargo fmt --check
22-
rustfmt --check build_system/mod.rs
22+
rustfmt --check build_system/main.rs
2323
rustfmt --check example/*
2424
2525
@@ -91,15 +91,15 @@ jobs:
9191
sudo apt-get install -y gcc-s390x-linux-gnu qemu-user
9292
9393
- name: Prepare dependencies
94-
run: ./y.rs prepare
94+
run: ./y.sh prepare
9595

9696
- name: Build
97-
run: ./y.rs build --sysroot none
97+
run: ./y.sh build --sysroot none
9898

9999
- name: Test
100100
env:
101101
TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
102-
run: ./y.rs test
102+
run: ./y.sh test
103103

104104
- name: Install LLVM standard library
105105
run: rustup target add ${{ matrix.env.TARGET_TRIPLE }}
@@ -111,7 +111,7 @@ jobs:
111111
if: matrix.os != 'windows-latest' || matrix.env.TARGET_TRIPLE != 'x86_64-pc-windows-gnu'
112112
env:
113113
TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
114-
run: ./y.rs test --sysroot llvm --no-unstable-features
114+
run: ./y.sh test --sysroot llvm --no-unstable-features
115115

116116

117117
# This job doesn't use cg_clif in any way. It checks that all cg_clif tests work with cg_llvm too.
@@ -165,13 +165,13 @@ jobs:
165165
run: cargo install hyperfine || true
166166

167167
- name: Prepare dependencies
168-
run: ./y.rs prepare
168+
run: ./y.sh prepare
169169

170170
- name: Build
171-
run: CI_OPT=1 ./y.rs build --sysroot none
171+
run: CI_OPT=1 ./y.sh build --sysroot none
172172

173173
- name: Benchmark
174-
run: CI_OPT=1 ./y.rs bench
174+
run: CI_OPT=1 ./y.sh bench
175175

176176

177177
dist:
@@ -224,13 +224,13 @@ jobs:
224224
sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable
225225
226226
- name: Prepare dependencies
227-
run: ./y.rs prepare
227+
run: ./y.sh prepare
228228

229229
- name: Build backend
230-
run: CI_OPT=1 ./y.rs build --sysroot none
230+
run: CI_OPT=1 ./y.sh build --sysroot none
231231

232232
- name: Build sysroot
233-
run: CI_OPT=1 ./y.rs build
233+
run: CI_OPT=1 ./y.sh build
234234

235235
- name: Package prebuilt cg_clif
236236
run: tar cvfJ cg_clif.tar.xz dist

.github/workflows/rustc.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
1919

2020
- name: Prepare dependencies
21-
run: ./y.rs prepare
21+
run: ./y.sh prepare
2222

2323
- name: Test
2424
run: ./scripts/test_bootstrap.sh
@@ -38,7 +38,7 @@ jobs:
3838
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
3939

4040
- name: Prepare dependencies
41-
run: ./y.rs prepare
41+
run: ./y.sh prepare
4242

4343
- name: Test
4444
run: ./scripts/test_rustc_tests.sh

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/target
2+
/build_system/target
23
**/*.rs.bk
34
*.rlib
45
*.o

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
"rust-analyzer.imports.granularity.enforce": true,
77
"rust-analyzer.imports.granularity.group": "module",
88
"rust-analyzer.imports.prefix": "crate",
9-
"rust-analyzer.cargo.features": ["unstable-features", "__check_build_system_using_ra"],
9+
"rust-analyzer.cargo.features": ["unstable-features"],
1010
"rust-analyzer.linkedProjects": [
1111
"./Cargo.toml",
12+
"./build_system/Cargo.toml",
1213
{
1314
"crates": [
1415
{

Cargo.toml

-8
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@ name = "rustc_codegen_cranelift"
33
version = "0.1.0"
44
edition = "2021"
55

6-
[[bin]]
7-
# This is used just to teach rust-analyzer how to check the build system. required-features is used
8-
# to disable it for regular builds.
9-
name = "y"
10-
path = "./y.rs"
11-
required-features = ["__check_build_system_using_ra"]
12-
136
[lib]
147
crate-type = ["dylib"]
158

@@ -45,7 +38,6 @@ smallvec = "1.8.1"
4538
unstable-features = ["jit", "inline_asm"]
4639
jit = ["cranelift-jit", "libloading"]
4740
inline_asm = []
48-
__check_build_system_using_ra = []
4941

5042
[package.metadata.rust-analyzer]
5143
rustc_private = true

Readme.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ If not please open an issue.
1010
```bash
1111
$ git clone https://github.com/bjorn3/rustc_codegen_cranelift
1212
$ cd rustc_codegen_cranelift
13-
$ ./y.rs prepare
14-
$ ./y.rs build
13+
$ ./y.sh prepare
14+
$ ./y.sh build
1515
```
1616

1717
To run the test suite replace the last command with:
@@ -20,7 +20,7 @@ To run the test suite replace the last command with:
2020
$ ./test.sh
2121
```
2222

23-
For more docs on how to build and test see [build_system/usage.txt](build_system/usage.txt) or the help message of `./y.rs`.
23+
For more docs on how to build and test see [build_system/usage.txt](build_system/usage.txt) or the help message of `./y.sh`.
2424

2525
## Precompiled builds
2626

@@ -35,7 +35,7 @@ If you want to use `cargo clif build` instead of having to specify the full path
3535

3636
rustc_codegen_cranelift can be used as a near-drop-in replacement for `cargo build` or `cargo run` for existing projects.
3737

38-
Assuming `$cg_clif_dir` is the directory you cloned this repo into and you followed the instructions (`y.rs prepare` and `y.rs build` or `test.sh`).
38+
Assuming `$cg_clif_dir` is the directory you cloned this repo into and you followed the instructions (`y.sh prepare` and `y.sh build` or `test.sh`).
3939

4040
In the directory with your project (where you can do the usual `cargo build`), run:
4141

build_sysroot/Cargo.toml

-36
This file was deleted.

build_sysroot/src/lib.rs

-1
This file was deleted.

build_system/Cargo.lock

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

build_system/Cargo.toml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "y"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[[bin]]
7+
name = "y"
8+
path = "main.rs"
9+
10+
[features]
11+
unstable-features = [] # for rust-analyzer
12+
13+
# Do not add any dependencies

build_system/abi_cafe.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ use super::prepare::GitRepo;
44
use super::utils::{spawn_and_wait, CargoProject, Compiler};
55
use super::{CodegenBackend, SysrootKind};
66

7-
static ABI_CAFE_REPO: GitRepo =
8-
GitRepo::github("Gankra", "abi-cafe", "4c6dc8c9c687e2b3a760ff2176ce236872b37212", "abi-cafe");
7+
static ABI_CAFE_REPO: GitRepo = GitRepo::github(
8+
"Gankra",
9+
"abi-cafe",
10+
"4c6dc8c9c687e2b3a760ff2176ce236872b37212",
11+
"588df6d66abbe105",
12+
"abi-cafe",
13+
);
914

10-
static ABI_CAFE: CargoProject = CargoProject::new(&ABI_CAFE_REPO.source_dir(), "abi_cafe");
15+
static ABI_CAFE: CargoProject = CargoProject::new(&ABI_CAFE_REPO.source_dir(), "abi_cafe_target");
1116

1217
pub(crate) fn run(
1318
channel: &str,
@@ -18,6 +23,7 @@ pub(crate) fn run(
1823
bootstrap_host_compiler: &Compiler,
1924
) {
2025
ABI_CAFE_REPO.fetch(dirs);
26+
ABI_CAFE_REPO.patch(dirs);
2127

2228
eprintln!("Building sysroot for abi-cafe");
2329
build_sysroot::build_sysroot(

build_system/bench.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ static SIMPLE_RAYTRACER_REPO: GitRepo = GitRepo::github(
1010
"ebobby",
1111
"simple-raytracer",
1212
"804a7a21b9e673a482797aa289a18ed480e4d813",
13+
"ad6f59a2331a3f56",
1314
"<none>",
1415
);
1516

@@ -24,9 +25,8 @@ fn benchmark_simple_raytracer(dirs: &Dirs, bootstrap_host_compiler: &Compiler) {
2425
std::process::exit(1);
2526
}
2627

27-
if !SIMPLE_RAYTRACER_REPO.source_dir().to_path(dirs).exists() {
28-
SIMPLE_RAYTRACER_REPO.fetch(dirs);
29-
}
28+
SIMPLE_RAYTRACER_REPO.fetch(dirs);
29+
SIMPLE_RAYTRACER_REPO.patch(dirs);
3030

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

build_system/build_backend.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::path::PathBuf;
33

44
use super::path::{Dirs, RelPath};
55
use super::rustc_info::get_file_name;
6-
use super::utils::{is_ci, is_ci_opt, CargoProject, Compiler};
6+
use super::utils::{is_ci, is_ci_opt, maybe_incremental, CargoProject, Compiler};
77

88
pub(crate) static CG_CLIF: CargoProject = CargoProject::new(&RelPath::SOURCE, "cg_clif");
99

@@ -14,18 +14,14 @@ pub(crate) fn build_backend(
1414
use_unstable_features: bool,
1515
) -> PathBuf {
1616
let mut cmd = CG_CLIF.build(&bootstrap_host_compiler, dirs);
17-
18-
cmd.env("CARGO_BUILD_INCREMENTAL", "true"); // Force incr comp even in release mode
17+
maybe_incremental(&mut cmd);
1918

2019
let mut rustflags = env::var("RUSTFLAGS").unwrap_or_default();
2120

2221
if is_ci() {
2322
// Deny warnings on CI
2423
rustflags += " -Dwarnings";
2524

26-
// Disabling incr comp reduces cache size and incr comp doesn't save as much on CI anyway
27-
cmd.env("CARGO_BUILD_INCREMENTAL", "false");
28-
2925
if !is_ci_opt() {
3026
cmd.env("CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS", "true");
3127
cmd.env("CARGO_PROFILE_RELEASE_OVERFLOW_CHECKS", "true");

0 commit comments

Comments
 (0)