]> git.lizzy.rs Git - rust.git/blob - .github/workflows/main.yml
Force the allocator to be looked up from the perspective of the rustc binary
[rust.git] / .github / workflows / main.yml
1 name: CI
2
3 on:
4   - push
5   - pull_request
6
7 jobs:
8   rustfmt:
9     runs-on: ubuntu-latest
10     timeout-minutes: 10
11
12     steps:
13     - uses: actions/checkout@v3
14
15     - name: Install rustfmt
16       run: |
17         rustup component add rustfmt
18
19     - name: Rustfmt
20       run: |
21         cargo fmt --check
22         rustfmt --check build_system/mod.rs
23
24
25   build:
26     runs-on: ${{ matrix.os }}
27     timeout-minutes: 60
28
29     defaults:
30       run:
31         shell: bash
32
33     strategy:
34       fail-fast: false
35       matrix:
36         include:
37           - os: ubuntu-latest
38             env:
39               TARGET_TRIPLE: x86_64-unknown-linux-gnu
40           - os: macos-latest
41             env:
42               TARGET_TRIPLE: x86_64-apple-darwin
43           # cross-compile from Linux to Windows using mingw
44           - os: ubuntu-latest
45             env:
46               TARGET_TRIPLE: x86_64-pc-windows-gnu
47           - os: ubuntu-latest
48             env:
49               TARGET_TRIPLE: aarch64-unknown-linux-gnu
50           # s390x requires QEMU 6.1 or greater, we could build it from source, but ubuntu 22.04 comes with 6.2 by default
51           - os: ubuntu-latest
52             env:
53               TARGET_TRIPLE: s390x-unknown-linux-gnu
54           - os: windows-latest
55             env:
56               TARGET_TRIPLE: x86_64-pc-windows-msvc
57           - os: windows-latest
58             env:
59               TARGET_TRIPLE: x86_64-pc-windows-gnu
60
61     steps:
62     - uses: actions/checkout@v3
63
64     - name: Cache cargo target dir
65       uses: actions/cache@v3
66       with:
67         path: build/cg_clif
68         key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
69
70     - name: Set MinGW as the default toolchain
71       if: matrix.os == 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
72       run: rustup set default-host x86_64-pc-windows-gnu
73
74     - name: Install MinGW toolchain and wine
75       if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
76       run: |
77         sudo apt-get update
78         sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable
79
80     - name: Install AArch64 toolchain and qemu
81       if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'aarch64-unknown-linux-gnu'
82       run: |
83         sudo apt-get update
84         sudo apt-get install -y gcc-aarch64-linux-gnu qemu-user
85
86     - name: Install s390x toolchain and qemu
87       if: matrix.env.TARGET_TRIPLE == 's390x-unknown-linux-gnu'
88       run: |
89         sudo apt-get update
90         sudo apt-get install -y gcc-s390x-linux-gnu qemu-user
91
92     - name: Use sparse cargo registry
93       run: |
94         cat >> ~/.cargo/config.toml <<EOF
95         [unstable]
96         sparse-registry = true
97         EOF
98
99     - name: Prepare dependencies
100       run: ./y.rs prepare
101
102     - name: Build without unstable features
103       env:
104         TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
105       # This is the config rust-lang/rust uses for builds
106       run: ./y.rs build --no-unstable-features
107
108     - name: Build
109       run: ./y.rs build --sysroot none
110
111     - name: Test
112       env:
113         TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
114       run: ./y.rs test
115
116
117   abi_cafe:
118     runs-on: ${{ matrix.os }}
119     timeout-minutes: 60
120
121     defaults:
122       run:
123         shell: bash
124
125     strategy:
126       fail-fast: true
127       matrix:
128         include:
129           - os: ubuntu-latest
130             env:
131               TARGET_TRIPLE: x86_64-unknown-linux-gnu
132           - os: macos-latest
133             env:
134               TARGET_TRIPLE: x86_64-apple-darwin
135           - os: windows-latest
136             env:
137               TARGET_TRIPLE: x86_64-pc-windows-msvc
138           - os: windows-latest
139             env:
140               TARGET_TRIPLE: x86_64-pc-windows-gnu
141
142     steps:
143     - uses: actions/checkout@v3
144
145     - name: Cache cargo target dir
146       uses: actions/cache@v3
147       with:
148         path: build/cg_clif
149         key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
150
151     - name: Set MinGW as the default toolchain
152       if: matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
153       run: rustup set default-host x86_64-pc-windows-gnu
154
155     - name: Use sparse cargo registry
156       run: |
157         cat >> ~/.cargo/config.toml <<EOF
158         [unstable]
159         sparse-registry = true
160         EOF
161
162     - name: Prepare dependencies
163       run: ./y.rs prepare
164
165     - name: Build
166       run: ./y.rs build --sysroot none
167
168     - name: Test abi-cafe
169       env:
170         TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
171       run: ./y.rs abi-cafe
172
173
174   bench:
175     runs-on: ubuntu-latest
176     timeout-minutes: 60
177
178     defaults:
179       run:
180         shell: bash
181
182     steps:
183     - uses: actions/checkout@v3
184
185     - name: Cache cargo target dir
186       uses: actions/cache@v3
187       with:
188         path: build/cg_clif
189         key: ${{ runner.os }}-x86_64-unknown-linux-gnu-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
190
191     - name: Cache cargo bin dir
192       uses: actions/cache@v3
193       with:
194         path: ~/.cargo/bin
195         key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-bin-dir-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
196
197     - name: Use sparse cargo registry
198       run: |
199         cat >> ~/.cargo/config.toml <<EOF
200         [unstable]
201         sparse-registry = true
202         EOF
203
204     - name: Install hyperfine
205       run: cargo install hyperfine || true
206
207     - name: Prepare dependencies
208       run: ./y.rs prepare
209
210     - name: Build
211       run: CI_OPT=1 ./y.rs build --sysroot none
212
213     - name: Benchmark
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           # FIXME update at some point in the future once most distros use a newer glibc
230           - os: ubuntu-20.04
231             env:
232               TARGET_TRIPLE: x86_64-unknown-linux-gnu
233           - os: macos-latest
234             env:
235               TARGET_TRIPLE: x86_64-apple-darwin
236           # cross-compile from Linux to Windows using mingw
237           - os: ubuntu-latest
238             env:
239               TARGET_TRIPLE: x86_64-pc-windows-gnu
240           - os: windows-latest
241             env:
242               TARGET_TRIPLE: x86_64-pc-windows-msvc
243           - os: windows-latest
244             env:
245               TARGET_TRIPLE: x86_64-pc-windows-gnu
246
247     steps:
248     - uses: actions/checkout@v3
249
250     - name: Cache cargo target dir
251       uses: actions/cache@v3
252       with:
253         path: build/cg_clif
254         key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-dist-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
255
256     - name: Set MinGW as the default toolchain
257       if: matrix.os == 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
258       run: rustup set default-host x86_64-pc-windows-gnu
259
260     - name: Install MinGW toolchain and wine
261       if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
262       run: |
263         sudo apt-get update
264         sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable
265
266     - name: Use sparse cargo registry
267       run: |
268         cat >> ~/.cargo/config.toml <<EOF
269         [unstable]
270         sparse-registry = true
271         EOF
272
273     - name: Prepare dependencies
274       run: ./y.rs prepare
275
276     - name: Build backend
277       run: CI_OPT=1 ./y.rs build --sysroot none
278
279     - name: Build sysroot
280       run: CI_OPT=1 ./y.rs build
281
282     - name: Package prebuilt cg_clif
283       run: tar cvfJ cg_clif.tar.xz dist
284
285     - name: Upload prebuilt cg_clif
286       if: matrix.os == 'windows-latest' || matrix.env.TARGET_TRIPLE != 'x86_64-pc-windows-gnu'
287       uses: actions/upload-artifact@v3
288       with:
289         name: cg_clif-${{ matrix.env.TARGET_TRIPLE }}
290         path: cg_clif.tar.xz
291
292     - name: Upload prebuilt cg_clif (cross compile)
293       if: matrix.os != 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
294       uses: actions/upload-artifact@v3
295       with:
296         name: cg_clif-${{ runner.os }}-cross-x86_64-mingw
297         path: cg_clif.tar.xz