Skip to content

Add Windows CI #1284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 32 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 "[email protected]"
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
Expand All @@ -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
11 changes: 1 addition & 10 deletions build_system/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down