Skip to content

Commit 454c87b

Browse files
committed
Merge branch 'build_system_changes'
2 parents 40d40fb + 1bab6df commit 454c87b

File tree

8 files changed

+45
-80
lines changed

8 files changed

+45
-80
lines changed

.cirrus.yml

+3
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ task:
1313
- ./y.sh prepare
1414
test_script:
1515
- . $HOME/.cargo/env
16+
# Disabling incr comp reduces cache size and incr comp doesn't save as much
17+
# on CI anyway.
18+
- export CARGO_BUILD_INCREMENTAL=false
1619
- ./y.sh test

.github/workflows/abi-cafe.yml

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Abi-cafe
33
on:
44
- push
55

6+
permissions: {}
7+
68
jobs:
79
abi_cafe:
810
runs-on: ${{ matrix.os }}

.github/workflows/main.yml

+27-40
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ on:
44
- push
55
- pull_request
66

7+
defaults:
8+
run:
9+
shell: bash
10+
11+
permissions: {}
12+
13+
env:
14+
# Disabling incr comp reduces cache size and incr comp doesn't save as much
15+
# on CI anyway.
16+
CARGO_BUILD_INCREMENTAL: false
17+
# Rust's CI denies warnings. Deny them here too to ensure subtree syncs don't
18+
# fail because of warnings.
19+
RUSTFLAGS: "-Dwarnings"
20+
721
jobs:
822
rustfmt:
923
runs-on: ubuntu-latest
@@ -30,9 +44,8 @@ jobs:
3044
runs-on: ${{ matrix.os }}
3145
timeout-minutes: 60
3246

33-
defaults:
34-
run:
35-
shell: bash
47+
env:
48+
CG_CLIF_EXPENSIVE_CHECKS: 1
3649

3750
strategy:
3851
fail-fast: false
@@ -48,15 +61,19 @@ jobs:
4861
- os: ubuntu-latest
4962
env:
5063
TARGET_TRIPLE: x86_64-pc-windows-gnu
64+
apt_deps: gcc-mingw-w64-x86-64 wine-stable
5165
- os: ubuntu-latest
5266
env:
5367
TARGET_TRIPLE: aarch64-unknown-linux-gnu
68+
apt_deps: gcc-aarch64-linux-gnu qemu-user
5469
- os: ubuntu-latest
5570
env:
5671
TARGET_TRIPLE: s390x-unknown-linux-gnu
72+
apt_deps: gcc-s390x-linux-gnu qemu-user
5773
- os: ubuntu-latest
5874
env:
5975
TARGET_TRIPLE: riscv64gc-unknown-linux-gnu
76+
apt_deps: gcc-riscv64-linux-gnu qemu-user
6077
- os: windows-latest
6178
env:
6279
TARGET_TRIPLE: x86_64-pc-windows-msvc
@@ -81,29 +98,11 @@ jobs:
8198
if: matrix.os == 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
8299
run: rustup set default-host x86_64-pc-windows-gnu
83100

84-
- name: Install MinGW toolchain and wine
85-
if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
86-
run: |
87-
sudo apt-get update
88-
sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable
89-
90-
- name: Install AArch64 toolchain and qemu
91-
if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'aarch64-unknown-linux-gnu'
92-
run: |
93-
sudo apt-get update
94-
sudo apt-get install -y gcc-aarch64-linux-gnu qemu-user
95-
96-
- name: Install s390x toolchain and qemu
97-
if: matrix.env.TARGET_TRIPLE == 's390x-unknown-linux-gnu'
101+
- name: Install toolchain and emulator
102+
if: matrix.apt_deps != null
98103
run: |
99104
sudo apt-get update
100-
sudo apt-get install -y gcc-s390x-linux-gnu qemu-user
101-
102-
- name: Install riscv64gc toolchain and qemu
103-
if: matrix.env.TARGET_TRIPLE == 'riscv64gc-unknown-linux-gnu'
104-
run: |
105-
sudo apt-get update
106-
sudo apt-get install -y gcc-riscv64-linux-gnu qemu-user
105+
sudo apt-get install -y ${{ matrix.apt_deps }}
107106
108107
- name: Prepare dependencies
109108
run: ./y.sh prepare
@@ -143,10 +142,6 @@ jobs:
143142
runs-on: ubuntu-latest
144143
timeout-minutes: 60
145144

146-
defaults:
147-
run:
148-
shell: bash
149-
150145
steps:
151146
- uses: actions/checkout@v4
152147

@@ -169,10 +164,6 @@ jobs:
169164
runs-on: ubuntu-latest
170165
timeout-minutes: 60
171166

172-
defaults:
173-
run:
174-
shell: bash
175-
176167
steps:
177168
- uses: actions/checkout@v4
178169

@@ -194,20 +185,16 @@ jobs:
194185
run: ./y.sh prepare
195186

196187
- name: Build
197-
run: CI_OPT=1 ./y.sh build --sysroot none
188+
run: ./y.sh build --sysroot none
198189

199190
- name: Benchmark
200-
run: CI_OPT=1 ./y.sh bench
191+
run: ./y.sh bench
201192

202193

203194
dist:
204195
runs-on: ${{ matrix.os }}
205196
timeout-minutes: 60
206197

207-
defaults:
208-
run:
209-
shell: bash
210-
211198
strategy:
212199
fail-fast: false
213200
matrix:
@@ -253,10 +240,10 @@ jobs:
253240
run: ./y.sh prepare
254241

255242
- name: Build backend
256-
run: CI_OPT=1 ./y.sh build --sysroot none
243+
run: ./y.sh build --sysroot none
257244

