Skip to content

Commit a53b445

Browse files
authored
Merge pull request #1284 from afonso360/windows-fix
Add Windows CI
2 parents 93703a4 + 6909219 commit a53b445

6 files changed

+147
-71
lines changed

.github/workflows/main.yml

+68-31
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ jobs:
2929
matrix:
3030
include:
3131
- os: ubuntu-latest
32+
env:
33+
TARGET_TRIPLE: x86_64-unknown-linux-gnu
3234
- os: macos-latest
35+
env:
36+
TARGET_TRIPLE: x86_64-apple-darwin
3337
# cross-compile from Linux to Windows using mingw
3438
- os: ubuntu-latest
3539
env:
@@ -112,7 +116,7 @@ jobs:
112116
if: matrix.env.TARGET_TRIPLE != 'x86_64-pc-windows-gnu'
113117
uses: actions/upload-artifact@v2
114118
with:
115-
name: cg_clif-${{ runner.os }}
119+
name: cg_clif-${{ matrix.env.TARGET_TRIPLE }}
116120
path: cg_clif.tar.xz
117121

118122
- name: Upload prebuilt cg_clif (cross compile)
@@ -122,56 +126,89 @@ jobs:
122126
name: cg_clif-${{ runner.os }}-cross-x86_64-mingw
123127
path: cg_clif.tar.xz
124128

125-
build_windows:
126-
runs-on: windows-latest
129+
windows:
130+
runs-on: ${{ matrix.os }}
127131
timeout-minutes: 60
128132

133+
strategy:
134+
fail-fast: false
135+
matrix:
136+
include:
137+
# Native Windows build with MSVC
138+
- os: windows-latest
139+
env:
140+
TARGET_TRIPLE: x86_64-pc-windows-msvc
141+
# cross-compile from Windows to Windows MinGW
142+
- os: windows-latest
143+
env:
144+
TARGET_TRIPLE: x86_64-pc-windows-gnu
145+
129146
steps:
130147
- uses: actions/checkout@v3
131148

132-
#- name: Cache cargo installed crates
133-
# uses: actions/cache@v2
134-
# with:
135-
# path: ~/.cargo/bin
136-
# key: ${{ runner.os }}-cargo-installed-crates
137-
138-
#- name: Cache cargo registry and index
139-
# uses: actions/cache@v2
140-
# with:
141-
# path: |
142-
# ~/.cargo/registry
143-
# ~/.cargo/git
144-
# key: ${{ runner.os }}-cargo-registry-and-index-${{ hashFiles('**/Cargo.lock') }}
145-
146-
#- name: Cache cargo target dir
147-
# uses: actions/cache@v2
148-
# with:
149-
# path: target
150-
# key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
149+
- name: Cache cargo installed crates
150+
uses: actions/cache@v2
151+
with:
152+
path: ~/.cargo/bin
153+
key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-installed-crates
154+
155+
- name: Cache cargo registry and index
156+
uses: actions/cache@v2
157+
with:
158+
path: |
159+
~/.cargo/registry
160+
~/.cargo/git
161+
key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-registry-and-index-${{ hashFiles('**/Cargo.lock') }}
162+
163+
- name: Cache cargo target dir
164+
uses: actions/cache@v2
165+
with:
166+
path: target
167+
key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
168+
169+
- name: Set MinGW as the default toolchain
170+
if: matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
171+
run: rustup set default-host x86_64-pc-windows-gnu
151172

152173
- name: Prepare dependencies
153174
run: |
154175
git config --global user.email "[email protected]"
155176
git config --global user.name "User"
156177
git config --global core.autocrlf false
157-
rustup set default-host x86_64-pc-windows-gnu
158178
rustc y.rs -o y.exe -g
159179
./y.exe prepare
160180
181+
- name: Build without unstable features
182+
env:
183+
TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
184+
# This is the config rust-lang/rust uses for builds
185+
run: ./y.rs build --no-unstable-features
186+
161187
- name: Build
162-
#name: Test
188+
run: ./y.rs build --sysroot none
189+
190+
- name: Test
163191
run: |
164192
# Enable backtraces for easier debugging
165-
#$Env:RUST_BACKTRACE=1
193+
$Env:RUST_BACKTRACE=1
166194
167195
# Reduce amount of benchmark runs as they are slow
168-
#$Env:COMPILE_RUNS=2
169-
#$Env:RUN_RUNS=2
196+
$Env:COMPILE_RUNS=2
197+
$Env:RUN_RUNS=2
170198
171199
# Enable extra checks
172-
#$Env:CG_CLIF_ENABLE_VERIFIER=1
173-
174-
./y.exe build
200+
$Env:CG_CLIF_ENABLE_VERIFIER=1
201+
202+
# WIP Disable some tests
203+
204+
# This fails due to some weird argument handling by hyperfine, not an actual regression
205+
# more of a build system issue
206+
(Get-Content config.txt) -replace '(bench.simple-raytracer)', '# $1' | Out-File config.txt
207+
208+
# This fails with a different output than expected
209+
(Get-Content config.txt) -replace '(test.regex-shootout-regex-dna)', '# $1' | Out-File config.txt
210+
211+
./y.exe test
175212
176213
- name: Package prebuilt cg_clif
177214
# don't use compression as xzip isn't supported by tar on windows and bzip2 hangs
@@ -180,5 +217,5 @@ jobs:
180217
- name: Upload prebuilt cg_clif
181218
uses: actions/upload-artifact@v2
182219
with:
183-
name: cg_clif-${{ runner.os }}
220+
name: cg_clif-${{ matrix.env.TARGET_TRIPLE }}
184221
path: cg_clif.tar

