From ba56e8f313895eefc3e0f7de38c9cde3145b0c04 Mon Sep 17 00:00:00 2001 From: Afonso Bordado Date: Mon, 26 Sep 2022 09:45:00 +0100 Subject: [PATCH 01/11] Remove MSVC Check --- build_system/mod.rs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/build_system/mod.rs b/build_system/mod.rs index 03c8f58c724..b25270d832c 100644 --- a/build_system/mod.rs +++ b/build_system/mod.rs @@ -122,16 +122,7 @@ pub fn main() { host_triple.clone() }; - if target_triple.ends_with("-msvc") { - eprintln!("The MSVC toolchain is not yet supported by rustc_codegen_cranelift."); - eprintln!("Switch to the MinGW toolchain for Windows support."); - eprintln!("Hint: You can use `rustup set default-host x86_64-pc-windows-gnu` to"); - eprintln!("set the global default target to MinGW"); - process::exit(1); - } - - let cg_clif_dylib = - build_backend::build_backend(channel, &host_triple, use_unstable_features); + let cg_clif_dylib = build_backend::build_backend(channel, &host_triple, use_unstable_features); match command { Command::Test => { tests::run_tests( From 481484c1410c360acd309ed3ba7fe214a6f61454 Mon Sep 17 00:00:00 2001 From: Afonso Bordado Date: Tue, 2 Aug 2022 08:31:50 +0100 Subject: [PATCH 02/11] Windows MinGW & MSVC Matrix CI --- .github/workflows/main.yml | 42 +++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e8897e9ae81..029e83f6aa4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -122,10 +122,21 @@ jobs: name: cg_clif-${{ runner.os }}-cross-x86_64-mingw path: cg_clif.tar.xz - build_windows: - runs-on: windows-latest + windows: + runs-on: ${{ matrix.os }} timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + include: + # Native Windows build with MSVC + - os: windows-latest + # cross-compile from Windows to Windows MinGW + - os: windows-latest + env: + TARGET_TRIPLE: x86_64-pc-windows-gnu + steps: - uses: actions/checkout@v3 @@ -149,29 +160,40 @@ jobs: # path: target # key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }} + - name: Set MinGW as the default toolchain + if: matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu' + run: rustup set default-host x86_64-pc-windows-gnu + - name: Prepare dependencies run: | git config --global user.email "user@example.com" git config --global user.name "User" git config --global core.autocrlf false - rustup set default-host x86_64-pc-windows-gnu rustc y.rs -o y.exe -g ./y.exe prepare + - name: Build without unstable features + env: + TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }} + # This is the config rust-lang/rust uses for builds + run: ./y.rs build --no-unstable-features + - name: Build - #name: Test + run: ./y.rs build --sysroot none + + - name: Test run: | # Enable backtraces for easier debugging - #$Env:RUST_BACKTRACE=1 + $Env:RUST_BACKTRACE=1 # Reduce amount of benchmark runs as they are slow - #$Env:COMPILE_RUNS=2 - #$Env:RUN_RUNS=2 + $Env:COMPILE_RUNS=2 + $Env:RUN_RUNS=2 # Enable extra checks - #$Env:CG_CLIF_ENABLE_VERIFIER=1 + $Env:CG_CLIF_ENABLE_VERIFIER=1 - ./y.exe build + ./y.exe test - name: Package prebuilt cg_clif # don't use compression as xzip isn't supported by tar on windows and bzip2 hangs @@ -180,5 +202,5 @@ jobs: - name: Upload prebuilt cg_clif uses: actions/upload-artifact@v2 with: - name: cg_clif-${{ runner.os }} + name: cg_clif-${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }} path: cg_clif.tar From 1878ca61bcce43276fa723921b7a579482293ff0 Mon Sep 17 00:00:00 2001 From: Afonso Bordado Date: Mon, 26 Sep 2022 13:38:53 +0100 Subject: [PATCH 03/11] Disable JIT Tests for windows --- build_system/tests.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build_system/tests.rs b/build_system/tests.rs index 74042bc9218..d4f393fc7ff 100644 --- a/build_system/tests.rs +++ b/build_system/tests.rs @@ -450,7 +450,8 @@ impl TestRunner { out_dir.push("out"); let is_native = host_triple == target_triple; - let jit_supported = target_triple.contains("x86_64") && is_native; + let jit_supported = + target_triple.contains("x86_64") && is_native && !host_triple.contains("windows"); let mut rust_flags = env::var("RUSTFLAGS").ok().unwrap_or("".to_string()); let mut run_wrapper = Vec::new(); From 01d3e1a3ade98bbf636cf38289ed50c2d3d66ef0 Mon Sep 17 00:00:00 2001 From: Afonso Bordado Date: Mon, 26 Sep 2022 13:44:55 +0100 Subject: [PATCH 04/11] Disable failing windows CI tests --- .github/workflows/main.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 029e83f6aa4..91240cca8b4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -192,6 +192,18 @@ jobs: # Enable extra checks $Env:CG_CLIF_ENABLE_VERIFIER=1 + + # WIP Disable some tests + + # This fails due to some weird argument handling by hyperfine, not an actual regression + # more of a build system issue + (Get-Content config.txt) -replace '(bench.simple-raytracer)', '# $1' | Out-File config.txt + + # This fails with a different output than expected + (Get-Content config.txt) -replace '(test.regex-shootout-regex-dna)', '# $1' | Out-File config.txt + + # This only fails on x86_64-pc-windows-gnu when run from a windows host + (Get-Content config.txt) -replace '(test.rust-random/rand)', '# $1' | Out-File config.txt ./y.exe test From 8072dec7a5f75861fc152310eb1bd6f171103835 Mon Sep 17 00:00:00 2001 From: Afonso Bordado Date: Mon, 26 Sep 2022 15:00:53 +0100 Subject: [PATCH 05/11] Drop abi cafe patch --- .../0001-abi-cafe-Disable-failing-tests.patch | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 patches/0001-abi-cafe-Disable-failing-tests.patch diff --git a/patches/0001-abi-cafe-Disable-failing-tests.patch b/patches/0001-abi-cafe-Disable-failing-tests.patch deleted file mode 100644 index a6bcade8eb8..00000000000 --- a/patches/0001-abi-cafe-Disable-failing-tests.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 1a315ba225577dbbd1f449d9609f16f984f68708 Mon Sep 17 00:00:00 2001 -From: Afonso Bordado -Date: Fri, 12 Aug 2022 22:51:58 +0000 -Subject: [PATCH] Disable abi-cafe tests - ---- - src/report.rs | 14 ++++++++++++++ - 1 file changed, 14 insertions(+) - -diff --git a/src/report.rs b/src/report.rs -index 7346f5e..8347762 100644 ---- a/src/report.rs -+++ b/src/report.rs -@@ -45,6 +45,13 @@ pub fn get_test_rules(test: &TestKey, caller: &dyn AbiImpl, callee: &dyn AbiImpl - // - // THIS AREA RESERVED FOR VENDORS TO APPLY PATCHES - -+ // Currently MSVC has some broken ABI issues. Furthermore, they cause -+ // a STATUS_ACCESS_VIOLATION, so we can't even run them. Ensure that they compile and link. -+ if cfg!(windows) && (test.test_name == "bool" || test.test_name == "ui128") { -+ result.run = Link; -+ result.check = Pass(Link); -+ } -+ - // END OF VENDOR RESERVED AREA - // - // --- -2.34.1 From 738dd2b70b6ab8366ae4620e5c0597c209e0235c Mon Sep 17 00:00:00 2001 From: Afonso Bordado Date: Tue, 27 Sep 2022 07:26:12 +0100 Subject: [PATCH 06/11] Windows CI Cache --- .github/workflows/main.yml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 91240cca8b4..2d63881b7ab 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -140,25 +140,25 @@ jobs: steps: - uses: actions/checkout@v3 - #- name: Cache cargo installed crates - # uses: actions/cache@v2 - # with: - # path: ~/.cargo/bin - # key: ${{ runner.os }}-cargo-installed-crates + - name: Cache cargo installed crates + uses: actions/cache@v2 + with: + path: ~/.cargo/bin + key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-installed-crates - #- name: Cache cargo registry and index - # uses: actions/cache@v2 - # with: - # path: | - # ~/.cargo/registry - # ~/.cargo/git - # key: ${{ runner.os }}-cargo-registry-and-index-${{ hashFiles('**/Cargo.lock') }} + - name: Cache cargo registry and index + uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-registry-and-index-${{ hashFiles('**/Cargo.lock') }} - #- name: Cache cargo target dir - # uses: actions/cache@v2 - # with: - # path: target - # key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }} + - name: Cache cargo target dir + uses: actions/cache@v2 + with: + path: target + key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }} - name: Set MinGW as the default toolchain if: matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu' From cd8becbc03916b2c1db31ce1063c40f7d0d2b38e Mon Sep 17 00:00:00 2001 From: Afonso Bordado Date: Tue, 27 Sep 2022 07:38:54 +0100 Subject: [PATCH 07/11] Disable some ABI tests on MinGW --- ...e-some-test-on-x86_64-pc-windows-gnu.patch | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 patches/0001-abi-cafe-Disable-some-test-on-x86_64-pc-windows-gnu.patch diff --git a/patches/0001-abi-cafe-Disable-some-test-on-x86_64-pc-windows-gnu.patch b/patches/0001-abi-cafe-Disable-some-test-on-x86_64-pc-windows-gnu.patch new file mode 100644 index 00000000000..0e5e7cdfcdf --- /dev/null +++ b/patches/0001-abi-cafe-Disable-some-test-on-x86_64-pc-windows-gnu.patch @@ -0,0 +1,29 @@ +From 2b15fee2bb5fd14e34c7e17e44d99cb34f4c555d Mon Sep 17 00:00:00 2001 +From: Afonso Bordado +Date: Tue, 27 Sep 2022 07:55:17 +0100 +Subject: [PATCH] Disable some test on x86_64-pc-windows-gnu + +--- + src/report.rs | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/src/report.rs b/src/report.rs +index eeec614..f582867 100644 +--- a/src/report.rs ++++ b/src/report.rs +@@ -48,6 +48,12 @@ pub fn get_test_rules(test: &TestKey, caller: &dyn AbiImpl, callee: &dyn AbiImpl + // + // THIS AREA RESERVED FOR VENDORS TO APPLY PATCHES + ++ // x86_64-pc-windows-gnu has some broken i128 tests that aren't disabled by default ++ if cfg!(all(target_os = "windows", target_env = "gnu")) && test.test_name == "ui128" { ++ result.run = Link; ++ result.check = Pass(Link); ++ } ++ + // END OF VENDOR RESERVED AREA + // + // +-- +2.30.1.windows.1 + From e96badc97fde074e64c300c35d0acdd68cddc59b Mon Sep 17 00:00:00 2001 From: Afonso Bordado Date: Tue, 27 Sep 2022 08:15:41 +0100 Subject: [PATCH 08/11] Disable some rand tests on MinGW --- .github/workflows/main.yml | 3 -- ...001-rand-Disable-rand-tests-on-mingw.patch | 47 +++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 patches/0001-rand-Disable-rand-tests-on-mingw.patch diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2d63881b7ab..7f6cfd2ccc5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -201,9 +201,6 @@ jobs: # This fails with a different output than expected (Get-Content config.txt) -replace '(test.regex-shootout-regex-dna)', '# $1' | Out-File config.txt - - # This only fails on x86_64-pc-windows-gnu when run from a windows host - (Get-Content config.txt) -replace '(test.rust-random/rand)', '# $1' | Out-File config.txt ./y.exe test diff --git a/patches/0001-rand-Disable-rand-tests-on-mingw.patch b/patches/0001-rand-Disable-rand-tests-on-mingw.patch new file mode 100644 index 00000000000..108f882408d --- /dev/null +++ b/patches/0001-rand-Disable-rand-tests-on-mingw.patch @@ -0,0 +1,47 @@ +From eea3bbaed34ab210868c324219a862a9d5f4681c Mon Sep 17 00:00:00 2001 +From: Afonso Bordado +Date: Tue, 27 Sep 2022 08:13:58 +0100 +Subject: [PATCH] Disable rand tests on mingw + +--- + rand_distr/src/pareto.rs | 2 ++ + rand_distr/tests/value_stability.rs | 4 ++++ + 2 files changed, 6 insertions(+) + +diff --git a/rand_distr/src/pareto.rs b/rand_distr/src/pareto.rs +index 217899ed9a..5f8e2c9bbb 100644 +--- a/rand_distr/src/pareto.rs ++++ b/rand_distr/src/pareto.rs +@@ -107,6 +107,8 @@ mod tests { + } + + #[test] ++ // This is broken on x86_64-pc-windows-gnu presumably due to a broken powf implementation ++ #[cfg(not(all(target_os = "windows", target_env = "gnu")))] + fn value_stability() { + fn test_samples>( + distr: D, zero: F, expected: &[F], +diff --git a/rand_distr/tests/value_stability.rs b/rand_distr/tests/value_stability.rs +index 192ba748b7..10c6ac24f6 100644 +--- a/rand_distr/tests/value_stability.rs ++++ b/rand_distr/tests/value_stability.rs +@@ -72,6 +72,8 @@ fn unit_disc_stability() { + } + + #[test] ++// This is broken on x86_64-pc-windows-gnu ++#[cfg(not(all(target_os = "windows", target_env = "gnu")))] + fn pareto_stability() { + test_samples(213, Pareto::new(1.0, 1.0).unwrap(), &[ + 1.0423688f32, 2.1235929, 4.132709, 1.4679428, +@@ -143,6 +145,8 @@ fn inverse_gaussian_stability() { + } + + #[test] ++// This is broken on x86_64-pc-windows-gnu ++#[cfg(not(all(target_os = "windows", target_env = "gnu")))] + fn gamma_stability() { + // Gamma has 3 cases: shape == 1, shape < 1, shape > 1 + test_samples(223, Gamma::new(1.0, 5.0).unwrap(), &[ +-- +2.30.1.windows.1 From a83ec3b6a451cd40f654f0606228564b9fa21a04 Mon Sep 17 00:00:00 2001 From: Afonso Bordado Date: Tue, 27 Sep 2022 12:26:23 +0100 Subject: [PATCH 09/11] Ignore rand tests --- ... 0003-rand-Disable-rand-tests-on-mingw.patch} | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) rename patches/{0001-rand-Disable-rand-tests-on-mingw.patch => 0003-rand-Disable-rand-tests-on-mingw.patch} (79%) diff --git a/patches/0001-rand-Disable-rand-tests-on-mingw.patch b/patches/0003-rand-Disable-rand-tests-on-mingw.patch similarity index 79% rename from patches/0001-rand-Disable-rand-tests-on-mingw.patch rename to patches/0003-rand-Disable-rand-tests-on-mingw.patch index 108f882408d..d8775e2d022 100644 --- a/patches/0001-rand-Disable-rand-tests-on-mingw.patch +++ b/patches/0003-rand-Disable-rand-tests-on-mingw.patch @@ -1,4 +1,4 @@ -From eea3bbaed34ab210868c324219a862a9d5f4681c Mon Sep 17 00:00:00 2001 +From eec874c889b8d24e5ad50faded24288150f057b1 Mon Sep 17 00:00:00 2001 From: Afonso Bordado Date: Tue, 27 Sep 2022 08:13:58 +0100 Subject: [PATCH] Disable rand tests on mingw @@ -9,7 +9,7 @@ Subject: [PATCH] Disable rand tests on mingw 2 files changed, 6 insertions(+) diff --git a/rand_distr/src/pareto.rs b/rand_distr/src/pareto.rs -index 217899ed9a..5f8e2c9bbb 100644 +index 217899e..9cedeb7 100644 --- a/rand_distr/src/pareto.rs +++ b/rand_distr/src/pareto.rs @@ -107,6 +107,8 @@ mod tests { @@ -17,12 +17,12 @@ index 217899ed9a..5f8e2c9bbb 100644 #[test] + // This is broken on x86_64-pc-windows-gnu presumably due to a broken powf implementation -+ #[cfg(not(all(target_os = "windows", target_env = "gnu")))] ++ #[cfg_attr(all(target_os = "windows", target_env = "gnu"), ignore)] fn value_stability() { fn test_samples>( distr: D, zero: F, expected: &[F], diff --git a/rand_distr/tests/value_stability.rs b/rand_distr/tests/value_stability.rs -index 192ba748b7..10c6ac24f6 100644 +index 192ba74..0101ace 100644 --- a/rand_distr/tests/value_stability.rs +++ b/rand_distr/tests/value_stability.rs @@ -72,6 +72,8 @@ fn unit_disc_stability() { @@ -30,7 +30,7 @@ index 192ba748b7..10c6ac24f6 100644 #[test] +// This is broken on x86_64-pc-windows-gnu -+#[cfg(not(all(target_os = "windows", target_env = "gnu")))] ++#[cfg_attr(all(target_os = "windows", target_env = "gnu"), ignore)] fn pareto_stability() { test_samples(213, Pareto::new(1.0, 1.0).unwrap(), &[ 1.0423688f32, 2.1235929, 4.132709, 1.4679428, @@ -39,9 +39,9 @@ index 192ba748b7..10c6ac24f6 100644 #[test] +// This is broken on x86_64-pc-windows-gnu -+#[cfg(not(all(target_os = "windows", target_env = "gnu")))] ++#[cfg_attr(all(target_os = "windows", target_env = "gnu"), ignore)] fn gamma_stability() { // Gamma has 3 cases: shape == 1, shape < 1, shape > 1 test_samples(223, Gamma::new(1.0, 5.0).unwrap(), &[ --- -2.30.1.windows.1 +-- +2.25.1 From 4edf14520aaa7e2d506afa470d9b8b1f9999b8f8 Mon Sep 17 00:00:00 2001 From: Afonso Bordado Date: Tue, 27 Sep 2022 12:29:52 +0100 Subject: [PATCH 10/11] Use target triple artifact names --- .github/workflows/main.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7f6cfd2ccc5..5655f466d74 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,7 +29,11 @@ jobs: matrix: include: - os: ubuntu-latest + env: + TARGET_TRIPLE: x86_64-unknown-linux-gnu - os: macos-latest + env: + TARGET_TRIPLE: x86_64-apple-darwin # cross-compile from Linux to Windows using mingw - os: ubuntu-latest env: @@ -112,7 +116,7 @@ jobs: if: matrix.env.TARGET_TRIPLE != 'x86_64-pc-windows-gnu' uses: actions/upload-artifact@v2 with: - name: cg_clif-${{ runner.os }} + name: ${{ matrix.env.TARGET_TRIPLE }} path: cg_clif.tar.xz - name: Upload prebuilt cg_clif (cross compile) @@ -132,6 +136,8 @@ jobs: include: # Native Windows build with MSVC - os: windows-latest + env: + TARGET_TRIPLE: x86_64-pc-windows-msvc # cross-compile from Windows to Windows MinGW - os: windows-latest env: @@ -211,5 +217,5 @@ jobs: - name: Upload prebuilt cg_clif uses: actions/upload-artifact@v2 with: - name: cg_clif-${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }} + name: ${{ matrix.env.TARGET_TRIPLE }} path: cg_clif.tar From 6909219a2945b9867250459e4722eae4ce359721 Mon Sep 17 00:00:00 2001 From: Afonso Bordado Date: Tue, 27 Sep 2022 12:42:27 +0100 Subject: [PATCH 11/11] Prefix artifact names with `cg_clif` Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com> --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5655f466d74..5061010c86c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -116,7 +116,7 @@ jobs: if: matrix.env.TARGET_TRIPLE != 'x86_64-pc-windows-gnu' uses: actions/upload-artifact@v2 with: - name: ${{ matrix.env.TARGET_TRIPLE }} + name: cg_clif-${{ matrix.env.TARGET_TRIPLE }} path: cg_clif.tar.xz - name: Upload prebuilt cg_clif (cross compile) @@ -217,5 +217,5 @@ jobs: - name: Upload prebuilt cg_clif uses: actions/upload-artifact@v2 with: - name: ${{ matrix.env.TARGET_TRIPLE }} + name: cg_clif-${{ matrix.env.TARGET_TRIPLE }} path: cg_clif.tar