258245
- name: Build sysroot
259-
run: CI_OPT=1 ./y.sh build
246+
run: ./y.sh build
260247

261248
- name: Package prebuilt cg_clif
262249
run: tar cvfJ cg_clif.tar.xz dist

.github/workflows/rustc.yml

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Various rustc tests
33
on:
44
- push
55

6+
permissions: {}
7+
68
jobs:
79
bootstrap_rustc:
810
runs-on: ubuntu-latest

build_system/build_backend.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
use std::env;
12
use std::path::PathBuf;
23

34
use crate::path::{Dirs, RelPath};
45
use crate::rustc_info::get_file_name;
56
use crate::shared_utils::{rustflags_from_env, rustflags_to_cmd_env};
6-
use crate::utils::{is_ci, is_ci_opt, maybe_incremental, CargoProject, Compiler, LogGroup};
7+
use crate::utils::{CargoProject, Compiler, LogGroup};
78

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

@@ -16,20 +17,15 @@ pub(crate) fn build_backend(
1617
let _group = LogGroup::guard("Build backend");
1718

1819
let mut cmd = CG_CLIF.build(&bootstrap_host_compiler, dirs);
19-
maybe_incremental(&mut cmd);
2020

2121
let mut rustflags = rustflags_from_env("RUSTFLAGS");
2222

2323
rustflags.push("-Zallow-features=rustc_private".to_owned());
2424

25-
if is_ci() {
26-
// Deny warnings on CI
27-
rustflags.push("-Dwarnings".to_owned());
28-
29-
if !is_ci_opt() {
30-
cmd.env("CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS", "true");
31-
cmd.env("CARGO_PROFILE_RELEASE_OVERFLOW_CHECKS", "true");
32-
}
25+
if env::var("CG_CLIF_EXPENSIVE_CHECKS").is_ok() {
26+
// Enabling debug assertions implicitly enables the clif ir verifier
27+
cmd.env("CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS", "true");
28+
cmd.env("CARGO_PROFILE_RELEASE_OVERFLOW_CHECKS", "true");
3329
}
3430

3531
if use_unstable_features {

build_system/build_sysroot.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use std::process::Command;
66
use crate::path::{Dirs, RelPath};
77
use crate::rustc_info::get_file_name;
88
use crate::utils::{
9-
maybe_incremental, remove_dir_if_exists, spawn_and_wait, try_hard_link, CargoProject, Compiler,
10-
LogGroup,
9+
remove_dir_if_exists, spawn_and_wait, try_hard_link, CargoProject, Compiler, LogGroup,
1110
};
1211
use crate::{config, CodegenBackend, SysrootKind};
1312

@@ -270,7 +269,6 @@ fn build_clif_sysroot_for_triple(
270269
}
271270
compiler.rustflags.extend(rustflags);
272271
let mut build_cmd = STANDARD_LIBRARY.build(&compiler, dirs);
273-
maybe_incremental(&mut build_cmd);
274272
if channel == "release" {
275273
build_cmd.arg("--release");
276274
}

build_system/main.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::env;
66
use std::path::PathBuf;
77
use std::process;
88

9-
use self::utils::{is_ci, is_ci_opt, Compiler};
9+
use self::utils::Compiler;
1010

1111
mod abi_cafe;
1212
mod bench;
@@ -60,14 +60,9 @@ fn main() {
6060
}
6161
env::set_var("CG_CLIF_DISABLE_INCR_CACHE", "1");
6262

63-
if is_ci() {
64-
// Disabling incr comp reduces cache size and incr comp doesn't save as much on CI anyway
65-
env::set_var("CARGO_BUILD_INCREMENTAL", "false");
66-
67-
if !is_ci_opt() {
68-
// Enable the Cranelift verifier
69-
env::set_var("CG_CLIF_ENABLE_VERIFIER", "1");
70-
}
63+
// Force incr comp even in release mode unless in CI or incremental builds are explicitly disabled
64+
if env::var_os("CARGO_BUILD_INCREMENTAL").is_none() {
65+
env::set_var("CARGO_BUILD_INCREMENTAL", "true");
7166
}
7267

7368
let mut args = env::args().skip(1);

build_system/utils.rs

-18
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,6 @@ pub(crate) fn copy_dir_recursively(from: &Path, to: &Path) {
254254
}
255255
}
256256

257-
pub(crate) fn is_ci() -> bool {
258-
env::var("CI").is_ok()
259-
}
260-
261-
pub(crate) fn is_ci_opt() -> bool {
262-
env::var("CI_OPT").is_ok()
263-
}
264-
265257
static IN_GROUP: AtomicBool = AtomicBool::new(false);
266258
pub(crate) struct LogGroup {
267259
is_gha: bool,
@@ -288,13 +280,3 @@ impl Drop for LogGroup {
288280
IN_GROUP.store(false, Ordering::SeqCst);
289281
}
290282
}
291-
292-
pub(crate) fn maybe_incremental(cmd: &mut Command) {
293-
if is_ci() || std::env::var("CARGO_BUILD_INCREMENTAL").map_or(false, |val| val == "false") {
294-
// Disabling incr comp reduces cache size and incr comp doesn't save as much on CI anyway
295-
cmd.env("CARGO_BUILD_INCREMENTAL", "false");
296-
} else {
297-
// Force incr comp even in release mode unless in CI or incremental builds are explicitly disabled
298-
cmd.env("CARGO_BUILD_INCREMENTAL", "true");
299-
}
300-
}

0 commit comments

Comments
 (0)