Skip to content

Commit 8b48138

Browse files
authored
Merge pull request #1347 from bjorn3/dist_no_debug_assertions
Build CI dist artifacts without debug assertions
2 parents efb92a1 + 761a91a commit 8b48138

File tree

4 files changed

+100
-25
lines changed

4 files changed

+100
-25
lines changed

.github/workflows/main.yml

Lines changed: 86 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
cargo fmt --check
2222
rustfmt --check build_system/mod.rs
2323
24+
2425
build:
2526
runs-on: ${{ matrix.os }}
2627
timeout-minutes: 60
@@ -112,23 +113,6 @@ jobs:
112113
TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
113114
run: ./y.rs test
114115

115-
- name: Package prebuilt cg_clif
116-
run: tar cvfJ cg_clif.tar.xz dist
117-
118-
- name: Upload prebuilt cg_clif
119-
if: matrix.os == 'windows-latest' || matrix.env.TARGET_TRIPLE != 'x86_64-pc-windows-gnu'
120-
uses: actions/upload-artifact@v3
121-
with:
122-
name: cg_clif-${{ matrix.env.TARGET_TRIPLE }}
123-
path: cg_clif.tar.xz
124-
125-
- name: Upload prebuilt cg_clif (cross compile)
126-
if: matrix.os != 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
127-
uses: actions/upload-artifact@v3
128-
with:
129-
name: cg_clif-${{ runner.os }}-cross-x86_64-mingw
130-
path: cg_clif.tar.xz
131-
132116

133117
abi_cafe:
134118
runs-on: ${{ matrix.os }}
@@ -186,6 +170,7 @@ jobs:
186170
TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
187171
run: ./y.rs abi-cafe
188172

173+
189174
bench:
190175
runs-on: ubuntu-latest
191176
timeout-minutes: 60
@@ -223,7 +208,89 @@ jobs:
223208
run: ./y.rs prepare
224209

225210
- name: Build
226-
run: ./y.rs build --sysroot none
211+
run: CI_OPT=1 ./y.rs build --sysroot none
227212

228213
- name: Benchmark
229-
run: ./y.rs bench
214+
run: CI_OPT=1 ./y.rs bench
215+
216+
217+
dist:
218+
runs-on: ${{ matrix.os }}
219+
timeout-minutes: 60
220+
221+
defaults:
222+
run:
223+
shell: bash
224+
225+
strategy:
226+
fail-fast: false
227+
matrix:
228+
include:
229+
- os: ubuntu-20.04 # FIXME switch to ubuntu-22.04 once #1303 is fixed
230+
env:
231+
TARGET_TRIPLE: x86_64-unknown-linux-gnu
232+
- os: macos-latest
233+
env:
234+
TARGET_TRIPLE: x86_64-apple-darwin
235+
# cross-compile from Linux to Windows using mingw
236+
- os: ubuntu-latest
237+
env:
238+
TARGET_TRIPLE: x86_64-pc-windows-gnu
239+
- os: windows-latest
240+
env:
241+
TARGET_TRIPLE: x86_64-pc-windows-msvc
242+
- os: windows-latest
243+
env:
244+
TARGET_TRIPLE: x86_64-pc-windows-gnu
245+
246+
steps:
247+
- uses: actions/checkout@v3
248+
249+
- name: Cache cargo target dir
250+
uses: actions/cache@v3
251+
with:
252+
path: build/cg_clif
253+
key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-dist-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
254+
255+
- name: Set MinGW as the default toolchain
256+
if: matrix.os == 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
257+
run: rustup set default-host x86_64-pc-windows-gnu
258+
259+
- name: Install MinGW toolchain and wine
260+
if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
261+
run: |
262+
sudo apt-get update
263+
sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable
264+
265+
- name: Use sparse cargo registry
266+
run: |
267+
cat >> ~/.cargo/config.toml <<EOF
268+
[unstable]
269+
sparse-registry = true
270+
EOF
271+
272+
- name: Prepare dependencies
273+
run: ./y.rs prepare
274+
275+
- name: Build backend
276+
run: CI_OPT=1 ./y.rs build --sysroot none
277+
278+
- name: Build sysroot
279+
run: CI_OPT=1 ./y.rs build
280+
281+
- name: Package prebuilt cg_clif
282+
run: tar cvfJ cg_clif.tar.xz dist
283+
284+
- name: Upload prebuilt cg_clif
285+
if: matrix.os == 'windows-latest' || matrix.env.TARGET_TRIPLE != 'x86_64-pc-windows-gnu'
286+
uses: actions/upload-artifact@v3
287+
with:
288+
name: cg_clif-${{ matrix.env.TARGET_TRIPLE }}
289+
path: cg_clif.tar.xz
290+
291+
- name: Upload prebuilt cg_clif (cross compile)
292+
if: matrix.os != 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
293+
uses: actions/upload-artifact@v3
294+
with:
295+
name: cg_clif-${{ runner.os }}-cross-x86_64-mingw
296+
path: cg_clif.tar.xz

build_system/build_backend.rs

Lines changed: 4 additions & 2 deletions
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, CargoProject, Compiler};
6+
use super::utils::{is_ci, is_ci_opt, CargoProject, Compiler};
77

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

@@ -26,7 +26,9 @@ pub(crate) fn build_backend(
2626
// Disabling incr comp reduces cache size and incr comp doesn't save as much on CI anyway
2727
cmd.env("CARGO_BUILD_INCREMENTAL", "false");
2828

29-
cmd.env("CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS", "true");
29+
if !is_ci_opt() {
30+
cmd.env("CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS", "true");
31+
}
3032
}
3133

3234
if use_unstable_features {

build_system/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::env;
22
use std::path::PathBuf;
33
use std::process;
44

5-
use self::utils::{is_ci, Compiler};
5+
use self::utils::{is_ci, is_ci_opt, Compiler};
66

77
mod abi_cafe;
88
mod bench;
@@ -53,8 +53,10 @@ pub fn main() {
5353
// Disabling incr comp reduces cache size and incr comp doesn't save as much on CI anyway
5454
env::set_var("CARGO_BUILD_INCREMENTAL", "false");
5555

56-
// Enable the Cranelift verifier
57-
env::set_var("CG_CLIF_ENABLE_VERIFIER", "1");
56+
if !is_ci_opt() {
57+
// Enable the Cranelift verifier
58+
env::set_var("CG_CLIF_ENABLE_VERIFIER", "1");
59+
}
5860
}
5961

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

build_system/utils.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,5 +279,9 @@ pub(crate) fn copy_dir_recursively(from: &Path, to: &Path) {
279279
}
280280

281281
pub(crate) fn is_ci() -> bool {
282-
env::var("CI").as_deref() == Ok("true")
282+
env::var("CI").is_ok()
283+
}
284+
285+
pub(crate) fn is_ci_opt() -> bool {
286+
env::var("CI_OPT").is_ok()
283287
}

0 commit comments

Comments
 (0)