build_system/mod.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,7 @@ pub fn main() {
122122
host_triple.clone()
123123
};
124124

125-
if target_triple.ends_with("-msvc") {
126-
eprintln!("The MSVC toolchain is not yet supported by rustc_codegen_cranelift.");
127-
eprintln!("Switch to the MinGW toolchain for Windows support.");
128-
eprintln!("Hint: You can use `rustup set default-host x86_64-pc-windows-gnu` to");
129-
eprintln!("set the global default target to MinGW");
130-
process::exit(1);
131-
}
132-
133-
let cg_clif_dylib =
134-
build_backend::build_backend(channel, &host_triple, use_unstable_features);
125+
let cg_clif_dylib = build_backend::build_backend(channel, &host_triple, use_unstable_features);
135126
match command {
136127
Command::Test => {
137128
tests::run_tests(

build_system/tests.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,8 @@ impl TestRunner {
450450
out_dir.push("out");
451451

452452
let is_native = host_triple == target_triple;
453-
let jit_supported = target_triple.contains("x86_64") && is_native;
453+
let jit_supported =
454+
target_triple.contains("x86_64") && is_native && !host_triple.contains("windows");
454455

455456
let mut rust_flags = env::var("RUSTFLAGS").ok().unwrap_or("".to_string());
456457
let mut run_wrapper = Vec::new();

patches/0001-abi-cafe-Disable-failing-tests.patch

-29
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
From 2b15fee2bb5fd14e34c7e17e44d99cb34f4c555d Mon Sep 17 00:00:00 2001
2+
From: Afonso Bordado <[email protected]>
3+
Date: Tue, 27 Sep 2022 07:55:17 +0100
4+
Subject: [PATCH] Disable some test on x86_64-pc-windows-gnu
5+
6+
---
7+
src/report.rs | 6 ++++++
8+
1 file changed, 6 insertions(+)
9+
10+
diff --git a/src/report.rs b/src/report.rs
11+
index eeec614..f582867 100644
12+
--- a/src/report.rs
13+
+++ b/src/report.rs
14+
@@ -48,6 +48,12 @@ pub fn get_test_rules(test: &TestKey, caller: &dyn AbiImpl, callee: &dyn AbiImpl
15+
//
16+
// THIS AREA RESERVED FOR VENDORS TO APPLY PATCHES
17+
18+
+ // x86_64-pc-windows-gnu has some broken i128 tests that aren't disabled by default
19+
+ if cfg!(all(target_os = "windows", target_env = "gnu")) && test.test_name == "ui128" {
20+
+ result.run = Link;
21+
+ result.check = Pass(Link);
22+
+ }
23+
+
24+
// END OF VENDOR RESERVED AREA
25+
//
26+
//
27+
--
28+
2.30.1.windows.1
29+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
From eec874c889b8d24e5ad50faded24288150f057b1 Mon Sep 17 00:00:00 2001
2+
From: Afonso Bordado <[email protected]>
3+
Date: Tue, 27 Sep 2022 08:13:58 +0100
4+
Subject: [PATCH] Disable rand tests on mingw
5+
6+
---
7+
rand_distr/src/pareto.rs | 2 ++
8+
rand_distr/tests/value_stability.rs | 4 ++++
9+
2 files changed, 6 insertions(+)
10+
11+
diff --git a/rand_distr/src/pareto.rs b/rand_distr/src/pareto.rs
12+
index 217899e..9cedeb7 100644
13+
--- a/rand_distr/src/pareto.rs
14+
+++ b/rand_distr/src/pareto.rs
15+
@@ -107,6 +107,8 @@ mod tests {
16+
}
17+
18+
#[test]
19+
+ // This is broken on x86_64-pc-windows-gnu presumably due to a broken powf implementation
20+
+ #[cfg_attr(all(target_os = "windows", target_env = "gnu"), ignore)]
21+
fn value_stability() {
22+
fn test_samples<F: Float + core::fmt::Debug, D: Distribution<F>>(
23+
distr: D, zero: F, expected: &[F],
24+
diff --git a/rand_distr/tests/value_stability.rs b/rand_distr/tests/value_stability.rs
25+
index 192ba74..0101ace 100644
26+
--- a/rand_distr/tests/value_stability.rs
27+
+++ b/rand_distr/tests/value_stability.rs
28+
@@ -72,6 +72,8 @@ fn unit_disc_stability() {
29+
}
30+
31+
#[test]
32+
+// This is broken on x86_64-pc-windows-gnu
33+
+#[cfg_attr(all(target_os = "windows", target_env = "gnu"), ignore)]
34+
fn pareto_stability() {
35+
test_samples(213, Pareto::new(1.0, 1.0).unwrap(), &[
36+
1.0423688f32, 2.1235929, 4.132709, 1.4679428,
37+
@@ -143,6 +145,8 @@ fn inverse_gaussian_stability() {
38+
}
39+
40+
#[test]
41+
+// This is broken on x86_64-pc-windows-gnu
42+
+#[cfg_attr(all(target_os = "windows", target_env = "gnu"), ignore)]
43+
fn gamma_stability() {
44+
// Gamma has 3 cases: shape == 1, shape < 1, shape > 1
45+
test_samples(223, Gamma::new(1.0, 5.0).unwrap(), &[
46+
--
47+
2.25.1

0 commit comments

Comments
 (0)