13 - uses: actions/checkout@v3
15 - name: Install rustfmt
17 rustup component add rustfmt
22 rustfmt --check build_system/mod.rs
25 runs-on: ${{ matrix.os }}
36 - os: ubuntu-20.04 # FIXME switch to ubuntu-22.04 once #1303 is fixed
38 TARGET_TRIPLE: x86_64-unknown-linux-gnu
41 TARGET_TRIPLE: x86_64-apple-darwin
42 # cross-compile from Linux to Windows using mingw
45 TARGET_TRIPLE: x86_64-pc-windows-gnu
48 TARGET_TRIPLE: aarch64-unknown-linux-gnu
49 # s390x requires QEMU 6.1 or greater, we could build it from source, but ubuntu 22.04 comes with 6.2 by default
52 TARGET_TRIPLE: s390x-unknown-linux-gnu
53 # Native Windows build with MSVC
56 TARGET_TRIPLE: x86_64-pc-windows-msvc
57 # cross-compile from Windows to Windows MinGW
60 TARGET_TRIPLE: x86_64-pc-windows-gnu
63 - uses: actions/checkout@v3
65 - name: Cache cargo target dir
66 uses: actions/cache@v3
69 key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
71 - name: Set MinGW as the default toolchain
72 if: matrix.os == 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
73 run: rustup set default-host x86_64-pc-windows-gnu
75 - name: Install MinGW toolchain and wine
76 if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
79 sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable
80 rustup target add x86_64-pc-windows-gnu
82 - name: Install AArch64 toolchain and qemu
83 if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'aarch64-unknown-linux-gnu'
86 sudo apt-get install -y gcc-aarch64-linux-gnu qemu-user
88 - name: Install s390x toolchain and qemu
89 if: matrix.env.TARGET_TRIPLE == 's390x-unknown-linux-gnu'
92 sudo apt-get install -y gcc-s390x-linux-gnu qemu-user
95 if: matrix.os == 'windows-latest'
96 run: git config --global core.autocrlf false
98 - name: Use sparse cargo registry
100 cat >> ~/.cargo/config.toml <<EOF
102 sparse-registry = true
105 - name: Prepare dependencies
108 - name: Build without unstable features
110 TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
111 # This is the config rust-lang/rust uses for builds
112 run: ./y.rs build --no-unstable-features
115 run: ./y.rs build --sysroot none
119 TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
122 - name: Package prebuilt cg_clif
123 run: tar cvfJ cg_clif.tar.xz dist
125 - name: Upload prebuilt cg_clif
126 if: matrix.os == 'windows-latest' || matrix.env.TARGET_TRIPLE != 'x86_64-pc-windows-gnu'
127 uses: actions/upload-artifact@v3
129 name: cg_clif-${{ matrix.env.TARGET_TRIPLE }}
132 - name: Upload prebuilt cg_clif (cross compile)
133 if: matrix.os != 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
134 uses: actions/upload-artifact@v3
136 name: cg_clif-${{ runner.os }}-cross-x86_64-mingw