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