]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_codegen_cranelift/.github/workflows/main.yml
Rollup merge of #102049 - fee1-dead-contrib:derive_const, r=oli-obk
[rust.git] / compiler / rustc_codegen_cranelift / .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
23   build:
24     runs-on: ${{ matrix.os }}
25     timeout-minutes: 60
26
27     strategy:
28       fail-fast: false
29       matrix:
30         include:
31           - os: ubuntu-latest
32             env:
33               TARGET_TRIPLE: x86_64-unknown-linux-gnu
34           - os: macos-latest
35             env:
36               TARGET_TRIPLE: x86_64-apple-darwin
37           # cross-compile from Linux to Windows using mingw
38           - os: ubuntu-latest
39             env:
40               TARGET_TRIPLE: x86_64-pc-windows-gnu
41           - os: ubuntu-latest
42             env:
43               TARGET_TRIPLE: aarch64-unknown-linux-gnu
44
45     steps:
46     - uses: actions/checkout@v3
47
48     - name: Cache cargo installed crates
49       uses: actions/cache@v2
50       with:
51         path: ~/.cargo/bin
52         key: ${{ runner.os }}-cargo-installed-crates
53
54     - name: Cache cargo registry and index
55       uses: actions/cache@v2
56       with:
57         path: |
58             ~/.cargo/registry
59             ~/.cargo/git
60         key: ${{ runner.os }}-cargo-registry-and-index-${{ hashFiles('**/Cargo.lock') }}
61
62     - name: Cache cargo target dir
63       uses: actions/cache@v2
64       with:
65         path: target
66         key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
67
68     - name: Install MinGW toolchain and wine
69       if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
70       run: |
71         sudo apt-get update
72         sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable
73         rustup target add x86_64-pc-windows-gnu
74
75     - name: Install AArch64 toolchain and qemu
76       if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'aarch64-unknown-linux-gnu'
77       run: |
78         sudo apt-get update
79         sudo apt-get install -y gcc-aarch64-linux-gnu qemu-user
80
81     - name: Prepare dependencies
82       run: |
83         git config --global user.email "user@example.com"
84         git config --global user.name "User"
85         ./y.rs prepare
86
87     - name: Build without unstable features
88       env:
89         TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
90       # This is the config rust-lang/rust uses for builds
91       run: ./y.rs build --no-unstable-features
92
93     - name: Build
94       run: ./y.rs build --sysroot none
95
96     - name: Test
97       env:
98         TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
99       run: |
100         # Enable backtraces for easier debugging
101         export RUST_BACKTRACE=1
102
103         # Reduce amount of benchmark runs as they are slow
104         export COMPILE_RUNS=2
105         export RUN_RUNS=2
106
107         # Enable extra checks
108         export CG_CLIF_ENABLE_VERIFIER=1
109
110         ./y.rs test
111
112     - name: Package prebuilt cg_clif
113       run: tar cvfJ cg_clif.tar.xz build
114
115     - name: Upload prebuilt cg_clif
116       if: matrix.env.TARGET_TRIPLE != 'x86_64-pc-windows-gnu'
117       uses: actions/upload-artifact@v2
118       with:
119         name: cg_clif-${{ matrix.env.TARGET_TRIPLE }}
120         path: cg_clif.tar.xz
121
122     - name: Upload prebuilt cg_clif (cross compile)
123       if: matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
124       uses: actions/upload-artifact@v2
125       with:
126         name: cg_clif-${{ runner.os }}-cross-x86_64-mingw
127         path: cg_clif.tar.xz
128
129   windows:
130     runs-on: ${{ matrix.os }}
131     timeout-minutes: 60
132
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
146     steps:
147     - uses: actions/checkout@v3
148
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
172
173     - name: Prepare dependencies
174       run: |
175         git config --global user.email "user@example.com"
176         git config --global user.name "User"
177         git config --global core.autocrlf false
178         rustc y.rs -o y.exe -g
179         ./y.exe prepare
180
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
187     - name: Build
188       run: ./y.rs build --sysroot none
189
190     - name: Test
191       run: |
192         # Enable backtraces for easier debugging
193         $Env:RUST_BACKTRACE=1
194
195         # Reduce amount of benchmark runs as they are slow
196         $Env:COMPILE_RUNS=2
197         $Env:RUN_RUNS=2
198
199         # Enable extra checks
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
212
213     - name: Package prebuilt cg_clif
214       # don't use compression as xzip isn't supported by tar on windows and bzip2 hangs
215       run: tar cvf cg_clif.tar build
216
217     - name: Upload prebuilt cg_clif
218       uses: actions/upload-artifact@v2
219       with:
220         name: cg_clif-${{ matrix.env.TARGET_TRIPLE }}
221         path: cg_clif.tar