• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: CI
2
3on:
4  push:
5    branches:
6      - main
7  pull_request:
8  workflow_dispatch:
9
10jobs:
11  rustfmt:
12    name: Rustfmt
13    runs-on: ubuntu-latest
14    steps:
15    - uses: actions/checkout@v3
16      with:
17        submodules: true
18    - uses: ./.github/actions/install-rust
19      with:
20        toolchain: stable
21    - run: cargo fmt --all -- --check
22
23  check:
24    name: Check
25    runs-on: ${{ matrix.os }}
26    strategy:
27      matrix:
28        build: [stable, nightly, 1.48]
29        include:
30          - build: stable
31            os: ubuntu-latest
32            rust: stable
33          - build: nightly
34            os: ubuntu-latest
35            rust: nightly
36          - build: 1.48
37            os: ubuntu-latest
38            rust: 1.48
39
40    env:
41      # -D warnings is commented out in our install-rust action; re-add it here.
42      # In theory we should add --cfg criterion here, but criterion doesn't compile under Rust 1.48.
43      RUSTFLAGS: -D warnings
44    steps:
45    - uses: actions/checkout@v3
46      with:
47        submodules: true
48    - uses: ./.github/actions/install-rust
49      with:
50        toolchain: ${{ matrix.rust }}
51
52    - run: >
53        rustup target add
54        x86_64-unknown-linux-musl
55        x86_64-unknown-linux-gnux32
56        x86_64-linux-android
57        i686-linux-android
58        x86_64-apple-darwin
59        x86_64-unknown-freebsd
60        x86_64-unknown-netbsd
61        x86_64-unknown-illumos
62        i686-unknown-linux-gnu
63        i686-unknown-linux-musl
64        wasm32-unknown-emscripten
65        riscv64gc-unknown-linux-gnu
66        aarch64-unknown-linux-gnu
67        aarch64-unknown-linux-musl
68        powerpc64le-unknown-linux-gnu
69        mipsel-unknown-linux-gnu
70        mips64el-unknown-linux-gnuabi64
71        armv5te-unknown-linux-gnueabi
72        s390x-unknown-linux-gnu
73        arm-linux-androideabi
74        sparc64-unknown-linux-gnu
75        sparcv9-sun-solaris
76        aarch64-linux-android
77        aarch64-apple-ios
78    - if: matrix.rust == 'nightly'
79      run: rustup target add x86_64-unknown-fuchsia
80    - if: matrix.rust != 'nightly'
81      run: rustup target add x86_64-fuchsia
82
83    - name: Install cross-compilation tools
84      run: |
85        set -ex
86        sudo apt-get update
87        sudo apt-get install -y gcc-i686-linux-gnu gcc-aarch64-linux-gnu gcc-riscv64-linux-gnu gcc-arm-linux-gnueabi musl-tools
88
89    - name: Use specific dependency versions for Rust 1.48 compatibility.
90      if: matrix.rust == '1.48'
91      run: cargo update --package=once_cell --precise 1.14.0
92
93    - run: cargo check --workspace --release -vv --all-targets
94    - run: cargo check --workspace --release -vv --features=all-apis --all-targets
95    - run: cargo check --workspace --release -vv --features=use-libc,all-apis --all-targets
96    - run: cargo check --workspace --release -vv --target=aarch64-linux-android --all-targets
97    - run: cargo check --workspace --release -vv --target=x86_64-unknown-linux-musl --features=all-apis --all-targets
98    - run: cargo check --workspace --release -vv --target=x86_64-unknown-linux-musl --features=use-libc,all-apis --all-targets
99    - run: cargo check --workspace --release -vv --target=x86_64-unknown-linux-gnux32 --features=all-apis --all-targets
100    - run: cargo check --workspace --release -vv --target=x86_64-linux-android --features=all-apis --all-targets
101    - run: cargo check --workspace --release -vv --target=i686-linux-android --features=all-apis --all-targets
102    - run: cargo check --workspace --release -vv --target=x86_64-apple-darwin --features=all-apis --all-targets
103    - run: cargo check --workspace --release -vv --target=x86_64-unknown-freebsd --features=all-apis --all-targets
104    - run: cargo check --workspace --release -vv --target=x86_64-unknown-netbsd --features=all-apis --all-targets
105    - if: matrix.rust == 'nightly'
106      run: cargo check --workspace --release -vv --target=x86_64-unknown-fuchsia --features=all-apis --all-targets
107    - if: matrix.rust != 'nightly'
108      run: cargo check --workspace --release -vv --target=x86_64-fuchsia --features=all-apis --all-targets
109    - run: cargo check --workspace --release -vv --target=x86_64-unknown-illumos --features=all-apis --all-targets
110    - run: cargo check --workspace --release -vv --target=i686-unknown-linux-gnu --features=all-apis --all-targets
111    - run: cargo check --workspace --release -vv --target=i686-unknown-linux-musl --features=all-apis --all-targets
112    - run: cargo check --workspace --release -vv --target=i686-unknown-linux-musl --features=use-libc,all-apis --all-targets
113    - run: cargo check --workspace --release -vv --target=wasm32-unknown-emscripten --features=all-apis --all-targets
114    - run: cargo check --workspace --release -vv --target=riscv64gc-unknown-linux-gnu --features=all-apis --all-targets
115    - run: cargo check --workspace --release -vv --target=aarch64-unknown-linux-gnu --features=all-apis --all-targets
116    - run: cargo check --workspace --release -vv --target=aarch64-unknown-linux-musl --features=all-apis --all-targets
117    - run: cargo check --workspace --release -vv --target=aarch64-unknown-linux-musl --features=use-libc,all-apis --all-targets
118    - run: cargo check --workspace --release -vv --target=powerpc64le-unknown-linux-gnu --features=all-apis --all-targets
119    - run: cargo check --workspace --release -vv --target=mipsel-unknown-linux-gnu --features=all-apis --all-targets
120    - run: cargo check --workspace --release -vv --target=mips64el-unknown-linux-gnuabi64 --features=all-apis --all-targets
121    - run: cargo check --workspace --release -vv --target=armv5te-unknown-linux-gnueabi --features=all-apis --all-targets
122    - run: cargo check --workspace --release -vv --target=s390x-unknown-linux-gnu --features=all-apis --all-targets
123    - run: cargo check --workspace --release -vv --target=arm-linux-androideabi --features=all-apis --all-targets
124    - run: cargo check --workspace --release -vv --target=sparc64-unknown-linux-gnu --features=all-apis --all-targets
125    - run: cargo check --workspace --release -vv --target=sparcv9-sun-solaris --features=all-apis --all-targets
126    - run: cargo check --workspace --release -vv --target=aarch64-apple-ios --features=all-apis --all-targets
127    - run: cargo check --workspace --release -vv --target=aarch64-linux-android --features=all-apis --all-targets
128
129  check_no_default_features:
130    name: Check --no-default-features
131    runs-on: ${{ matrix.os }}
132    strategy:
133      matrix:
134        build: [nightly]
135        include:
136          - build: nightly
137            os: ubuntu-latest
138            rust: nightly
139
140    env:
141      # -D warnings is commented out in our install-rust action; re-add it here.
142      RUSTFLAGS: -D warnings
143    steps:
144    - uses: actions/checkout@v3
145      with:
146        submodules: true
147    - uses: ./.github/actions/install-rust
148      with:
149        toolchain: ${{ matrix.rust }}
150    - run: cargo check --workspace --release --no-default-features -vv
151    - run: cargo check --workspace --release --no-default-features --features all-apis -vv
152
153  check_nightly:
154    name: Check nightly-only targets
155    runs-on: ${{ matrix.os }}
156    strategy:
157      matrix:
158        build: [nightly]
159        include:
160          - build: nightly
161            os: ubuntu-latest
162            rust: nightly
163
164    steps:
165    - uses: actions/checkout@v3
166      with:
167        submodules: true
168    - uses: ./.github/actions/install-rust
169      with:
170        toolchain: ${{ matrix.rust }}
171    - run: >
172        rustup target add
173        x86_64-unknown-redox
174        wasm32-wasi
175        thumbv7neon-unknown-linux-gnueabihf
176    - run: cargo check --workspace --release -vv --target=x86_64-unknown-redox --features=all-apis
177    - run: cargo check --workspace --release -vv --target=wasm32-wasi --features=all-apis
178    - run: cargo check --workspace --release -vv --target=thumbv7neon-unknown-linux-gnueabihf --features=all-apis
179
180  check_tier3:
181    name: Check selected Tier 3 platforms
182    runs-on: ${{ matrix.os }}
183    strategy:
184      matrix:
185        build: [nightly]
186        include:
187          - build: nightly
188            os: ubuntu-latest
189            rust: nightly
190
191    steps:
192    - uses: actions/checkout@v3
193      with:
194        submodules: true
195    - uses: ./.github/actions/install-rust
196      with:
197        toolchain: ${{ matrix.rust }}
198      env:
199        # See the comments in the libc crate
200        RUSTFLAGS: -A improper_ctypes_definitions --cfg criterion
201    - run: rustup component add rust-src
202    - run: cargo check -Z build-std --target x86_64-unknown-openbsd --all-targets --features=all-apis
203    - run: cargo check -Z build-std --target mips64-openwrt-linux-musl --all-targets --features=all-apis
204    - run: cargo check -Z build-std --target x86_64-unknown-dragonfly --all-targets --features=all-apis
205    - run: cargo check -Z build-std --target sparc-unknown-linux-gnu --all-targets --features=all-apis
206    - run: cargo check -Z build-std --target armv7-unknown-freebsd --all-targets --features=all-apis
207    # Omit --all-targets on haiku because not all the tests build yet.
208    - run: cargo check -Z build-std --target x86_64-unknown-haiku --features=all-apis
209    # x86_64-uwp-windows-msvc isn't currently working.
210    #- run: cargo check -Z build-std --target x86_64-uwp-windows-msvc --all-targets --features=all-apis
211
212  test:
213    name: Test
214    runs-on: ${{ matrix.os }}
215    env:
216      QEMU_BUILD_VERSION: 7.0.0
217    strategy:
218      matrix:
219        build: [ubuntu, ubuntu-18.04, i686-linux, aarch64-linux, powerpc64le-linux, riscv64-linux, s390x-linux, arm-linux, ubuntu-stable, ubuntu-1.48, i686-linux-stable, aarch64-linux-stable, riscv64-linux-stable, s390x-linux-stable, mipsel-linux-stable, mips64el-linux-stable, powerpc64le-linux-stable, arm-linux-stable, ubuntu-1.48, i686-linux-1.48, aarch64-linux-1.48, riscv64-linux-1.48, s390x-linux-1.48, mipsel-linux-1.48, mips64el-linux-1.48, powerpc64le-linux-1.48, arm-linux-1.48, macos-latest, macos-10.15, windows, windows-2019]
220        include:
221          - build: ubuntu
222            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
223            rust: nightly
224          - build: ubuntu-18.04
225            os: ubuntu-18.04
226            rust: nightly
227          - build: i686-linux
228            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
229            rust: nightly
230            target: i686-unknown-linux-gnu
231            gcc_package: gcc-i686-linux-gnu
232            gcc: i686-linux-gnu-gcc
233            libc_package: libc-dev-i386-cross
234          - build: aarch64-linux
235            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
236            rust: nightly
237            target: aarch64-unknown-linux-gnu
238            gcc_package: gcc-aarch64-linux-gnu
239            gcc: aarch64-linux-gnu-gcc
240            qemu: qemu-aarch64
241            qemu_args: -L /usr/aarch64-linux-gnu
242            qemu_target: aarch64-linux-user
243          - build: powerpc64le-linux
244            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
245            rust: nightly
246            target: powerpc64le-unknown-linux-gnu
247            gcc_package: gcc-powerpc64le-linux-gnu
248            gcc: powerpc64le-linux-gnu-gcc
249            qemu: qemu-ppc64le
250            qemu_args: -L /usr/powerpc64le-linux-gnu
251            qemu_target: ppc64le-linux-user
252          - build: mips64el-linux
253            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
254            rust: nightly
255            target: mips64el-unknown-linux-gnuabi64
256            gcc_package: gcc-mips64el-linux-gnuabi64
257            gcc: mips64el-linux-gnuabi64-gcc
258            qemu: qemu-mips64el
259            qemu_args: -L /usr/mips64el-linux-gnuabi64
260            qemu_target: mips64el-linux-user
261          - build: mipsel-linux
262            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
263            rust: nightly
264            target: mipsel-unknown-linux-gnu
265            gcc_package: gcc-mipsel-linux-gnu
266            gcc: mipsel-linux-gnu-gcc
267            qemu: qemu-mipsel
268            qemu_args: -L /usr/mipsel-linux-gnu
269            qemu_target: mipsel-linux-user
270          - build: riscv64-linux
271            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
272            rust: nightly
273            target: riscv64gc-unknown-linux-gnu
274            gcc_package: gcc-riscv64-linux-gnu
275            gcc: riscv64-linux-gnu-gcc
276            qemu: qemu-riscv64
277            qemu_args: -L /usr/riscv64-linux-gnu
278            qemu_target: riscv64-linux-user
279          - build: s390x-linux
280            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
281            rust: nightly
282            target: s390x-unknown-linux-gnu
283            gcc_package: gcc-s390x-linux-gnu
284            gcc: s390x-linux-gnu-gcc
285            qemu: qemu-s390x
286            qemu_args: -L /usr/s390x-linux-gnu
287            qemu_target: s390x-linux-user
288          - build: arm-linux
289            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
290            rust: nightly
291            target: armv5te-unknown-linux-gnueabi
292            gcc_package: gcc-arm-linux-gnueabi
293            gcc: arm-linux-gnueabi-gcc
294            qemu: qemu-arm
295            qemu_args: -L /usr/arm-linux-gnueabi
296            qemu_target: arm-linux-user
297          - build: ubuntu-stable
298            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
299            rust: stable
300          - build: i686-linux-stable
301            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
302            rust: stable
303            target: i686-unknown-linux-gnu
304            gcc_package: gcc-i686-linux-gnu
305            gcc: i686-linux-gnu-gcc
306            libc_package: libc-dev-i386-cross
307          - build: aarch64-linux-stable
308            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
309            rust: stable
310            target: aarch64-unknown-linux-gnu
311            gcc_package: gcc-aarch64-linux-gnu
312            gcc: aarch64-linux-gnu-gcc
313            qemu: qemu-aarch64
314            qemu_args: -L /usr/aarch64-linux-gnu
315            qemu_target: aarch64-linux-user
316          - build: riscv64-linux-stable
317            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
318            rust: stable
319            target: riscv64gc-unknown-linux-gnu
320            gcc_package: gcc-riscv64-linux-gnu
321            gcc: riscv64-linux-gnu-gcc
322            qemu: qemu-riscv64
323            qemu_args: -L /usr/riscv64-linux-gnu
324            qemu_target: riscv64-linux-user
325          - build: s390x-linux-stable
326            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
327            rust: stable
328            target: s390x-unknown-linux-gnu
329            gcc_package: gcc-s390x-linux-gnu
330            gcc: s390x-linux-gnu-gcc
331            qemu: qemu-s390x
332            qemu_args: -L /usr/s390x-linux-gnu
333            qemu_target: s390x-linux-user
334          - build: powerpc64le-linux-stable
335            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
336            rust: stable
337            target: powerpc64le-unknown-linux-gnu
338            gcc_package: gcc-powerpc64le-linux-gnu
339            gcc: powerpc64le-linux-gnu-gcc
340            qemu: qemu-ppc64le
341            qemu_args: -L /usr/powerpc64le-linux-gnu
342            qemu_target: ppc64le-linux-user
343          - build: mips64el-linux-stable
344            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
345            rust: stable
346            target: mips64el-unknown-linux-gnuabi64
347            gcc_package: gcc-mips64el-linux-gnuabi64
348            gcc: mips64el-linux-gnuabi64-gcc
349            qemu: qemu-mips64el
350            qemu_args: -L /usr/mips64el-linux-gnuabi64
351            qemu_target: mips64el-linux-user
352          - build: mipsel-linux-stable
353            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
354            rust: stable
355            target: mipsel-unknown-linux-gnu
356            gcc_package: gcc-mipsel-linux-gnu
357            gcc: mipsel-linux-gnu-gcc
358            qemu: qemu-mipsel
359            qemu_args: -L /usr/mipsel-linux-gnu
360            qemu_target: mipsel-linux-user
361          - build: arm-linux-stable
362            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
363            rust: stable
364            target: armv5te-unknown-linux-gnueabi
365            gcc_package: gcc-arm-linux-gnueabi
366            gcc: arm-linux-gnueabi-gcc
367            qemu: qemu-arm
368            qemu_args: -L /usr/arm-linux-gnueabi
369            qemu_target: arm-linux-user
370          - build: ubuntu-1.48
371            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
372            rust: 1.48
373          - build: i686-linux-1.48
374            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
375            rust: 1.48
376            target: i686-unknown-linux-gnu
377            gcc_package: gcc-i686-linux-gnu
378            gcc: i686-linux-gnu-gcc
379            libc_package: libc-dev-i386-cross
380          - build: aarch64-linux-1.48
381            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
382            rust: 1.48
383            target: aarch64-unknown-linux-gnu
384            gcc_package: gcc-aarch64-linux-gnu
385            gcc: aarch64-linux-gnu-gcc
386            qemu: qemu-aarch64
387            qemu_args: -L /usr/aarch64-linux-gnu
388            qemu_target: aarch64-linux-user
389          - build: riscv64-linux-1.48
390            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
391            rust: 1.48
392            target: riscv64gc-unknown-linux-gnu
393            gcc_package: gcc-riscv64-linux-gnu
394            gcc: riscv64-linux-gnu-gcc
395            qemu: qemu-riscv64
396            qemu_args: -L /usr/riscv64-linux-gnu
397            qemu_target: riscv64-linux-user
398          - build: s390x-linux-1.48
399            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
400            rust: 1.48
401            target: s390x-unknown-linux-gnu
402            gcc_package: gcc-s390x-linux-gnu
403            gcc: s390x-linux-gnu-gcc
404            qemu: qemu-s390x
405            qemu_args: -L /usr/s390x-linux-gnu
406            qemu_target: s390x-linux-user
407          - build: powerpc64le-linux-1.48
408            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
409            rust: 1.48
410            target: powerpc64le-unknown-linux-gnu
411            gcc_package: gcc-powerpc64le-linux-gnu
412            gcc: powerpc64le-linux-gnu-gcc
413            qemu: qemu-ppc64le
414            qemu_args: -L /usr/powerpc64le-linux-gnu
415            qemu_target: ppc64le-linux-user
416          - build: mips64el-linux-1.48
417            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
418            rust: 1.48
419            target: mips64el-unknown-linux-gnuabi64
420            gcc_package: gcc-mips64el-linux-gnuabi64
421            gcc: mips64el-linux-gnuabi64-gcc
422            qemu: qemu-mips64el
423            qemu_args: -L /usr/mips64el-linux-gnuabi64
424            qemu_target: mips64el-linux-user
425          - build: mipsel-linux-1.48
426            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
427            rust: 1.48
428            target: mipsel-unknown-linux-gnu
429            gcc_package: gcc-mipsel-linux-gnu
430            gcc: mipsel-linux-gnu-gcc
431            qemu: qemu-mipsel
432            qemu_args: -L /usr/mipsel-linux-gnu
433            qemu_target: mipsel-linux-user
434          - build: arm-linux-1.48
435            os: ubuntu-20.04 # TODO: remove pin when fixed (#483)
436            rust: 1.48
437            target: armv5te-unknown-linux-gnueabi
438            gcc_package: gcc-arm-linux-gnueabi
439            gcc: arm-linux-gnueabi-gcc
440            qemu: qemu-arm
441            qemu_args: -L /usr/arm-linux-gnueabi
442            qemu_target: arm-linux-user
443          - build: macos-latest
444            os: macos-latest
445            rust: stable
446          - build: macos-10.15
447            os: macos-10.15
448            rust: stable
449          - build: windows
450            os: windows-latest
451            rust: nightly
452          - build: windows-2019
453            os: windows-2019
454            rust: nightly
455    steps:
456    - uses: actions/checkout@v3
457      with:
458        submodules: true
459    - uses: ./.github/actions/install-rust
460      with:
461        toolchain: ${{ matrix.rust }}
462
463    - name: Configure Cargo target
464      run: |
465        echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
466        rustup target add ${{ matrix.target }}
467      if: matrix.target != ''
468
469    - uses: actions/cache@v3
470      with:
471        path: ${{ runner.tool_cache }}/qemu
472        key: qemu-${{ matrix.target }}-${{ env.QEMU_BUILD_VERSION }}-patched
473      if: matrix.target != '' && matrix.os == 'ubuntu-20.04' # TODO: remove pin when fixed (#483)
474
475    - name: Install cross-compilation tools
476      run: |
477        set -ex
478        sudo apt-get update
479        sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build
480        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
481        echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV
482      if: matrix.gcc_package != '' && matrix.os == 'ubuntu-20.04' # TODO: remove pin when fixed (#483)
483
484    - name: Install cross-compilation libraries
485      run: |
486        set -ex
487        sudo apt-get update
488        sudo apt-get install -y ${{ matrix.libc_package }}
489      if: matrix.libc_package != '' && matrix.os == 'ubuntu-20.04' # TODO: remove pin when fixed (#483)
490
491    - name: Install qemu
492      run: |
493        set -ex
494
495        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
496        echo CARGO_TARGET_${upcase}_RUNNER=${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ${{ matrix.qemu_args }} >> $GITHUB_ENV
497
498        # See if qemu is already in the cache
499        if [ -f ${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ]; then
500          exit 0
501        fi
502
503        # Download and build qemu from source since the most recent release is
504        # way faster at arm emulation than the current version github actions'
505        # ubuntu image uses. Disable as much as we can to get it to build
506        # quickly.
507        cd
508        curl https://download.qemu.org/qemu-$QEMU_BUILD_VERSION.tar.xz | tar xJf -
509        cd qemu-$QEMU_BUILD_VERSION
510        patch -p1 < $GITHUB_WORKSPACE/ci/translate-errno.patch
511        patch -p1 < $GITHUB_WORKSPACE/ci/getsockopt-timeouts.patch
512        patch -p1 < $GITHUB_WORKSPACE/ci/s390x-stat-have-nsec.patch
513        ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache }}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs
514        ninja -C build install
515      if: matrix.qemu != '' && matrix.os == 'ubuntu-20.04' # TODO: remove pin when fixed (#483)
516
517    - name: Use specific dependency versions for Rust 1.48 compatibility.
518      if: matrix.rust == '1.48'
519      run: cargo update --package=once_cell --precise 1.14.0
520
521    - run: |
522        # Run the tests, and check the prebuilt release libraries.
523        cargo test --verbose --features=all-impls,all-apis,cc --release --workspace -- --nocapture
524      env:
525        RUST_BACKTRACE: full
526      if: matrix.rust != '1.48'
527
528    - run: |
529        # Run the tests with Rust 1.48, and check the prebuilt release libraries.
530        # Don't use all-impls because some of the impls have dependencies that
531        # don't support Rust 1.48.
532        cargo test --verbose --features=fs-err,all-apis,cc --release --workspace -- --nocapture
533      env:
534        RUST_BACKTRACE: full
535      if: matrix.rust == '1.48'
536
537    - run: |
538        # Check the prebuilt debug libraries too.
539        cargo check --features=all-impls,all-apis,cc
540      env:
541        RUST_BACKTRACE: full
542      if: matrix.rust != '1.48'
543
544    - run: |
545        # Check the prebuilt debug libraries with Rust 1.48 too.
546        # Don't use all-impls because some of the impls have dependencies that
547        # don't support Rust 1.48.
548        cargo check --features=fs-err,all-apis,cc
549      env:
550        RUST_BACKTRACE: full
551      if: matrix.rust == '1.48'
552
553  test_use_libc:
554    name: Test use-libc
555    runs-on: ${{ matrix.os }}
556    strategy:
557      matrix:
558        build: [ubuntu, i686-linux, aarch64-linux, powerpc64le-linux, mips64el-linux, mipsel-linux, riscv64-linux, arm-linux]
559        include:
560          - build: ubuntu
561            os: ubuntu-latest
562            rust: stable
563          - build: i686-linux
564            os: ubuntu-latest
565            rust: stable
566            target: i686-unknown-linux-gnu
567            gcc_package: gcc-i686-linux-gnu
568            gcc: i686-linux-gnu-gcc
569            libc_package: libc-dev-i386-cross
570          - build: aarch64-linux
571            os: ubuntu-latest
572            rust: stable
573            target: aarch64-unknown-linux-gnu
574            gcc_package: gcc-aarch64-linux-gnu
575            gcc: aarch64-linux-gnu-gcc
576            qemu: qemu-aarch64
577            qemu_args: -L /usr/aarch64-linux-gnu
578            qemu_target: aarch64-linux-user
579          - build: powerpc64le-linux
580            os: ubuntu-latest
581            rust: stable
582            target: powerpc64le-unknown-linux-gnu
583            gcc_package: gcc-powerpc64le-linux-gnu
584            gcc: powerpc64le-linux-gnu-gcc
585            qemu: qemu-ppc64le
586            qemu_args: -L /usr/powerpc64le-linux-gnu
587            qemu_target: ppc64le-linux-user
588          - build: mips64el-linux
589            os: ubuntu-latest
590            rust: stable
591            target: mips64el-unknown-linux-gnuabi64
592            gcc_package: gcc-mips64el-linux-gnuabi64
593            gcc: mips64el-linux-gnuabi64-gcc
594            qemu: qemu-mips64el
595            qemu_args: -L /usr/mips64el-linux-gnuabi64
596            qemu_target: mips64el-linux-user
597          - build: mipsel-linux
598            os: ubuntu-latest
599            rust: stable
600            target: mipsel-unknown-linux-gnu
601            gcc_package: gcc-mipsel-linux-gnu
602            gcc: mipsel-linux-gnu-gcc
603            qemu: qemu-mipsel
604            qemu_args: -L /usr/mipsel-linux-gnu
605            qemu_target: mipsel-linux-user
606          - build: riscv64-linux
607            os: ubuntu-latest
608            rust: stable
609            target: riscv64gc-unknown-linux-gnu
610            gcc_package: gcc-riscv64-linux-gnu
611            gcc: riscv64-linux-gnu-gcc
612            qemu: qemu-riscv64
613            qemu_args: -L /usr/riscv64-linux-gnu
614            qemu_target: riscv64-linux-user
615          - build: arm-linux
616            os: ubuntu-latest
617            rust: stable
618            target: armv7-unknown-linux-gnueabihf
619            gcc_package: gcc-arm-linux-gnueabihf
620            gcc: arm-linux-gnueabihf-gcc
621            qemu: qemu-arm
622            qemu_args: -L /usr/arm-linux-gnueabihf
623            qemu_target: arm-linux-user
624    env:
625      # -D warnings is commented out in our install-rust action; re-add it here.
626      RUSTFLAGS: -D warnings
627      QEMU_BUILD_VERSION: 7.0.0
628    steps:
629    - uses: actions/checkout@v3
630      with:
631        submodules: true
632    - uses: ./.github/actions/install-rust
633      with:
634        toolchain: ${{ matrix.rust }}
635
636    - name: Configure Cargo target
637      run: |
638        echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
639        rustup target add ${{ matrix.target }}
640      if: matrix.target != ''
641
642    - uses: actions/cache@v3
643      with:
644        path: ${{ runner.tool_cache }}/qemu
645        key: qemu-${{ matrix.target }}-${{ env.QEMU_BUILD_VERSION }}-patched
646      if: matrix.target != '' && matrix.os == 'ubuntu-latest'
647
648    - name: Install cross-compilation tools
649      run: |
650        set -ex
651        sudo apt-get update
652        sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build
653        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
654        echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV
655      if: matrix.gcc_package != '' && matrix.os == 'ubuntu-latest'
656
657    - name: Install cross-compilation libraries
658      run: |
659        set -ex
660        sudo apt-get update
661        sudo apt-get install -y ${{ matrix.libc_package }}
662      if: matrix.libc_package != '' && matrix.os == 'ubuntu-latest'
663
664    - name: Install qemu
665      run: |
666        set -ex
667
668        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
669        echo CARGO_TARGET_${upcase}_RUNNER=${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ${{ matrix.qemu_args }} >> $GITHUB_ENV
670
671        # See if qemu is already in the cache
672        if [ -f ${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ]; then
673          exit 0
674        fi
675
676        # Download and build qemu from source since the most recent release is
677        # way faster at arm emulation than the current version github actions'
678        # ubuntu image uses. Disable as much as we can to get it to build
679        # quickly.
680        cd
681        curl https://download.qemu.org/qemu-$QEMU_BUILD_VERSION.tar.xz | tar xJf -
682        cd qemu-$QEMU_BUILD_VERSION
683        patch -p1 < $GITHUB_WORKSPACE/ci/translate-errno.patch
684        patch -p1 < $GITHUB_WORKSPACE/ci/getsockopt-timeouts.patch
685        patch -p1 < $GITHUB_WORKSPACE/ci/s390x-stat-have-nsec.patch
686        ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache }}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs
687        ninja -C build install
688      if: matrix.qemu != '' && matrix.os == 'ubuntu-latest'
689
690    - run: |
691        cargo test --verbose --features=use-libc,all-impls,all-apis --release --workspace -- --nocapture
692      env:
693        RUST_BACKTRACE: full
694
695  test_rustix_use_experimental_asm:
696    name: Test rustix_use_experimental_asm
697    runs-on: ${{ matrix.os }}
698    strategy:
699      matrix:
700        build: [powerpc64le-linux, mipsel-linux, mips64el-linux]
701        include:
702          - build: powerpc64le-linux
703            os: ubuntu-latest
704            rust: nightly
705            target: powerpc64le-unknown-linux-gnu
706            gcc_package: gcc-powerpc64le-linux-gnu
707            gcc: powerpc64le-linux-gnu-gcc
708            qemu: qemu-ppc64le
709            qemu_args: -L /usr/powerpc64le-linux-gnu
710            qemu_target: ppc64le-linux-user
711          - build: mips64el-linux
712            os: ubuntu-latest
713            rust: nightly
714            target: mips64el-unknown-linux-gnuabi64
715            gcc_package: gcc-mips64el-linux-gnuabi64
716            gcc: mips64el-linux-gnuabi64-gcc
717            qemu: qemu-mips64el
718            qemu_args: -L /usr/mips64el-linux-gnuabi64
719            qemu_target: mips64el-linux-user
720          - build: mipsel-linux
721            os: ubuntu-latest
722            rust: nightly
723            target: mipsel-unknown-linux-gnu
724            gcc_package: gcc-mipsel-linux-gnu
725            gcc: mipsel-linux-gnu-gcc
726            qemu: qemu-mipsel
727            qemu_args: -L /usr/mipsel-linux-gnu
728            qemu_target: mipsel-linux-user
729    env:
730      # -D warnings is commented out in our install-rust action; re-add it here.
731      RUSTFLAGS: --cfg rustix_use_experimental_asm -D warnings
732      RUSTDOCFLAGS: --cfg rustix_use_experimental_asm
733      CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_RUSTFLAGS: --cfg rustix_use_experimental_asm
734      CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_RUSTFLAGS: --cfg rustix_use_experimental_asm
735      CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_RUSTFLAGS: --cfg rustix_use_experimental_asm
736      QEMU_BUILD_VERSION: 7.0.0
737    steps:
738    - uses: actions/checkout@v3
739      with:
740        submodules: true
741    - uses: ./.github/actions/install-rust
742      with:
743        toolchain: ${{ matrix.rust }}
744
745    - name: Configure Cargo target
746      run: |
747        echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
748        rustup target add ${{ matrix.target }}
749      if: matrix.target != ''
750
751    - uses: actions/cache@v3
752      with:
753        path: ${{ runner.tool_cache }}/qemu
754        key: qemu-${{ matrix.target }}-${{ env.QEMU_BUILD_VERSION }}-patched
755      if: matrix.target != '' && matrix.os == 'ubuntu-latest'
756
757    - name: Install cross-compilation tools
758      run: |
759        set -ex
760        sudo apt-get update
761        sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build
762        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
763        echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV
764      if: matrix.gcc_package != '' && matrix.os == 'ubuntu-latest'
765
766    - name: Install cross-compilation libraries
767      run: |
768        set -ex
769        sudo apt-get update
770        sudo apt-get install -y ${{ matrix.libc_package }}
771      if: matrix.libc_package != '' && matrix.os == 'ubuntu-latest'
772
773    - name: Install qemu
774      run: |
775        set -ex
776
777        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
778        echo CARGO_TARGET_${upcase}_RUNNER=${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ${{ matrix.qemu_args }} >> $GITHUB_ENV
779
780        # See if qemu is already in the cache
781        if [ -f ${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ]; then
782          exit 0
783        fi
784
785        # Download and build qemu from source since the most recent release is
786        # way faster at arm emulation than the current version github actions'
787        # ubuntu image uses. Disable as much as we can to get it to build
788        # quickly.
789        cd
790        curl https://download.qemu.org/qemu-$QEMU_BUILD_VERSION.tar.xz | tar xJf -
791        cd qemu-$QEMU_BUILD_VERSION
792        patch -p1 < $GITHUB_WORKSPACE/ci/translate-errno.patch
793        patch -p1 < $GITHUB_WORKSPACE/ci/getsockopt-timeouts.patch
794        patch -p1 < $GITHUB_WORKSPACE/ci/s390x-stat-have-nsec.patch
795        ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache }}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs
796        ninja -C build install
797      if: matrix.qemu != '' && matrix.os == 'ubuntu-latest'
798
799    - run: |
800        cargo test --verbose --features=all-impls,all-apis --release --workspace -- --nocapture
801      env:
802        RUST_BACKTRACE: full
803