1b8a62b91Sopenharmony_ci# Test a selection of projects which depend on rustix.
2b8a62b91Sopenharmony_ci
3b8a62b91Sopenharmony_ciname: Test rustix's users
4b8a62b91Sopenharmony_ci
5b8a62b91Sopenharmony_cion: workflow_dispatch
6b8a62b91Sopenharmony_ci
7b8a62b91Sopenharmony_cijobs:
8b8a62b91Sopenharmony_ci  listenfd:
9b8a62b91Sopenharmony_ci    name: listenfd ported to rustix
10b8a62b91Sopenharmony_ci    runs-on: ${{ matrix.os }}
11b8a62b91Sopenharmony_ci    env:
12b8a62b91Sopenharmony_ci      QEMU_BUILD_VERSION: 7.0.0
13b8a62b91Sopenharmony_ci    strategy:
14b8a62b91Sopenharmony_ci      matrix:
15b8a62b91Sopenharmony_ci        build: [ubuntu, i686-linux, aarch64-linux, powerpc64le-linux, riscv64-linux, mipsel-linux, mips64el-linux, arm-linux, macos-latest]
16b8a62b91Sopenharmony_ci        include:
17b8a62b91Sopenharmony_ci          - build: ubuntu
18b8a62b91Sopenharmony_ci            os: ubuntu-latest
19b8a62b91Sopenharmony_ci            rust: nightly
20b8a62b91Sopenharmony_ci          - build: i686-linux
21b8a62b91Sopenharmony_ci            os: ubuntu-latest
22b8a62b91Sopenharmony_ci            rust: nightly
23b8a62b91Sopenharmony_ci            target: i686-unknown-linux-gnu
24b8a62b91Sopenharmony_ci            gcc_package: gcc-i686-linux-gnu
25b8a62b91Sopenharmony_ci            gcc: i686-linux-gnu-gcc
26b8a62b91Sopenharmony_ci            libc_package: libc-dev-i386-cross
27b8a62b91Sopenharmony_ci          - build: aarch64-linux
28b8a62b91Sopenharmony_ci            os: ubuntu-latest
29b8a62b91Sopenharmony_ci            rust: nightly
30b8a62b91Sopenharmony_ci            target: aarch64-unknown-linux-gnu
31b8a62b91Sopenharmony_ci            gcc_package: gcc-aarch64-linux-gnu
32b8a62b91Sopenharmony_ci            gcc: aarch64-linux-gnu-gcc
33b8a62b91Sopenharmony_ci            qemu: qemu-aarch64
34b8a62b91Sopenharmony_ci            qemu_args: -L /usr/aarch64-linux-gnu
35b8a62b91Sopenharmony_ci            qemu_target: aarch64-linux-user
36b8a62b91Sopenharmony_ci          - build: powerpc64le-linux
37b8a62b91Sopenharmony_ci            os: ubuntu-latest
38b8a62b91Sopenharmony_ci            rust: nightly
39b8a62b91Sopenharmony_ci            target: powerpc64le-unknown-linux-gnu
40b8a62b91Sopenharmony_ci            gcc_package: gcc-powerpc64le-linux-gnu
41b8a62b91Sopenharmony_ci            gcc: powerpc64le-linux-gnu-gcc
42b8a62b91Sopenharmony_ci            qemu: qemu-ppc64le
43b8a62b91Sopenharmony_ci            qemu_args: -L /usr/powerpc64le-linux-gnu
44b8a62b91Sopenharmony_ci            qemu_target: ppc64le-linux-user
45b8a62b91Sopenharmony_ci          - build: mips64el-linux
46b8a62b91Sopenharmony_ci            os: ubuntu-latest
47b8a62b91Sopenharmony_ci            rust: nightly
48b8a62b91Sopenharmony_ci            target: mips64el-unknown-linux-gnuabi64
49b8a62b91Sopenharmony_ci            gcc_package: gcc-mips64el-linux-gnuabi64
50b8a62b91Sopenharmony_ci            gcc: mips64el-linux-gnuabi64-gcc
51b8a62b91Sopenharmony_ci            qemu: qemu-mips64el
52b8a62b91Sopenharmony_ci            qemu_args: -L /usr/mips64el-linux-gnuabi64
53b8a62b91Sopenharmony_ci            qemu_target: mips64el-linux-user
54b8a62b91Sopenharmony_ci          - build: mipsel-linux
55b8a62b91Sopenharmony_ci            os: ubuntu-latest
56b8a62b91Sopenharmony_ci            rust: nightly
57b8a62b91Sopenharmony_ci            target: mipsel-unknown-linux-gnu
58b8a62b91Sopenharmony_ci            gcc_package: gcc-mipsel-linux-gnu
59b8a62b91Sopenharmony_ci            gcc: mipsel-linux-gnu-gcc
60b8a62b91Sopenharmony_ci            qemu: qemu-mipsel
61b8a62b91Sopenharmony_ci            qemu_args: -L /usr/mipsel-linux-gnu
62b8a62b91Sopenharmony_ci            qemu_target: mipsel-linux-user
63b8a62b91Sopenharmony_ci          - build: riscv64-linux
64b8a62b91Sopenharmony_ci            os: ubuntu-latest
65b8a62b91Sopenharmony_ci            rust: nightly
66b8a62b91Sopenharmony_ci            target: riscv64gc-unknown-linux-gnu
67b8a62b91Sopenharmony_ci            gcc_package: gcc-riscv64-linux-gnu
68b8a62b91Sopenharmony_ci            gcc: riscv64-linux-gnu-gcc
69b8a62b91Sopenharmony_ci            qemu: qemu-riscv64
70b8a62b91Sopenharmony_ci            qemu_args: -L /usr/riscv64-linux-gnu
71b8a62b91Sopenharmony_ci            qemu_target: riscv64-linux-user
72b8a62b91Sopenharmony_ci          - build: arm-linux
73b8a62b91Sopenharmony_ci            os: ubuntu-latest
74b8a62b91Sopenharmony_ci            rust: nightly
75b8a62b91Sopenharmony_ci            target: armv5te-unknown-linux-gnueabi
76b8a62b91Sopenharmony_ci            gcc_package: gcc-arm-linux-gnueabi
77b8a62b91Sopenharmony_ci            gcc: arm-linux-gnueabi-gcc
78b8a62b91Sopenharmony_ci            qemu: qemu-arm
79b8a62b91Sopenharmony_ci            qemu_args: -L /usr/arm-linux-gnueabi
80b8a62b91Sopenharmony_ci            qemu_target: arm-linux-user
81b8a62b91Sopenharmony_ci          - build: macos-latest
82b8a62b91Sopenharmony_ci            os: macos-latest
83b8a62b91Sopenharmony_ci            rust: nightly
84b8a62b91Sopenharmony_ci    steps:
85b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
86b8a62b91Sopenharmony_ci    - uses: ./.github/actions/install-rust
87b8a62b91Sopenharmony_ci      with:
88b8a62b91Sopenharmony_ci        toolchain: ${{ matrix.rust }}
89b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
90b8a62b91Sopenharmony_ci      with:
91b8a62b91Sopenharmony_ci        repository: sunfishcode/rust-listenfd
92b8a62b91Sopenharmony_ci        path: rust-listenfd
93b8a62b91Sopenharmony_ci        ref: rustix-0.35.6-beta.2
94b8a62b91Sopenharmony_ci
95b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
96b8a62b91Sopenharmony_ci      with:
97b8a62b91Sopenharmony_ci        repository: davidedelpapa/thttp
98b8a62b91Sopenharmony_ci        path: thttp
99b8a62b91Sopenharmony_ci
100b8a62b91Sopenharmony_ci    - name: Configure Cargo target
101b8a62b91Sopenharmony_ci      run: |
102b8a62b91Sopenharmony_ci        echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
103b8a62b91Sopenharmony_ci        rustup target add ${{ matrix.target }}
104b8a62b91Sopenharmony_ci      if: matrix.target != ''
105b8a62b91Sopenharmony_ci
106b8a62b91Sopenharmony_ci    - uses: actions/cache@v3
107b8a62b91Sopenharmony_ci      with:
108b8a62b91Sopenharmony_ci        path: ${{ runner.tool_cache }}/qemu
109b8a62b91Sopenharmony_ci        key: qemu-${{ matrix.target }}-${{ env.QEMU_BUILD_VERSION }}-patched
110b8a62b91Sopenharmony_ci      if: matrix.target != '' && matrix.os == 'ubuntu-latest'
111b8a62b91Sopenharmony_ci
112b8a62b91Sopenharmony_ci    - name: Install cross-compilation tools
113b8a62b91Sopenharmony_ci      run: |
114b8a62b91Sopenharmony_ci        set -ex
115b8a62b91Sopenharmony_ci        sudo apt-get update
116b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build
117b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
118b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV
119b8a62b91Sopenharmony_ci        echo CC_${{ matrix.target }}=${{ matrix.gcc }} >> $GITHUB_ENV
120b8a62b91Sopenharmony_ci      if: matrix.gcc_package != '' && matrix.os == 'ubuntu-latest'
121b8a62b91Sopenharmony_ci
122b8a62b91Sopenharmony_ci    - name: Install cross-compilation libraries
123b8a62b91Sopenharmony_ci      run: |
124b8a62b91Sopenharmony_ci        set -ex
125b8a62b91Sopenharmony_ci        sudo apt-get update
126b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.libc_package }}
127b8a62b91Sopenharmony_ci      if: matrix.libc_package != '' && matrix.os == 'ubuntu-latest'
128b8a62b91Sopenharmony_ci
129b8a62b91Sopenharmony_ci    - name: Install qemu
130b8a62b91Sopenharmony_ci      run: |
131b8a62b91Sopenharmony_ci        set -ex
132b8a62b91Sopenharmony_ci
133b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
134b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_RUNNER=${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ${{ matrix.qemu_args }} >> $GITHUB_ENV
135b8a62b91Sopenharmony_ci
136b8a62b91Sopenharmony_ci        # See if qemu is already in the cache
137b8a62b91Sopenharmony_ci        if [ -f ${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ]; then
138b8a62b91Sopenharmony_ci          exit 0
139b8a62b91Sopenharmony_ci        fi
140b8a62b91Sopenharmony_ci
141b8a62b91Sopenharmony_ci        # Download and build qemu from source since the most recent release is
142b8a62b91Sopenharmony_ci        # way faster at arm emulation than the current version github actions'
143b8a62b91Sopenharmony_ci        # ubuntu image uses. Disable as much as we can to get it to build
144b8a62b91Sopenharmony_ci        # quickly.
145b8a62b91Sopenharmony_ci        cd
146b8a62b91Sopenharmony_ci        curl https://download.qemu.org/qemu-$QEMU_BUILD_VERSION.tar.xz | tar xJf -
147b8a62b91Sopenharmony_ci        cd qemu-$QEMU_BUILD_VERSION
148b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/translate-errno.patch
149b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/getsockopt-timeouts.patch
150b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/s390x-stat-have-nsec.patch
151b8a62b91Sopenharmony_ci        ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache }}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs
152b8a62b91Sopenharmony_ci        ninja -C build install
153b8a62b91Sopenharmony_ci      if: matrix.qemu != '' && matrix.os == 'ubuntu-latest'
154b8a62b91Sopenharmony_ci
155b8a62b91Sopenharmony_ci    - run: cargo install systemfd
156b8a62b91Sopenharmony_ci
157b8a62b91Sopenharmony_ci    - run: cd rust-listenfd && cargo update
158b8a62b91Sopenharmony_ci    - run: sed -i'.bak' 's/^version = "'`cd rust-listenfd && cargo tree --edges=normal |head -1 |sed 's/^[[:alnum:]_-]* v\([[:alnum:].-]*\) (.*/\1/'`'"$/version = '`grep -A1 '^name = "rustix"' rust-listenfd/Cargo.lock |grep ^version |sed 's/^[^"]*//'`'/' Cargo.toml
159b8a62b91Sopenharmony_ci
160b8a62b91Sopenharmony_ci    - run: cd rust-listenfd && echo '[patch.crates-io]' >> Cargo.toml
161b8a62b91Sopenharmony_ci    - run: cd rust-listenfd && echo 'rustix = { path = ".." }' >> Cargo.toml
162b8a62b91Sopenharmony_ci
163b8a62b91Sopenharmony_ci    - run: cd thttp && echo '[patch.crates-io]' >> Cargo.toml
164b8a62b91Sopenharmony_ci    - run: cd thttp && echo 'listenfd = { path = "../rust-listenfd" }' >> Cargo.toml
165b8a62b91Sopenharmony_ci    - run: cd thttp && echo 'rustix = { path = ".." }' >> Cargo.toml
166b8a62b91Sopenharmony_ci
167b8a62b91Sopenharmony_ci    - run: cd thttp && cargo build
168b8a62b91Sopenharmony_ci    - run: cd thttp && systemfd --no-pid -s http::0.0.0.0:5052 -- cargo run &
169b8a62b91Sopenharmony_ci    - run: cd thttp && sleep 5
170b8a62b91Sopenharmony_ci    - run: cd thttp && wget http://127.0.0.1:5052/Cargo.toml
171b8a62b91Sopenharmony_ci    - run: cd thttp && diff -u Cargo.toml Cargo.toml.1
172b8a62b91Sopenharmony_ci
173b8a62b91Sopenharmony_ci  async-io:
174b8a62b91Sopenharmony_ci    name: async-io ported to rustix
175b8a62b91Sopenharmony_ci    runs-on: ${{ matrix.os }}
176b8a62b91Sopenharmony_ci    env:
177b8a62b91Sopenharmony_ci      QEMU_BUILD_VERSION: 7.0.0
178b8a62b91Sopenharmony_ci    strategy:
179b8a62b91Sopenharmony_ci      matrix:
180b8a62b91Sopenharmony_ci        build: [ubuntu, i686-linux, aarch64-linux, powerpc64le-linux, riscv64-linux, mipsel-linux, mips64el-linux, arm-linux, macos-latest]
181b8a62b91Sopenharmony_ci        include:
182b8a62b91Sopenharmony_ci          - build: ubuntu
183b8a62b91Sopenharmony_ci            os: ubuntu-latest
184b8a62b91Sopenharmony_ci            rust: nightly
185b8a62b91Sopenharmony_ci          - build: i686-linux
186b8a62b91Sopenharmony_ci            os: ubuntu-latest
187b8a62b91Sopenharmony_ci            rust: nightly
188b8a62b91Sopenharmony_ci            target: i686-unknown-linux-gnu
189b8a62b91Sopenharmony_ci            gcc_package: gcc-i686-linux-gnu
190b8a62b91Sopenharmony_ci            gcc: i686-linux-gnu-gcc
191b8a62b91Sopenharmony_ci            libc_package: libc-dev-i386-cross
192b8a62b91Sopenharmony_ci          - build: aarch64-linux
193b8a62b91Sopenharmony_ci            os: ubuntu-latest
194b8a62b91Sopenharmony_ci            rust: nightly
195b8a62b91Sopenharmony_ci            target: aarch64-unknown-linux-gnu
196b8a62b91Sopenharmony_ci            gcc_package: gcc-aarch64-linux-gnu
197b8a62b91Sopenharmony_ci            gcc: aarch64-linux-gnu-gcc
198b8a62b91Sopenharmony_ci            qemu: qemu-aarch64
199b8a62b91Sopenharmony_ci            qemu_args: -L /usr/aarch64-linux-gnu
200b8a62b91Sopenharmony_ci            qemu_target: aarch64-linux-user
201b8a62b91Sopenharmony_ci          - build: powerpc64le-linux
202b8a62b91Sopenharmony_ci            os: ubuntu-latest
203b8a62b91Sopenharmony_ci            rust: nightly
204b8a62b91Sopenharmony_ci            target: powerpc64le-unknown-linux-gnu
205b8a62b91Sopenharmony_ci            gcc_package: gcc-powerpc64le-linux-gnu
206b8a62b91Sopenharmony_ci            gcc: powerpc64le-linux-gnu-gcc
207b8a62b91Sopenharmony_ci            qemu: qemu-ppc64le
208b8a62b91Sopenharmony_ci            qemu_args: -L /usr/powerpc64le-linux-gnu
209b8a62b91Sopenharmony_ci            qemu_target: ppc64le-linux-user
210b8a62b91Sopenharmony_ci          - build: mips64el-linux
211b8a62b91Sopenharmony_ci            os: ubuntu-latest
212b8a62b91Sopenharmony_ci            rust: nightly
213b8a62b91Sopenharmony_ci            target: mips64el-unknown-linux-gnuabi64
214b8a62b91Sopenharmony_ci            gcc_package: gcc-mips64el-linux-gnuabi64
215b8a62b91Sopenharmony_ci            gcc: mips64el-linux-gnuabi64-gcc
216b8a62b91Sopenharmony_ci            qemu: qemu-mips64el
217b8a62b91Sopenharmony_ci            qemu_args: -L /usr/mips64el-linux-gnuabi64
218b8a62b91Sopenharmony_ci            qemu_target: mips64el-linux-user
219b8a62b91Sopenharmony_ci          - build: mipsel-linux
220b8a62b91Sopenharmony_ci            os: ubuntu-latest
221b8a62b91Sopenharmony_ci            rust: nightly
222b8a62b91Sopenharmony_ci            target: mipsel-unknown-linux-gnu
223b8a62b91Sopenharmony_ci            gcc_package: gcc-mipsel-linux-gnu
224b8a62b91Sopenharmony_ci            gcc: mipsel-linux-gnu-gcc
225b8a62b91Sopenharmony_ci            qemu: qemu-mipsel
226b8a62b91Sopenharmony_ci            qemu_args: -L /usr/mipsel-linux-gnu
227b8a62b91Sopenharmony_ci            qemu_target: mipsel-linux-user
228b8a62b91Sopenharmony_ci          - build: riscv64-linux
229b8a62b91Sopenharmony_ci            os: ubuntu-latest
230b8a62b91Sopenharmony_ci            rust: nightly
231b8a62b91Sopenharmony_ci            target: riscv64gc-unknown-linux-gnu
232b8a62b91Sopenharmony_ci            gcc_package: gcc-riscv64-linux-gnu
233b8a62b91Sopenharmony_ci            gcc: riscv64-linux-gnu-gcc
234b8a62b91Sopenharmony_ci            qemu: qemu-riscv64
235b8a62b91Sopenharmony_ci            qemu_args: -L /usr/riscv64-linux-gnu
236b8a62b91Sopenharmony_ci            qemu_target: riscv64-linux-user
237b8a62b91Sopenharmony_ci          - build: arm-linux
238b8a62b91Sopenharmony_ci            os: ubuntu-latest
239b8a62b91Sopenharmony_ci            rust: nightly
240b8a62b91Sopenharmony_ci            target: armv5te-unknown-linux-gnueabi
241b8a62b91Sopenharmony_ci            gcc_package: gcc-arm-linux-gnueabi
242b8a62b91Sopenharmony_ci            gcc: arm-linux-gnueabi-gcc
243b8a62b91Sopenharmony_ci            qemu: qemu-arm
244b8a62b91Sopenharmony_ci            qemu_args: -L /usr/arm-linux-gnueabi
245b8a62b91Sopenharmony_ci            qemu_target: arm-linux-user
246b8a62b91Sopenharmony_ci          - build: macos-latest
247b8a62b91Sopenharmony_ci            os: macos-latest
248b8a62b91Sopenharmony_ci            rust: nightly
249b8a62b91Sopenharmony_ci    steps:
250b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
251b8a62b91Sopenharmony_ci    - uses: ./.github/actions/install-rust
252b8a62b91Sopenharmony_ci      with:
253b8a62b91Sopenharmony_ci        toolchain: ${{ matrix.rust }}
254b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
255b8a62b91Sopenharmony_ci      with:
256b8a62b91Sopenharmony_ci        repository: sunfishcode/async-io
257b8a62b91Sopenharmony_ci        path: async-io
258b8a62b91Sopenharmony_ci        ref: rustix-0.35.6-beta.2
259b8a62b91Sopenharmony_ci
260b8a62b91Sopenharmony_ci    - name: Configure Cargo target
261b8a62b91Sopenharmony_ci      run: |
262b8a62b91Sopenharmony_ci        echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
263b8a62b91Sopenharmony_ci        rustup target add ${{ matrix.target }}
264b8a62b91Sopenharmony_ci      if: matrix.target != ''
265b8a62b91Sopenharmony_ci
266b8a62b91Sopenharmony_ci    - uses: actions/cache@v3
267b8a62b91Sopenharmony_ci      with:
268b8a62b91Sopenharmony_ci        path: ${{ runner.tool_cache }}/qemu
269b8a62b91Sopenharmony_ci        key: qemu-${{ matrix.target }}-${{ env.QEMU_BUILD_VERSION }}-patched
270b8a62b91Sopenharmony_ci      if: matrix.target != '' && matrix.os == 'ubuntu-latest'
271b8a62b91Sopenharmony_ci
272b8a62b91Sopenharmony_ci    - name: Install cross-compilation tools
273b8a62b91Sopenharmony_ci      run: |
274b8a62b91Sopenharmony_ci        set -ex
275b8a62b91Sopenharmony_ci        sudo apt-get update
276b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build
277b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
278b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV
279b8a62b91Sopenharmony_ci      if: matrix.gcc_package != '' && matrix.os == 'ubuntu-latest'
280b8a62b91Sopenharmony_ci
281b8a62b91Sopenharmony_ci    - name: Install cross-compilation libraries
282b8a62b91Sopenharmony_ci      run: |
283b8a62b91Sopenharmony_ci        set -ex
284b8a62b91Sopenharmony_ci        sudo apt-get update
285b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.libc_package }}
286b8a62b91Sopenharmony_ci      if: matrix.libc_package != '' && matrix.os == 'ubuntu-latest'
287b8a62b91Sopenharmony_ci
288b8a62b91Sopenharmony_ci    - name: Install qemu
289b8a62b91Sopenharmony_ci      run: |
290b8a62b91Sopenharmony_ci        set -ex
291b8a62b91Sopenharmony_ci
292b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
293b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_RUNNER=${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ${{ matrix.qemu_args }} >> $GITHUB_ENV
294b8a62b91Sopenharmony_ci
295b8a62b91Sopenharmony_ci        # See if qemu is already in the cache
296b8a62b91Sopenharmony_ci        if [ -f ${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ]; then
297b8a62b91Sopenharmony_ci          exit 0
298b8a62b91Sopenharmony_ci        fi
299b8a62b91Sopenharmony_ci
300b8a62b91Sopenharmony_ci        # Download and build qemu from source since the most recent release is
301b8a62b91Sopenharmony_ci        # way faster at arm emulation than the current version github actions'
302b8a62b91Sopenharmony_ci        # ubuntu image uses. Disable as much as we can to get it to build
303b8a62b91Sopenharmony_ci        # quickly.
304b8a62b91Sopenharmony_ci        cd
305b8a62b91Sopenharmony_ci        curl https://download.qemu.org/qemu-$QEMU_BUILD_VERSION.tar.xz | tar xJf -
306b8a62b91Sopenharmony_ci        cd qemu-$QEMU_BUILD_VERSION
307b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/translate-errno.patch
308b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/getsockopt-timeouts.patch
309b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/s390x-stat-have-nsec.patch
310b8a62b91Sopenharmony_ci        ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache }}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs
311b8a62b91Sopenharmony_ci        ninja -C build install
312b8a62b91Sopenharmony_ci      if: matrix.qemu != '' && matrix.os == 'ubuntu-latest'
313b8a62b91Sopenharmony_ci
314b8a62b91Sopenharmony_ci    - run: cd async-io && cargo update
315b8a62b91Sopenharmony_ci    - run: sed -i'.bak' 's/^version = "'`cd async-io && cargo tree --edges=normal |head -1 |sed 's/^[[:alnum:]_-]* v\([[:alnum:].-]*\) (.*/\1/'`'"$/version = '`grep -A1 '^name = "rustix"' async-io/Cargo.lock |grep ^version |sed 's/^[^"]*//'`'/' Cargo.toml
316b8a62b91Sopenharmony_ci    - run: cd async-io && echo '[patch.crates-io]' >> Cargo.toml
317b8a62b91Sopenharmony_ci    - run: cd async-io && echo 'rustix = { path = ".." }' >> Cargo.toml
318b8a62b91Sopenharmony_ci    - run: cd async-io && cargo test
319b8a62b91Sopenharmony_ci
320b8a62b91Sopenharmony_ci  cap-std:
321b8a62b91Sopenharmony_ci    name: cap-std
322b8a62b91Sopenharmony_ci    runs-on: ${{ matrix.os }}
323b8a62b91Sopenharmony_ci    env:
324b8a62b91Sopenharmony_ci      QEMU_BUILD_VERSION: 7.0.0
325b8a62b91Sopenharmony_ci    strategy:
326b8a62b91Sopenharmony_ci      matrix:
327b8a62b91Sopenharmony_ci        build: [ubuntu, i686-linux, aarch64-linux, powerpc64le-linux, riscv64-linux, mipsel-linux, mips64el-linux, arm-linux, macos-latest]
328b8a62b91Sopenharmony_ci        include:
329b8a62b91Sopenharmony_ci          - build: ubuntu
330b8a62b91Sopenharmony_ci            os: ubuntu-latest
331b8a62b91Sopenharmony_ci            rust: nightly
332b8a62b91Sopenharmony_ci          - build: i686-linux
333b8a62b91Sopenharmony_ci            os: ubuntu-latest
334b8a62b91Sopenharmony_ci            rust: nightly
335b8a62b91Sopenharmony_ci            target: i686-unknown-linux-gnu
336b8a62b91Sopenharmony_ci            gcc_package: gcc-i686-linux-gnu
337b8a62b91Sopenharmony_ci            gcc: i686-linux-gnu-gcc
338b8a62b91Sopenharmony_ci            libc_package: libc-dev-i386-cross
339b8a62b91Sopenharmony_ci          - build: aarch64-linux
340b8a62b91Sopenharmony_ci            os: ubuntu-latest
341b8a62b91Sopenharmony_ci            rust: nightly
342b8a62b91Sopenharmony_ci            target: aarch64-unknown-linux-gnu
343b8a62b91Sopenharmony_ci            gcc_package: gcc-aarch64-linux-gnu
344b8a62b91Sopenharmony_ci            gcc: aarch64-linux-gnu-gcc
345b8a62b91Sopenharmony_ci            qemu: qemu-aarch64
346b8a62b91Sopenharmony_ci            qemu_args: -L /usr/aarch64-linux-gnu
347b8a62b91Sopenharmony_ci            qemu_target: aarch64-linux-user
348b8a62b91Sopenharmony_ci          - build: powerpc64le-linux
349b8a62b91Sopenharmony_ci            os: ubuntu-latest
350b8a62b91Sopenharmony_ci            rust: nightly
351b8a62b91Sopenharmony_ci            target: powerpc64le-unknown-linux-gnu
352b8a62b91Sopenharmony_ci            gcc_package: gcc-powerpc64le-linux-gnu
353b8a62b91Sopenharmony_ci            gcc: powerpc64le-linux-gnu-gcc
354b8a62b91Sopenharmony_ci            qemu: qemu-ppc64le
355b8a62b91Sopenharmony_ci            qemu_args: -L /usr/powerpc64le-linux-gnu
356b8a62b91Sopenharmony_ci            qemu_target: ppc64le-linux-user
357b8a62b91Sopenharmony_ci          - build: mips64el-linux
358b8a62b91Sopenharmony_ci            os: ubuntu-latest
359b8a62b91Sopenharmony_ci            rust: nightly
360b8a62b91Sopenharmony_ci            target: mips64el-unknown-linux-gnuabi64
361b8a62b91Sopenharmony_ci            gcc_package: gcc-mips64el-linux-gnuabi64
362b8a62b91Sopenharmony_ci            gcc: mips64el-linux-gnuabi64-gcc
363b8a62b91Sopenharmony_ci            qemu: qemu-mips64el
364b8a62b91Sopenharmony_ci            qemu_args: -L /usr/mips64el-linux-gnuabi64
365b8a62b91Sopenharmony_ci            qemu_target: mips64el-linux-user
366b8a62b91Sopenharmony_ci          - build: mipsel-linux
367b8a62b91Sopenharmony_ci            os: ubuntu-latest
368b8a62b91Sopenharmony_ci            rust: nightly
369b8a62b91Sopenharmony_ci            target: mipsel-unknown-linux-gnu
370b8a62b91Sopenharmony_ci            gcc_package: gcc-mipsel-linux-gnu
371b8a62b91Sopenharmony_ci            gcc: mipsel-linux-gnu-gcc
372b8a62b91Sopenharmony_ci            qemu: qemu-mipsel
373b8a62b91Sopenharmony_ci            qemu_args: -L /usr/mipsel-linux-gnu
374b8a62b91Sopenharmony_ci            qemu_target: mipsel-linux-user
375b8a62b91Sopenharmony_ci          - build: riscv64-linux
376b8a62b91Sopenharmony_ci            os: ubuntu-latest
377b8a62b91Sopenharmony_ci            rust: nightly
378b8a62b91Sopenharmony_ci            target: riscv64gc-unknown-linux-gnu
379b8a62b91Sopenharmony_ci            gcc_package: gcc-riscv64-linux-gnu
380b8a62b91Sopenharmony_ci            gcc: riscv64-linux-gnu-gcc
381b8a62b91Sopenharmony_ci            qemu: qemu-riscv64
382b8a62b91Sopenharmony_ci            qemu_args: -L /usr/riscv64-linux-gnu
383b8a62b91Sopenharmony_ci            qemu_target: riscv64-linux-user
384b8a62b91Sopenharmony_ci          - build: arm-linux
385b8a62b91Sopenharmony_ci            os: ubuntu-latest
386b8a62b91Sopenharmony_ci            rust: nightly
387b8a62b91Sopenharmony_ci            target: armv5te-unknown-linux-gnueabi
388b8a62b91Sopenharmony_ci            gcc_package: gcc-arm-linux-gnueabi
389b8a62b91Sopenharmony_ci            gcc: arm-linux-gnueabi-gcc
390b8a62b91Sopenharmony_ci            qemu: qemu-arm
391b8a62b91Sopenharmony_ci            qemu_args: -L /usr/arm-linux-gnueabi
392b8a62b91Sopenharmony_ci            qemu_target: arm-linux-user
393b8a62b91Sopenharmony_ci          - build: macos-latest
394b8a62b91Sopenharmony_ci            os: macos-latest
395b8a62b91Sopenharmony_ci            rust: nightly
396b8a62b91Sopenharmony_ci    steps:
397b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
398b8a62b91Sopenharmony_ci    - uses: ./.github/actions/install-rust
399b8a62b91Sopenharmony_ci      with:
400b8a62b91Sopenharmony_ci        toolchain: ${{ matrix.rust }}
401b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
402b8a62b91Sopenharmony_ci      with:
403b8a62b91Sopenharmony_ci        repository: bytecodealliance/cap-std
404b8a62b91Sopenharmony_ci        path: cap-std
405b8a62b91Sopenharmony_ci        ref: rustix-0.35.6-beta.2
406b8a62b91Sopenharmony_ci
407b8a62b91Sopenharmony_ci    - name: Configure Cargo target
408b8a62b91Sopenharmony_ci      run: |
409b8a62b91Sopenharmony_ci        echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
410b8a62b91Sopenharmony_ci        rustup target add ${{ matrix.target }}
411b8a62b91Sopenharmony_ci      if: matrix.target != ''
412b8a62b91Sopenharmony_ci
413b8a62b91Sopenharmony_ci    - uses: actions/cache@v3
414b8a62b91Sopenharmony_ci      with:
415b8a62b91Sopenharmony_ci        path: ${{ runner.tool_cache }}/qemu
416b8a62b91Sopenharmony_ci        key: qemu-${{ matrix.target }}-${{ env.QEMU_BUILD_VERSION }}-patched
417b8a62b91Sopenharmony_ci      if: matrix.target != '' && matrix.os == 'ubuntu-latest'
418b8a62b91Sopenharmony_ci
419b8a62b91Sopenharmony_ci    - name: Install cross-compilation tools
420b8a62b91Sopenharmony_ci      run: |
421b8a62b91Sopenharmony_ci        set -ex
422b8a62b91Sopenharmony_ci        sudo apt-get update
423b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build
424b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
425b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV
426b8a62b91Sopenharmony_ci      if: matrix.gcc_package != '' && matrix.os == 'ubuntu-latest'
427b8a62b91Sopenharmony_ci
428b8a62b91Sopenharmony_ci    - name: Install cross-compilation libraries
429b8a62b91Sopenharmony_ci      run: |
430b8a62b91Sopenharmony_ci        set -ex
431b8a62b91Sopenharmony_ci        sudo apt-get update
432b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.libc_package }}
433b8a62b91Sopenharmony_ci      if: matrix.libc_package != '' && matrix.os == 'ubuntu-latest'
434b8a62b91Sopenharmony_ci
435b8a62b91Sopenharmony_ci    - name: Install qemu
436b8a62b91Sopenharmony_ci      run: |
437b8a62b91Sopenharmony_ci        set -ex
438b8a62b91Sopenharmony_ci
439b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
440b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_RUNNER=${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ${{ matrix.qemu_args }} >> $GITHUB_ENV
441b8a62b91Sopenharmony_ci
442b8a62b91Sopenharmony_ci        # See if qemu is already in the cache
443b8a62b91Sopenharmony_ci        if [ -f ${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ]; then
444b8a62b91Sopenharmony_ci          exit 0
445b8a62b91Sopenharmony_ci        fi
446b8a62b91Sopenharmony_ci
447b8a62b91Sopenharmony_ci        # Download and build qemu from source since the most recent release is
448b8a62b91Sopenharmony_ci        # way faster at arm emulation than the current version github actions'
449b8a62b91Sopenharmony_ci        # ubuntu image uses. Disable as much as we can to get it to build
450b8a62b91Sopenharmony_ci        # quickly.
451b8a62b91Sopenharmony_ci        cd
452b8a62b91Sopenharmony_ci        curl https://download.qemu.org/qemu-$QEMU_BUILD_VERSION.tar.xz | tar xJf -
453b8a62b91Sopenharmony_ci        cd qemu-$QEMU_BUILD_VERSION
454b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/translate-errno.patch
455b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/getsockopt-timeouts.patch
456b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/s390x-stat-have-nsec.patch
457b8a62b91Sopenharmony_ci        ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache }}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs
458b8a62b91Sopenharmony_ci        ninja -C build install
459b8a62b91Sopenharmony_ci      if: matrix.qemu != '' && matrix.os == 'ubuntu-latest'
460b8a62b91Sopenharmony_ci
461b8a62b91Sopenharmony_ci    - run: cd cap-std && cargo update
462b8a62b91Sopenharmony_ci    - run: sed -i'.bak' 's/^version = "'`cd cap-std && cargo tree --edges=normal |head -1 |sed 's/^[[:alnum:]_-]* v\([[:alnum:].-]*\) (.*/\1/'`'"$/version = '`grep -A1 '^name = "rustix"' cap-std/Cargo.lock |grep ^version |sed 's/^[^"]*//'`'/' Cargo.toml
463b8a62b91Sopenharmony_ci    - run: cd cap-std && echo '[patch.crates-io]' >> Cargo.toml
464b8a62b91Sopenharmony_ci    - run: cd cap-std && echo 'rustix = { path = ".." }' >> Cargo.toml
465b8a62b91Sopenharmony_ci    - run: cd cap-std && cargo test
466b8a62b91Sopenharmony_ci
467b8a62b91Sopenharmony_ci  cargo:
468b8a62b91Sopenharmony_ci    name: cargo ported to rustix
469b8a62b91Sopenharmony_ci    runs-on: ${{ matrix.os }}
470b8a62b91Sopenharmony_ci    strategy:
471b8a62b91Sopenharmony_ci      matrix:
472b8a62b91Sopenharmony_ci        # Cargo depends on pkg-config which must be configured for cross-compilation.
473b8a62b91Sopenharmony_ci        build: [ubuntu]
474b8a62b91Sopenharmony_ci        include:
475b8a62b91Sopenharmony_ci          - build: ubuntu
476b8a62b91Sopenharmony_ci            os: ubuntu-latest
477b8a62b91Sopenharmony_ci            rust: nightly
478b8a62b91Sopenharmony_ci    steps:
479b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
480b8a62b91Sopenharmony_ci    - uses: ./.github/actions/install-rust
481b8a62b91Sopenharmony_ci      with:
482b8a62b91Sopenharmony_ci        toolchain: ${{ matrix.rust }}
483b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
484b8a62b91Sopenharmony_ci      with:
485b8a62b91Sopenharmony_ci        repository: sunfishcode/cargo
486b8a62b91Sopenharmony_ci        path: cargo
487b8a62b91Sopenharmony_ci        ref: rustix-0.35.6-beta.2
488b8a62b91Sopenharmony_ci
489b8a62b91Sopenharmony_ci    - run: rustup component add rust-src rustc-dev llvm-tools-preview
490b8a62b91Sopenharmony_ci    - run: cd cargo && cargo update
491b8a62b91Sopenharmony_ci    - run: sed -i'.bak' 's/^version = "'`cd cargo && cargo tree --edges=normal |head -1 |sed 's/^[[:alnum:]_-]* v\([[:alnum:].-]*\) (.*/\1/'`'"$/version = '`grep -A1 '^name = "rustix"' cargo/Cargo.lock |grep ^version |sed 's/^[^"]*//'`'/' Cargo.toml
492b8a62b91Sopenharmony_ci    - run: cd cargo && echo '[patch.crates-io]' >> Cargo.toml
493b8a62b91Sopenharmony_ci    - run: cd cargo && echo 'rustix = { path = ".." }' >> Cargo.toml
494b8a62b91Sopenharmony_ci    - run: cd cargo && cargo test --workspace
495b8a62b91Sopenharmony_ci      # Cargo cross tests require extra build dependencies.
496b8a62b91Sopenharmony_ci      env:
497b8a62b91Sopenharmony_ci        CFG_DISABLE_CROSS_TESTS: 1
498b8a62b91Sopenharmony_ci
499b8a62b91Sopenharmony_ci  memfd-rs:
500b8a62b91Sopenharmony_ci    name: memfd-rs
501b8a62b91Sopenharmony_ci    runs-on: ${{ matrix.os }}
502b8a62b91Sopenharmony_ci    env:
503b8a62b91Sopenharmony_ci      QEMU_BUILD_VERSION: 7.0.0
504b8a62b91Sopenharmony_ci    strategy:
505b8a62b91Sopenharmony_ci      matrix:
506b8a62b91Sopenharmony_ci        build: [ubuntu, i686-linux, aarch64-linux, powerpc64le-linux, riscv64-linux, mipsel-linux, mips64el-linux, arm-linux]
507b8a62b91Sopenharmony_ci        include:
508b8a62b91Sopenharmony_ci          - build: ubuntu
509b8a62b91Sopenharmony_ci            os: ubuntu-latest
510b8a62b91Sopenharmony_ci            rust: nightly
511b8a62b91Sopenharmony_ci          - build: i686-linux
512b8a62b91Sopenharmony_ci            os: ubuntu-latest
513b8a62b91Sopenharmony_ci            rust: nightly
514b8a62b91Sopenharmony_ci            target: i686-unknown-linux-gnu
515b8a62b91Sopenharmony_ci            gcc_package: gcc-i686-linux-gnu
516b8a62b91Sopenharmony_ci            gcc: i686-linux-gnu-gcc
517b8a62b91Sopenharmony_ci            libc_package: libc-dev-i386-cross
518b8a62b91Sopenharmony_ci          - build: aarch64-linux
519b8a62b91Sopenharmony_ci            os: ubuntu-latest
520b8a62b91Sopenharmony_ci            rust: nightly
521b8a62b91Sopenharmony_ci            target: aarch64-unknown-linux-gnu
522b8a62b91Sopenharmony_ci            gcc_package: gcc-aarch64-linux-gnu
523b8a62b91Sopenharmony_ci            gcc: aarch64-linux-gnu-gcc
524b8a62b91Sopenharmony_ci            qemu: qemu-aarch64
525b8a62b91Sopenharmony_ci            qemu_args: -L /usr/aarch64-linux-gnu
526b8a62b91Sopenharmony_ci            qemu_target: aarch64-linux-user
527b8a62b91Sopenharmony_ci          - build: powerpc64le-linux
528b8a62b91Sopenharmony_ci            os: ubuntu-latest
529b8a62b91Sopenharmony_ci            rust: nightly
530b8a62b91Sopenharmony_ci            target: powerpc64le-unknown-linux-gnu
531b8a62b91Sopenharmony_ci            gcc_package: gcc-powerpc64le-linux-gnu
532b8a62b91Sopenharmony_ci            gcc: powerpc64le-linux-gnu-gcc
533b8a62b91Sopenharmony_ci            qemu: qemu-ppc64le
534b8a62b91Sopenharmony_ci            qemu_args: -L /usr/powerpc64le-linux-gnu
535b8a62b91Sopenharmony_ci            qemu_target: ppc64le-linux-user
536b8a62b91Sopenharmony_ci          - build: mips64el-linux
537b8a62b91Sopenharmony_ci            os: ubuntu-latest
538b8a62b91Sopenharmony_ci            rust: nightly
539b8a62b91Sopenharmony_ci            target: mips64el-unknown-linux-gnuabi64
540b8a62b91Sopenharmony_ci            gcc_package: gcc-mips64el-linux-gnuabi64
541b8a62b91Sopenharmony_ci            gcc: mips64el-linux-gnuabi64-gcc
542b8a62b91Sopenharmony_ci            qemu: qemu-mips64el
543b8a62b91Sopenharmony_ci            qemu_args: -L /usr/mips64el-linux-gnuabi64
544b8a62b91Sopenharmony_ci            qemu_target: mips64el-linux-user
545b8a62b91Sopenharmony_ci          - build: mipsel-linux
546b8a62b91Sopenharmony_ci            os: ubuntu-latest
547b8a62b91Sopenharmony_ci            rust: nightly
548b8a62b91Sopenharmony_ci            target: mipsel-unknown-linux-gnu
549b8a62b91Sopenharmony_ci            gcc_package: gcc-mipsel-linux-gnu
550b8a62b91Sopenharmony_ci            gcc: mipsel-linux-gnu-gcc
551b8a62b91Sopenharmony_ci            qemu: qemu-mipsel
552b8a62b91Sopenharmony_ci            qemu_args: -L /usr/mipsel-linux-gnu
553b8a62b91Sopenharmony_ci            qemu_target: mipsel-linux-user
554b8a62b91Sopenharmony_ci          - build: riscv64-linux
555b8a62b91Sopenharmony_ci            os: ubuntu-latest
556b8a62b91Sopenharmony_ci            rust: nightly
557b8a62b91Sopenharmony_ci            target: riscv64gc-unknown-linux-gnu
558b8a62b91Sopenharmony_ci            gcc_package: gcc-riscv64-linux-gnu
559b8a62b91Sopenharmony_ci            gcc: riscv64-linux-gnu-gcc
560b8a62b91Sopenharmony_ci            qemu: qemu-riscv64
561b8a62b91Sopenharmony_ci            qemu_args: -L /usr/riscv64-linux-gnu
562b8a62b91Sopenharmony_ci            qemu_target: riscv64-linux-user
563b8a62b91Sopenharmony_ci          - build: arm-linux
564b8a62b91Sopenharmony_ci            os: ubuntu-latest
565b8a62b91Sopenharmony_ci            rust: nightly
566b8a62b91Sopenharmony_ci            target: armv5te-unknown-linux-gnueabi
567b8a62b91Sopenharmony_ci            gcc_package: gcc-arm-linux-gnueabi
568b8a62b91Sopenharmony_ci            gcc: arm-linux-gnueabi-gcc
569b8a62b91Sopenharmony_ci            qemu: qemu-arm
570b8a62b91Sopenharmony_ci            qemu_args: -L /usr/arm-linux-gnueabi
571b8a62b91Sopenharmony_ci            qemu_target: arm-linux-user
572b8a62b91Sopenharmony_ci    steps:
573b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
574b8a62b91Sopenharmony_ci    - uses: ./.github/actions/install-rust
575b8a62b91Sopenharmony_ci      with:
576b8a62b91Sopenharmony_ci        toolchain: ${{ matrix.rust }}
577b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
578b8a62b91Sopenharmony_ci      with:
579b8a62b91Sopenharmony_ci        repository: sunfishcode/memfd-rs
580b8a62b91Sopenharmony_ci        path: memfd-rs
581b8a62b91Sopenharmony_ci        ref: rustix-0.35.6-beta.2
582b8a62b91Sopenharmony_ci
583b8a62b91Sopenharmony_ci    - name: Configure Cargo target
584b8a62b91Sopenharmony_ci      run: |
585b8a62b91Sopenharmony_ci        echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
586b8a62b91Sopenharmony_ci        rustup target add ${{ matrix.target }}
587b8a62b91Sopenharmony_ci      if: matrix.target != ''
588b8a62b91Sopenharmony_ci
589b8a62b91Sopenharmony_ci    - uses: actions/cache@v3
590b8a62b91Sopenharmony_ci      with:
591b8a62b91Sopenharmony_ci        path: ${{ runner.tool_cache }}/qemu
592b8a62b91Sopenharmony_ci        key: qemu-${{ matrix.target }}-${{ env.QEMU_BUILD_VERSION }}-patched
593b8a62b91Sopenharmony_ci      if: matrix.target != '' && matrix.os == 'ubuntu-latest'
594b8a62b91Sopenharmony_ci
595b8a62b91Sopenharmony_ci    - name: Install cross-compilation tools
596b8a62b91Sopenharmony_ci      run: |
597b8a62b91Sopenharmony_ci        set -ex
598b8a62b91Sopenharmony_ci        sudo apt-get update
599b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build
600b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
601b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV
602b8a62b91Sopenharmony_ci      if: matrix.gcc_package != '' && matrix.os == 'ubuntu-latest'
603b8a62b91Sopenharmony_ci
604b8a62b91Sopenharmony_ci    - name: Install cross-compilation libraries
605b8a62b91Sopenharmony_ci      run: |
606b8a62b91Sopenharmony_ci        set -ex
607b8a62b91Sopenharmony_ci        sudo apt-get update
608b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.libc_package }}
609b8a62b91Sopenharmony_ci      if: matrix.libc_package != '' && matrix.os == 'ubuntu-latest'
610b8a62b91Sopenharmony_ci
611b8a62b91Sopenharmony_ci    - name: Install qemu
612b8a62b91Sopenharmony_ci      run: |
613b8a62b91Sopenharmony_ci        set -ex
614b8a62b91Sopenharmony_ci
615b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
616b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_RUNNER=${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ${{ matrix.qemu_args }} >> $GITHUB_ENV
617b8a62b91Sopenharmony_ci
618b8a62b91Sopenharmony_ci        # See if qemu is already in the cache
619b8a62b91Sopenharmony_ci        if [ -f ${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ]; then
620b8a62b91Sopenharmony_ci          exit 0
621b8a62b91Sopenharmony_ci        fi
622b8a62b91Sopenharmony_ci
623b8a62b91Sopenharmony_ci        # Download and build qemu from source since the most recent release is
624b8a62b91Sopenharmony_ci        # way faster at arm emulation than the current version github actions'
625b8a62b91Sopenharmony_ci        # ubuntu image uses. Disable as much as we can to get it to build
626b8a62b91Sopenharmony_ci        # quickly.
627b8a62b91Sopenharmony_ci        cd
628b8a62b91Sopenharmony_ci        curl https://download.qemu.org/qemu-$QEMU_BUILD_VERSION.tar.xz | tar xJf -
629b8a62b91Sopenharmony_ci        cd qemu-$QEMU_BUILD_VERSION
630b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/translate-errno.patch
631b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/getsockopt-timeouts.patch
632b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/s390x-stat-have-nsec.patch
633b8a62b91Sopenharmony_ci        ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache }}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs
634b8a62b91Sopenharmony_ci        ninja -C build install
635b8a62b91Sopenharmony_ci      if: matrix.qemu != '' && matrix.os == 'ubuntu-latest'
636b8a62b91Sopenharmony_ci
637b8a62b91Sopenharmony_ci    - run: cd memfd-rs && cargo update
638b8a62b91Sopenharmony_ci    - run: sed -i'.bak' 's/^version = "'`cd memfd-rs && cargo tree --edges=normal |head -1 |sed 's/^[[:alnum:]_-]* v\([[:alnum:].-]*\) (.*/\1/'`'"$/version = '`grep -A1 '^name = "rustix"' memfd-rs/Cargo.lock |grep ^version |sed 's/^[^"]*//'`'/' Cargo.toml
639b8a62b91Sopenharmony_ci    - run: cd memfd-rs && echo '[patch.crates-io]' >> Cargo.toml
640b8a62b91Sopenharmony_ci    - run: cd memfd-rs && echo 'rustix = { path = ".." }' >> Cargo.toml
641b8a62b91Sopenharmony_ci    - run: cd memfd-rs && cargo test
642b8a62b91Sopenharmony_ci
643b8a62b91Sopenharmony_ci  rust-timerfd:
644b8a62b91Sopenharmony_ci    name: rust-timerfd
645b8a62b91Sopenharmony_ci    runs-on: ${{ matrix.os }}
646b8a62b91Sopenharmony_ci    env:
647b8a62b91Sopenharmony_ci      QEMU_BUILD_VERSION: 7.0.0
648b8a62b91Sopenharmony_ci    strategy:
649b8a62b91Sopenharmony_ci      matrix:
650b8a62b91Sopenharmony_ci        build: [ubuntu, i686-linux, aarch64-linux, powerpc64le-linux, riscv64-linux, mipsel-linux, mips64el-linux, arm-linux]
651b8a62b91Sopenharmony_ci        include:
652b8a62b91Sopenharmony_ci          - build: ubuntu
653b8a62b91Sopenharmony_ci            os: ubuntu-latest
654b8a62b91Sopenharmony_ci            rust: nightly
655b8a62b91Sopenharmony_ci          - build: i686-linux
656b8a62b91Sopenharmony_ci            os: ubuntu-latest
657b8a62b91Sopenharmony_ci            rust: nightly
658b8a62b91Sopenharmony_ci            target: i686-unknown-linux-gnu
659b8a62b91Sopenharmony_ci            gcc_package: gcc-i686-linux-gnu
660b8a62b91Sopenharmony_ci            gcc: i686-linux-gnu-gcc
661b8a62b91Sopenharmony_ci            libc_package: libc-dev-i386-cross
662b8a62b91Sopenharmony_ci          - build: aarch64-linux
663b8a62b91Sopenharmony_ci            os: ubuntu-latest
664b8a62b91Sopenharmony_ci            rust: nightly
665b8a62b91Sopenharmony_ci            target: aarch64-unknown-linux-gnu
666b8a62b91Sopenharmony_ci            gcc_package: gcc-aarch64-linux-gnu
667b8a62b91Sopenharmony_ci            gcc: aarch64-linux-gnu-gcc
668b8a62b91Sopenharmony_ci            qemu: qemu-aarch64
669b8a62b91Sopenharmony_ci            qemu_args: -L /usr/aarch64-linux-gnu
670b8a62b91Sopenharmony_ci            qemu_target: aarch64-linux-user
671b8a62b91Sopenharmony_ci          - build: powerpc64le-linux
672b8a62b91Sopenharmony_ci            os: ubuntu-latest
673b8a62b91Sopenharmony_ci            rust: nightly
674b8a62b91Sopenharmony_ci            target: powerpc64le-unknown-linux-gnu
675b8a62b91Sopenharmony_ci            gcc_package: gcc-powerpc64le-linux-gnu
676b8a62b91Sopenharmony_ci            gcc: powerpc64le-linux-gnu-gcc
677b8a62b91Sopenharmony_ci            qemu: qemu-ppc64le
678b8a62b91Sopenharmony_ci            qemu_args: -L /usr/powerpc64le-linux-gnu
679b8a62b91Sopenharmony_ci            qemu_target: ppc64le-linux-user
680b8a62b91Sopenharmony_ci          - build: mips64el-linux
681b8a62b91Sopenharmony_ci            os: ubuntu-latest
682b8a62b91Sopenharmony_ci            rust: nightly
683b8a62b91Sopenharmony_ci            target: mips64el-unknown-linux-gnuabi64
684b8a62b91Sopenharmony_ci            gcc_package: gcc-mips64el-linux-gnuabi64
685b8a62b91Sopenharmony_ci            gcc: mips64el-linux-gnuabi64-gcc
686b8a62b91Sopenharmony_ci            qemu: qemu-mips64el -L /usr/mips64el-linux-gnuabi64
687b8a62b91Sopenharmony_ci            qemu_target: mips64el-linux-user
688b8a62b91Sopenharmony_ci          - build: mipsel-linux
689b8a62b91Sopenharmony_ci            os: ubuntu-latest
690b8a62b91Sopenharmony_ci            rust: nightly
691b8a62b91Sopenharmony_ci            target: mipsel-unknown-linux-gnu
692b8a62b91Sopenharmony_ci            gcc_package: gcc-mipsel-linux-gnu
693b8a62b91Sopenharmony_ci            gcc: mipsel-linux-gnu-gcc
694b8a62b91Sopenharmony_ci            qemu: qemu-mipsel -L /usr/mipsel-linux-gnu
695b8a62b91Sopenharmony_ci            qemu_target: mipsel-linux-user
696b8a62b91Sopenharmony_ci          - build: riscv64-linux
697b8a62b91Sopenharmony_ci            os: ubuntu-latest
698b8a62b91Sopenharmony_ci            rust: nightly
699b8a62b91Sopenharmony_ci            target: riscv64gc-unknown-linux-gnu
700b8a62b91Sopenharmony_ci            gcc_package: gcc-riscv64-linux-gnu
701b8a62b91Sopenharmony_ci            gcc: riscv64-linux-gnu-gcc
702b8a62b91Sopenharmony_ci            qemu: qemu-riscv64
703b8a62b91Sopenharmony_ci            qemu_args: -L /usr/riscv64-linux-gnu
704b8a62b91Sopenharmony_ci            qemu_target: riscv64-linux-user
705b8a62b91Sopenharmony_ci          - build: arm-linux
706b8a62b91Sopenharmony_ci            os: ubuntu-latest
707b8a62b91Sopenharmony_ci            rust: nightly
708b8a62b91Sopenharmony_ci            target: armv5te-unknown-linux-gnueabi
709b8a62b91Sopenharmony_ci            gcc_package: gcc-arm-linux-gnueabi
710b8a62b91Sopenharmony_ci            gcc: arm-linux-gnueabi-gcc
711b8a62b91Sopenharmony_ci            qemu: qemu-arm
712b8a62b91Sopenharmony_ci            qemu_args: -L /usr/arm-linux-gnueabi
713b8a62b91Sopenharmony_ci            qemu_target: arm-linux-user
714b8a62b91Sopenharmony_ci    steps:
715b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
716b8a62b91Sopenharmony_ci    - uses: ./.github/actions/install-rust
717b8a62b91Sopenharmony_ci      with:
718b8a62b91Sopenharmony_ci        toolchain: ${{ matrix.rust }}
719b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
720b8a62b91Sopenharmony_ci      with:
721b8a62b91Sopenharmony_ci        repository: sunfishcode/rust-timerfd
722b8a62b91Sopenharmony_ci        path: rust-timerfd
723b8a62b91Sopenharmony_ci        ref: rustix-0.35.6-beta.2
724b8a62b91Sopenharmony_ci
725b8a62b91Sopenharmony_ci    - name: Configure Cargo target
726b8a62b91Sopenharmony_ci      run: |
727b8a62b91Sopenharmony_ci        echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
728b8a62b91Sopenharmony_ci        rustup target add ${{ matrix.target }}
729b8a62b91Sopenharmony_ci      if: matrix.target != ''
730b8a62b91Sopenharmony_ci
731b8a62b91Sopenharmony_ci    - uses: actions/cache@v3
732b8a62b91Sopenharmony_ci      with:
733b8a62b91Sopenharmony_ci        path: ${{ runner.tool_cache }}/qemu
734b8a62b91Sopenharmony_ci        key: qemu-${{ matrix.target }}-${{ env.QEMU_BUILD_VERSION }}-patched
735b8a62b91Sopenharmony_ci      if: matrix.target != '' && matrix.os == 'ubuntu-latest'
736b8a62b91Sopenharmony_ci
737b8a62b91Sopenharmony_ci    - name: Install cross-compilation tools
738b8a62b91Sopenharmony_ci      run: |
739b8a62b91Sopenharmony_ci        set -ex
740b8a62b91Sopenharmony_ci        sudo apt-get update
741b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build
742b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
743b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV
744b8a62b91Sopenharmony_ci      if: matrix.gcc_package != '' && matrix.os == 'ubuntu-latest'
745b8a62b91Sopenharmony_ci
746b8a62b91Sopenharmony_ci    - name: Install cross-compilation libraries
747b8a62b91Sopenharmony_ci      run: |
748b8a62b91Sopenharmony_ci        set -ex
749b8a62b91Sopenharmony_ci        sudo apt-get update
750b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.libc_package }}
751b8a62b91Sopenharmony_ci      if: matrix.libc_package != '' && matrix.os == 'ubuntu-latest'
752b8a62b91Sopenharmony_ci
753b8a62b91Sopenharmony_ci    - name: Install qemu
754b8a62b91Sopenharmony_ci      run: |
755b8a62b91Sopenharmony_ci        set -ex
756b8a62b91Sopenharmony_ci
757b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
758b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_RUNNER=${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ${{ matrix.qemu_args }} >> $GITHUB_ENV
759b8a62b91Sopenharmony_ci
760b8a62b91Sopenharmony_ci        # See if qemu is already in the cache
761b8a62b91Sopenharmony_ci        if [ -f ${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ]; then
762b8a62b91Sopenharmony_ci          exit 0
763b8a62b91Sopenharmony_ci        fi
764b8a62b91Sopenharmony_ci
765b8a62b91Sopenharmony_ci        # Download and build qemu from source since the most recent release is
766b8a62b91Sopenharmony_ci        # way faster at arm emulation than the current version github actions'
767b8a62b91Sopenharmony_ci        # ubuntu image uses. Disable as much as we can to get it to build
768b8a62b91Sopenharmony_ci        # quickly.
769b8a62b91Sopenharmony_ci        cd
770b8a62b91Sopenharmony_ci        curl https://download.qemu.org/qemu-$QEMU_BUILD_VERSION.tar.xz | tar xJf -
771b8a62b91Sopenharmony_ci        cd qemu-$QEMU_BUILD_VERSION
772b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/translate-errno.patch
773b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/getsockopt-timeouts.patch
774b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/s390x-stat-have-nsec.patch
775b8a62b91Sopenharmony_ci        ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache }}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs
776b8a62b91Sopenharmony_ci        ninja -C build install
777b8a62b91Sopenharmony_ci      if: matrix.qemu != '' && matrix.os == 'ubuntu-latest'
778b8a62b91Sopenharmony_ci
779b8a62b91Sopenharmony_ci    - run: cd rust-timerfd && cargo update
780b8a62b91Sopenharmony_ci    - run: sed -i'.bak' 's/^version = "'`cd rust-timerfd && cargo tree --edges=normal |head -1 |sed 's/^[[:alnum:]_-]* v\([[:alnum:].-]*\) (.*/\1/'`'"$/version = '`grep -A1 '^name = "rustix"' rust-timerfd/Cargo.lock |grep ^version |sed 's/^[^"]*//'`'/' Cargo.toml
781b8a62b91Sopenharmony_ci    - run: cd rust-timerfd && echo '[patch.crates-io]' >> Cargo.toml
782b8a62b91Sopenharmony_ci    - run: cd rust-timerfd && echo 'rustix = { path = ".." }' >> Cargo.toml
783b8a62b91Sopenharmony_ci    - run: cd rust-timerfd && cargo test
784b8a62b91Sopenharmony_ci
785b8a62b91Sopenharmony_ci  procfs:
786b8a62b91Sopenharmony_ci    name: procfs
787b8a62b91Sopenharmony_ci    runs-on: ${{ matrix.os }}
788b8a62b91Sopenharmony_ci    env:
789b8a62b91Sopenharmony_ci      QEMU_BUILD_VERSION: 7.0.0
790b8a62b91Sopenharmony_ci    strategy:
791b8a62b91Sopenharmony_ci      matrix:
792b8a62b91Sopenharmony_ci        build: [ubuntu, i686-linux, aarch64-linux, powerpc64le-linux, riscv64-linux, mipsel-linux, mips64el-linux, arm-linux]
793b8a62b91Sopenharmony_ci        include:
794b8a62b91Sopenharmony_ci          - build: ubuntu
795b8a62b91Sopenharmony_ci            os: ubuntu-latest
796b8a62b91Sopenharmony_ci            rust: nightly
797b8a62b91Sopenharmony_ci          - build: i686-linux
798b8a62b91Sopenharmony_ci            os: ubuntu-latest
799b8a62b91Sopenharmony_ci            rust: nightly
800b8a62b91Sopenharmony_ci            target: i686-unknown-linux-gnu
801b8a62b91Sopenharmony_ci            gcc_package: gcc-i686-linux-gnu
802b8a62b91Sopenharmony_ci            gcc: i686-linux-gnu-gcc
803b8a62b91Sopenharmony_ci            libc_package: libc-dev-i386-cross
804b8a62b91Sopenharmony_ci          - build: aarch64-linux
805b8a62b91Sopenharmony_ci            os: ubuntu-latest
806b8a62b91Sopenharmony_ci            rust: nightly
807b8a62b91Sopenharmony_ci            target: aarch64-unknown-linux-gnu
808b8a62b91Sopenharmony_ci            gcc_package: gcc-aarch64-linux-gnu
809b8a62b91Sopenharmony_ci            gcc: aarch64-linux-gnu-gcc
810b8a62b91Sopenharmony_ci            qemu: qemu-aarch64
811b8a62b91Sopenharmony_ci            qemu_args: -L /usr/aarch64-linux-gnu
812b8a62b91Sopenharmony_ci            qemu_target: aarch64-linux-user
813b8a62b91Sopenharmony_ci          - build: powerpc64le-linux
814b8a62b91Sopenharmony_ci            os: ubuntu-latest
815b8a62b91Sopenharmony_ci            rust: nightly
816b8a62b91Sopenharmony_ci            target: powerpc64le-unknown-linux-gnu
817b8a62b91Sopenharmony_ci            gcc_package: gcc-powerpc64le-linux-gnu
818b8a62b91Sopenharmony_ci            gcc: powerpc64le-linux-gnu-gcc
819b8a62b91Sopenharmony_ci            qemu: qemu-ppc64le
820b8a62b91Sopenharmony_ci            qemu_args: -L /usr/powerpc64le-linux-gnu
821b8a62b91Sopenharmony_ci            qemu_target: ppc64le-linux-user
822b8a62b91Sopenharmony_ci          - build: mips64el-linux
823b8a62b91Sopenharmony_ci            os: ubuntu-latest
824b8a62b91Sopenharmony_ci            rust: nightly
825b8a62b91Sopenharmony_ci            target: mips64el-unknown-linux-gnuabi64
826b8a62b91Sopenharmony_ci            gcc_package: gcc-mips64el-linux-gnuabi64
827b8a62b91Sopenharmony_ci            gcc: mips64el-linux-gnuabi64-gcc
828b8a62b91Sopenharmony_ci            qemu: qemu-mips64el -L /usr/mips64el-linux-gnuabi64
829b8a62b91Sopenharmony_ci            qemu_target: mips64el-linux-user
830b8a62b91Sopenharmony_ci          - build: mipsel-linux
831b8a62b91Sopenharmony_ci            os: ubuntu-latest
832b8a62b91Sopenharmony_ci            rust: nightly
833b8a62b91Sopenharmony_ci            target: mipsel-unknown-linux-gnu
834b8a62b91Sopenharmony_ci            gcc_package: gcc-mipsel-linux-gnu
835b8a62b91Sopenharmony_ci            gcc: mipsel-linux-gnu-gcc
836b8a62b91Sopenharmony_ci            qemu: qemu-mipsel -L /usr/mipsel-linux-gnu
837b8a62b91Sopenharmony_ci            qemu_target: mipsel-linux-user
838b8a62b91Sopenharmony_ci          - build: riscv64-linux
839b8a62b91Sopenharmony_ci            os: ubuntu-latest
840b8a62b91Sopenharmony_ci            rust: nightly
841b8a62b91Sopenharmony_ci            target: riscv64gc-unknown-linux-gnu
842b8a62b91Sopenharmony_ci            gcc_package: gcc-riscv64-linux-gnu
843b8a62b91Sopenharmony_ci            gcc: riscv64-linux-gnu-gcc
844b8a62b91Sopenharmony_ci            qemu: qemu-riscv64
845b8a62b91Sopenharmony_ci            qemu_args: -L /usr/riscv64-linux-gnu
846b8a62b91Sopenharmony_ci            qemu_target: riscv64-linux-user
847b8a62b91Sopenharmony_ci          - build: arm-linux
848b8a62b91Sopenharmony_ci            os: ubuntu-latest
849b8a62b91Sopenharmony_ci            rust: nightly
850b8a62b91Sopenharmony_ci            target: armv5te-unknown-linux-gnueabi
851b8a62b91Sopenharmony_ci            gcc_package: gcc-arm-linux-gnueabi
852b8a62b91Sopenharmony_ci            gcc: arm-linux-gnueabi-gcc
853b8a62b91Sopenharmony_ci            qemu: qemu-arm
854b8a62b91Sopenharmony_ci            qemu_args: -L /usr/arm-linux-gnueabi
855b8a62b91Sopenharmony_ci            qemu_target: arm-linux-user
856b8a62b91Sopenharmony_ci    steps:
857b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
858b8a62b91Sopenharmony_ci    - uses: ./.github/actions/install-rust
859b8a62b91Sopenharmony_ci      with:
860b8a62b91Sopenharmony_ci        toolchain: ${{ matrix.rust }}
861b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
862b8a62b91Sopenharmony_ci      with:
863b8a62b91Sopenharmony_ci        repository: sunfishcode/procfs
864b8a62b91Sopenharmony_ci        path: procfs
865b8a62b91Sopenharmony_ci        ref: rustix-0.35.6-beta.2
866b8a62b91Sopenharmony_ci
867b8a62b91Sopenharmony_ci    - name: Configure Cargo target
868b8a62b91Sopenharmony_ci      run: |
869b8a62b91Sopenharmony_ci        echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
870b8a62b91Sopenharmony_ci        rustup target add ${{ matrix.target }}
871b8a62b91Sopenharmony_ci      if: matrix.target != ''
872b8a62b91Sopenharmony_ci
873b8a62b91Sopenharmony_ci    - uses: actions/cache@v3
874b8a62b91Sopenharmony_ci      with:
875b8a62b91Sopenharmony_ci        path: ${{ runner.tool_cache }}/qemu
876b8a62b91Sopenharmony_ci        key: qemu-${{ matrix.target }}-${{ env.QEMU_BUILD_VERSION }}-patched
877b8a62b91Sopenharmony_ci      if: matrix.target != '' && matrix.os == 'ubuntu-latest'
878b8a62b91Sopenharmony_ci
879b8a62b91Sopenharmony_ci    - name: Install cross-compilation tools
880b8a62b91Sopenharmony_ci      run: |
881b8a62b91Sopenharmony_ci        set -ex
882b8a62b91Sopenharmony_ci        sudo apt-get update
883b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build
884b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
885b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV
886b8a62b91Sopenharmony_ci      if: matrix.gcc_package != '' && matrix.os == 'ubuntu-latest'
887b8a62b91Sopenharmony_ci
888b8a62b91Sopenharmony_ci    - name: Install cross-compilation libraries
889b8a62b91Sopenharmony_ci      run: |
890b8a62b91Sopenharmony_ci        set -ex
891b8a62b91Sopenharmony_ci        sudo apt-get update
892b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.libc_package }}
893b8a62b91Sopenharmony_ci      if: matrix.libc_package != '' && matrix.os == 'ubuntu-latest'
894b8a62b91Sopenharmony_ci
895b8a62b91Sopenharmony_ci    - name: Install qemu
896b8a62b91Sopenharmony_ci      run: |
897b8a62b91Sopenharmony_ci        set -ex
898b8a62b91Sopenharmony_ci
899b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
900b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_RUNNER=${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ${{ matrix.qemu_args }} >> $GITHUB_ENV
901b8a62b91Sopenharmony_ci
902b8a62b91Sopenharmony_ci        # See if qemu is already in the cache
903b8a62b91Sopenharmony_ci        if [ -f ${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ]; then
904b8a62b91Sopenharmony_ci          exit 0
905b8a62b91Sopenharmony_ci        fi
906b8a62b91Sopenharmony_ci
907b8a62b91Sopenharmony_ci        # Download and build qemu from source since the most recent release is
908b8a62b91Sopenharmony_ci        # way faster at arm emulation than the current version github actions'
909b8a62b91Sopenharmony_ci        # ubuntu image uses. Disable as much as we can to get it to build
910b8a62b91Sopenharmony_ci        # quickly.
911b8a62b91Sopenharmony_ci        cd
912b8a62b91Sopenharmony_ci        curl https://download.qemu.org/qemu-$QEMU_BUILD_VERSION.tar.xz | tar xJf -
913b8a62b91Sopenharmony_ci        cd qemu-$QEMU_BUILD_VERSION
914b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/translate-errno.patch
915b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/getsockopt-timeouts.patch
916b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/s390x-stat-have-nsec.patch
917b8a62b91Sopenharmony_ci        ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache }}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs
918b8a62b91Sopenharmony_ci        ninja -C build install
919b8a62b91Sopenharmony_ci      if: matrix.qemu != '' && matrix.os == 'ubuntu-latest'
920b8a62b91Sopenharmony_ci
921b8a62b91Sopenharmony_ci    - run: cd procfs && cargo update
922b8a62b91Sopenharmony_ci    - run: sed -i'.bak' 's/^version = "'`cd procfs && cargo tree --edges=normal |head -1 |sed 's/^[[:alnum:]_-]* v\([[:alnum:].-]*\) (.*/\1/'`'"$/version = '`grep -A1 '^name = "rustix"' procfs/Cargo.lock |grep ^version |sed 's/^[^"]*//'`'/' Cargo.toml
923b8a62b91Sopenharmony_ci    - run: cd procfs && echo '[patch.crates-io]' >> Cargo.toml
924b8a62b91Sopenharmony_ci    - run: cd procfs && echo 'rustix = { path = ".." }' >> Cargo.toml
925b8a62b91Sopenharmony_ci    - run: cd procfs && cargo test
926b8a62b91Sopenharmony_ci
927b8a62b91Sopenharmony_ci  rust-atomicwrites:
928b8a62b91Sopenharmony_ci    name: rust-atomicwrites
929b8a62b91Sopenharmony_ci    runs-on: ${{ matrix.os }}
930b8a62b91Sopenharmony_ci    env:
931b8a62b91Sopenharmony_ci      QEMU_BUILD_VERSION: 7.0.0
932b8a62b91Sopenharmony_ci    strategy:
933b8a62b91Sopenharmony_ci      matrix:
934b8a62b91Sopenharmony_ci        build: [ubuntu, i686-linux, aarch64-linux, powerpc64le-linux, riscv64-linux, mipsel-linux, mips64el-linux, arm-linux]
935b8a62b91Sopenharmony_ci        include:
936b8a62b91Sopenharmony_ci          - build: ubuntu
937b8a62b91Sopenharmony_ci            os: ubuntu-latest
938b8a62b91Sopenharmony_ci            rust: nightly
939b8a62b91Sopenharmony_ci          - build: i686-linux
940b8a62b91Sopenharmony_ci            os: ubuntu-latest
941b8a62b91Sopenharmony_ci            rust: nightly
942b8a62b91Sopenharmony_ci            target: i686-unknown-linux-gnu
943b8a62b91Sopenharmony_ci            gcc_package: gcc-i686-linux-gnu
944b8a62b91Sopenharmony_ci            gcc: i686-linux-gnu-gcc
945b8a62b91Sopenharmony_ci            libc_package: libc-dev-i386-cross
946b8a62b91Sopenharmony_ci          - build: aarch64-linux
947b8a62b91Sopenharmony_ci            os: ubuntu-latest
948b8a62b91Sopenharmony_ci            rust: nightly
949b8a62b91Sopenharmony_ci            target: aarch64-unknown-linux-gnu
950b8a62b91Sopenharmony_ci            gcc_package: gcc-aarch64-linux-gnu
951b8a62b91Sopenharmony_ci            gcc: aarch64-linux-gnu-gcc
952b8a62b91Sopenharmony_ci            qemu: qemu-aarch64
953b8a62b91Sopenharmony_ci            qemu_args: -L /usr/aarch64-linux-gnu
954b8a62b91Sopenharmony_ci            qemu_target: aarch64-linux-user
955b8a62b91Sopenharmony_ci          - build: powerpc64le-linux
956b8a62b91Sopenharmony_ci            os: ubuntu-latest
957b8a62b91Sopenharmony_ci            rust: nightly
958b8a62b91Sopenharmony_ci            target: powerpc64le-unknown-linux-gnu
959b8a62b91Sopenharmony_ci            gcc_package: gcc-powerpc64le-linux-gnu
960b8a62b91Sopenharmony_ci            gcc: powerpc64le-linux-gnu-gcc
961b8a62b91Sopenharmony_ci            qemu: qemu-ppc64le
962b8a62b91Sopenharmony_ci            qemu_args: -L /usr/powerpc64le-linux-gnu
963b8a62b91Sopenharmony_ci            qemu_target: ppc64le-linux-user
964b8a62b91Sopenharmony_ci          - build: mips64el-linux
965b8a62b91Sopenharmony_ci            os: ubuntu-latest
966b8a62b91Sopenharmony_ci            rust: nightly
967b8a62b91Sopenharmony_ci            target: mips64el-unknown-linux-gnuabi64
968b8a62b91Sopenharmony_ci            gcc_package: gcc-mips64el-linux-gnuabi64
969b8a62b91Sopenharmony_ci            gcc: mips64el-linux-gnuabi64-gcc
970b8a62b91Sopenharmony_ci            qemu: qemu-mips64el -L /usr/mips64el-linux-gnuabi64
971b8a62b91Sopenharmony_ci            qemu_target: mips64el-linux-user
972b8a62b91Sopenharmony_ci          - build: mipsel-linux
973b8a62b91Sopenharmony_ci            os: ubuntu-latest
974b8a62b91Sopenharmony_ci            rust: nightly
975b8a62b91Sopenharmony_ci            target: mipsel-unknown-linux-gnu
976b8a62b91Sopenharmony_ci            gcc_package: gcc-mipsel-linux-gnu
977b8a62b91Sopenharmony_ci            gcc: mipsel-linux-gnu-gcc
978b8a62b91Sopenharmony_ci            qemu: qemu-mipsel -L /usr/mipsel-linux-gnu
979b8a62b91Sopenharmony_ci            qemu_target: mipsel-linux-user
980b8a62b91Sopenharmony_ci          - build: riscv64-linux
981b8a62b91Sopenharmony_ci            os: ubuntu-latest
982b8a62b91Sopenharmony_ci            rust: nightly
983b8a62b91Sopenharmony_ci            target: riscv64gc-unknown-linux-gnu
984b8a62b91Sopenharmony_ci            gcc_package: gcc-riscv64-linux-gnu
985b8a62b91Sopenharmony_ci            gcc: riscv64-linux-gnu-gcc
986b8a62b91Sopenharmony_ci            qemu: qemu-riscv64
987b8a62b91Sopenharmony_ci            qemu_args: -L /usr/riscv64-linux-gnu
988b8a62b91Sopenharmony_ci            qemu_target: riscv64-linux-user
989b8a62b91Sopenharmony_ci          - build: arm-linux
990b8a62b91Sopenharmony_ci            os: ubuntu-latest
991b8a62b91Sopenharmony_ci            rust: nightly
992b8a62b91Sopenharmony_ci            target: armv5te-unknown-linux-gnueabi
993b8a62b91Sopenharmony_ci            gcc_package: gcc-arm-linux-gnueabi
994b8a62b91Sopenharmony_ci            gcc: arm-linux-gnueabi-gcc
995b8a62b91Sopenharmony_ci            qemu: qemu-arm
996b8a62b91Sopenharmony_ci            qemu_args: -L /usr/arm-linux-gnueabi
997b8a62b91Sopenharmony_ci            qemu_target: arm-linux-user
998b8a62b91Sopenharmony_ci    steps:
999b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
1000b8a62b91Sopenharmony_ci    - uses: ./.github/actions/install-rust
1001b8a62b91Sopenharmony_ci      with:
1002b8a62b91Sopenharmony_ci        toolchain: ${{ matrix.rust }}
1003b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
1004b8a62b91Sopenharmony_ci      with:
1005b8a62b91Sopenharmony_ci        repository: sunfishcode/rust-atomicwrites
1006b8a62b91Sopenharmony_ci        path: rust-atomicwrites
1007b8a62b91Sopenharmony_ci        ref: rustix-0.35.6-beta.2
1008b8a62b91Sopenharmony_ci
1009b8a62b91Sopenharmony_ci    - name: Configure Cargo target
1010b8a62b91Sopenharmony_ci      run: |
1011b8a62b91Sopenharmony_ci        echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
1012b8a62b91Sopenharmony_ci        rustup target add ${{ matrix.target }}
1013b8a62b91Sopenharmony_ci      if: matrix.target != ''
1014b8a62b91Sopenharmony_ci
1015b8a62b91Sopenharmony_ci    - uses: actions/cache@v3
1016b8a62b91Sopenharmony_ci      with:
1017b8a62b91Sopenharmony_ci        path: ${{ runner.tool_cache }}/qemu
1018b8a62b91Sopenharmony_ci        key: qemu-${{ matrix.target }}-${{ env.QEMU_BUILD_VERSION }}-patched
1019b8a62b91Sopenharmony_ci      if: matrix.target != '' && matrix.os == 'ubuntu-latest'
1020b8a62b91Sopenharmony_ci
1021b8a62b91Sopenharmony_ci    - name: Install cross-compilation tools
1022b8a62b91Sopenharmony_ci      run: |
1023b8a62b91Sopenharmony_ci        set -ex
1024b8a62b91Sopenharmony_ci        sudo apt-get update
1025b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build
1026b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
1027b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV
1028b8a62b91Sopenharmony_ci      if: matrix.gcc_package != '' && matrix.os == 'ubuntu-latest'
1029b8a62b91Sopenharmony_ci
1030b8a62b91Sopenharmony_ci    - name: Install cross-compilation libraries
1031b8a62b91Sopenharmony_ci      run: |
1032b8a62b91Sopenharmony_ci        set -ex
1033b8a62b91Sopenharmony_ci        sudo apt-get update
1034b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.libc_package }}
1035b8a62b91Sopenharmony_ci      if: matrix.libc_package != '' && matrix.os == 'ubuntu-latest'
1036b8a62b91Sopenharmony_ci
1037b8a62b91Sopenharmony_ci    - name: Install qemu
1038b8a62b91Sopenharmony_ci      run: |
1039b8a62b91Sopenharmony_ci        set -ex
1040b8a62b91Sopenharmony_ci
1041b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
1042b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_RUNNER=${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ${{ matrix.qemu_args }} >> $GITHUB_ENV
1043b8a62b91Sopenharmony_ci
1044b8a62b91Sopenharmony_ci        # See if qemu is already in the cache
1045b8a62b91Sopenharmony_ci        if [ -f ${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ]; then
1046b8a62b91Sopenharmony_ci          exit 0
1047b8a62b91Sopenharmony_ci        fi
1048b8a62b91Sopenharmony_ci
1049b8a62b91Sopenharmony_ci        # Download and build qemu from source since the most recent release is
1050b8a62b91Sopenharmony_ci        # way faster at arm emulation than the current version github actions'
1051b8a62b91Sopenharmony_ci        # ubuntu image uses. Disable as much as we can to get it to build
1052b8a62b91Sopenharmony_ci        # quickly.
1053b8a62b91Sopenharmony_ci        cd
1054b8a62b91Sopenharmony_ci        curl https://download.qemu.org/qemu-$QEMU_BUILD_VERSION.tar.xz | tar xJf -
1055b8a62b91Sopenharmony_ci        cd qemu-$QEMU_BUILD_VERSION
1056b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/translate-errno.patch
1057b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/getsockopt-timeouts.patch
1058b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/s390x-stat-have-nsec.patch
1059b8a62b91Sopenharmony_ci        ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache }}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs
1060b8a62b91Sopenharmony_ci        ninja -C build install
1061b8a62b91Sopenharmony_ci      if: matrix.qemu != '' && matrix.os == 'ubuntu-latest'
1062b8a62b91Sopenharmony_ci
1063b8a62b91Sopenharmony_ci    - run: cd rust-atomicwrites && cargo update
1064b8a62b91Sopenharmony_ci    - run: sed -i'.bak' 's/^version = "'`cd rust-atomicwrites && cargo tree --edges=normal |head -1 |sed 's/^[[:alnum:]_-]* v\([[:alnum:].-]*\) (.*/\1/'`'"$/version = '`grep -A1 '^name = "rustix"' rust-atomicwrites/Cargo.lock |grep ^version |sed 's/^[^"]*//'`'/' Cargo.toml
1065b8a62b91Sopenharmony_ci    - run: cd rust-atomicwrites && echo '[patch.crates-io]' >> Cargo.toml
1066b8a62b91Sopenharmony_ci    - run: cd rust-atomicwrites && echo 'rustix = { path = ".." }' >> Cargo.toml
1067b8a62b91Sopenharmony_ci    - run: cd rust-atomicwrites && cargo test
1068b8a62b91Sopenharmony_ci
1069b8a62b91Sopenharmony_ci  io-uring:
1070b8a62b91Sopenharmony_ci    name: io-uring ported to rustix
1071b8a62b91Sopenharmony_ci    runs-on: ${{ matrix.os }}
1072b8a62b91Sopenharmony_ci    env:
1073b8a62b91Sopenharmony_ci      QEMU_BUILD_VERSION: 7.0.0
1074b8a62b91Sopenharmony_ci    strategy:
1075b8a62b91Sopenharmony_ci      matrix:
1076b8a62b91Sopenharmony_ci        build: [ubuntu, i686-linux, aarch64-linux, powerpc64le-linux, riscv64-linux, mipsel-linux, mips64el-linux, arm-linux]
1077b8a62b91Sopenharmony_ci        include:
1078b8a62b91Sopenharmony_ci          - build: ubuntu
1079b8a62b91Sopenharmony_ci            os: ubuntu-latest
1080b8a62b91Sopenharmony_ci            rust: nightly
1081b8a62b91Sopenharmony_ci          - build: i686-linux
1082b8a62b91Sopenharmony_ci            os: ubuntu-latest
1083b8a62b91Sopenharmony_ci            rust: nightly
1084b8a62b91Sopenharmony_ci            target: i686-unknown-linux-gnu
1085b8a62b91Sopenharmony_ci            gcc_package: gcc-i686-linux-gnu
1086b8a62b91Sopenharmony_ci            gcc: i686-linux-gnu-gcc
1087b8a62b91Sopenharmony_ci            libc_package: libc-dev-i386-cross
1088b8a62b91Sopenharmony_ci          - build: aarch64-linux
1089b8a62b91Sopenharmony_ci            os: ubuntu-latest
1090b8a62b91Sopenharmony_ci            rust: nightly
1091b8a62b91Sopenharmony_ci            target: aarch64-unknown-linux-gnu
1092b8a62b91Sopenharmony_ci            gcc_package: gcc-aarch64-linux-gnu
1093b8a62b91Sopenharmony_ci            gcc: aarch64-linux-gnu-gcc
1094b8a62b91Sopenharmony_ci            qemu: qemu-aarch64
1095b8a62b91Sopenharmony_ci            qemu_args: -L /usr/aarch64-linux-gnu
1096b8a62b91Sopenharmony_ci            qemu_target: aarch64-linux-user
1097b8a62b91Sopenharmony_ci          - build: powerpc64le-linux
1098b8a62b91Sopenharmony_ci            os: ubuntu-latest
1099b8a62b91Sopenharmony_ci            rust: nightly
1100b8a62b91Sopenharmony_ci            target: powerpc64le-unknown-linux-gnu
1101b8a62b91Sopenharmony_ci            gcc_package: gcc-powerpc64le-linux-gnu
1102b8a62b91Sopenharmony_ci            gcc: powerpc64le-linux-gnu-gcc
1103b8a62b91Sopenharmony_ci            qemu: qemu-ppc64le
1104b8a62b91Sopenharmony_ci            qemu_args: -L /usr/powerpc64le-linux-gnu
1105b8a62b91Sopenharmony_ci            qemu_target: ppc64le-linux-user
1106b8a62b91Sopenharmony_ci          - build: mips64el-linux
1107b8a62b91Sopenharmony_ci            os: ubuntu-latest
1108b8a62b91Sopenharmony_ci            rust: nightly
1109b8a62b91Sopenharmony_ci            target: mips64el-unknown-linux-gnuabi64
1110b8a62b91Sopenharmony_ci            gcc_package: gcc-mips64el-linux-gnuabi64
1111b8a62b91Sopenharmony_ci            gcc: mips64el-linux-gnuabi64-gcc
1112b8a62b91Sopenharmony_ci            qemu: qemu-mips64el -L /usr/mips64el-linux-gnuabi64
1113b8a62b91Sopenharmony_ci            qemu_target: mips64el-linux-user
1114b8a62b91Sopenharmony_ci          - build: mipsel-linux
1115b8a62b91Sopenharmony_ci            os: ubuntu-latest
1116b8a62b91Sopenharmony_ci            rust: nightly
1117b8a62b91Sopenharmony_ci            target: mipsel-unknown-linux-gnu
1118b8a62b91Sopenharmony_ci            gcc_package: gcc-mipsel-linux-gnu
1119b8a62b91Sopenharmony_ci            gcc: mipsel-linux-gnu-gcc
1120b8a62b91Sopenharmony_ci            qemu: qemu-mipsel -L /usr/mipsel-linux-gnu
1121b8a62b91Sopenharmony_ci            qemu_target: mipsel-linux-user
1122b8a62b91Sopenharmony_ci          - build: riscv64-linux
1123b8a62b91Sopenharmony_ci            os: ubuntu-latest
1124b8a62b91Sopenharmony_ci            rust: nightly
1125b8a62b91Sopenharmony_ci            target: riscv64gc-unknown-linux-gnu
1126b8a62b91Sopenharmony_ci            gcc_package: gcc-riscv64-linux-gnu
1127b8a62b91Sopenharmony_ci            gcc: riscv64-linux-gnu-gcc
1128b8a62b91Sopenharmony_ci            qemu: qemu-riscv64
1129b8a62b91Sopenharmony_ci            qemu_args: -L /usr/riscv64-linux-gnu
1130b8a62b91Sopenharmony_ci            qemu_target: riscv64-linux-user
1131b8a62b91Sopenharmony_ci          - build: arm-linux
1132b8a62b91Sopenharmony_ci            os: ubuntu-latest
1133b8a62b91Sopenharmony_ci            rust: nightly
1134b8a62b91Sopenharmony_ci            target: armv5te-unknown-linux-gnueabi
1135b8a62b91Sopenharmony_ci            gcc_package: gcc-arm-linux-gnueabi
1136b8a62b91Sopenharmony_ci            gcc: arm-linux-gnueabi-gcc
1137b8a62b91Sopenharmony_ci            qemu: qemu-arm
1138b8a62b91Sopenharmony_ci            qemu_args: -L /usr/arm-linux-gnueabi
1139b8a62b91Sopenharmony_ci            qemu_target: arm-linux-user
1140b8a62b91Sopenharmony_ci    steps:
1141b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
1142b8a62b91Sopenharmony_ci    - uses: ./.github/actions/install-rust
1143b8a62b91Sopenharmony_ci      with:
1144b8a62b91Sopenharmony_ci        toolchain: ${{ matrix.rust }}
1145b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
1146b8a62b91Sopenharmony_ci      with:
1147b8a62b91Sopenharmony_ci        repository: sunfishcode/io-uring
1148b8a62b91Sopenharmony_ci        path: io-uring
1149b8a62b91Sopenharmony_ci        ref: rustix-0.35.6-beta.2
1150b8a62b91Sopenharmony_ci
1151b8a62b91Sopenharmony_ci    - name: Configure Cargo target
1152b8a62b91Sopenharmony_ci      run: |
1153b8a62b91Sopenharmony_ci        echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
1154b8a62b91Sopenharmony_ci        rustup target add ${{ matrix.target }}
1155b8a62b91Sopenharmony_ci      if: matrix.target != ''
1156b8a62b91Sopenharmony_ci
1157b8a62b91Sopenharmony_ci    - uses: actions/cache@v3
1158b8a62b91Sopenharmony_ci      with:
1159b8a62b91Sopenharmony_ci        path: ${{ runner.tool_cache }}/qemu
1160b8a62b91Sopenharmony_ci        key: qemu-${{ matrix.target }}-${{ env.QEMU_BUILD_VERSION }}-patched
1161b8a62b91Sopenharmony_ci      if: matrix.target != '' && matrix.os == 'ubuntu-latest'
1162b8a62b91Sopenharmony_ci
1163b8a62b91Sopenharmony_ci    - name: Install cross-compilation tools
1164b8a62b91Sopenharmony_ci      run: |
1165b8a62b91Sopenharmony_ci        set -ex
1166b8a62b91Sopenharmony_ci        sudo apt-get update
1167b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build
1168b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
1169b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV
1170b8a62b91Sopenharmony_ci      if: matrix.gcc_package != '' && matrix.os == 'ubuntu-latest'
1171b8a62b91Sopenharmony_ci
1172b8a62b91Sopenharmony_ci    - name: Install cross-compilation libraries
1173b8a62b91Sopenharmony_ci      run: |
1174b8a62b91Sopenharmony_ci        set -ex
1175b8a62b91Sopenharmony_ci        sudo apt-get update
1176b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.libc_package }}
1177b8a62b91Sopenharmony_ci      if: matrix.libc_package != '' && matrix.os == 'ubuntu-latest'
1178b8a62b91Sopenharmony_ci
1179b8a62b91Sopenharmony_ci    - name: Install qemu
1180b8a62b91Sopenharmony_ci      run: |
1181b8a62b91Sopenharmony_ci        set -ex
1182b8a62b91Sopenharmony_ci
1183b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
1184b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_RUNNER=${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ${{ matrix.qemu_args }} >> $GITHUB_ENV
1185b8a62b91Sopenharmony_ci
1186b8a62b91Sopenharmony_ci        # See if qemu is already in the cache
1187b8a62b91Sopenharmony_ci        if [ -f ${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ]; then
1188b8a62b91Sopenharmony_ci          exit 0
1189b8a62b91Sopenharmony_ci        fi
1190b8a62b91Sopenharmony_ci
1191b8a62b91Sopenharmony_ci        # Download and build qemu from source since the most recent release is
1192b8a62b91Sopenharmony_ci        # way faster at arm emulation than the current version github actions'
1193b8a62b91Sopenharmony_ci        # ubuntu image uses. Disable as much as we can to get it to build
1194b8a62b91Sopenharmony_ci        # quickly.
1195b8a62b91Sopenharmony_ci        cd
1196b8a62b91Sopenharmony_ci        curl https://download.qemu.org/qemu-$QEMU_BUILD_VERSION.tar.xz | tar xJf -
1197b8a62b91Sopenharmony_ci        cd qemu-$QEMU_BUILD_VERSION
1198b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/translate-errno.patch
1199b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/getsockopt-timeouts.patch
1200b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/s390x-stat-have-nsec.patch
1201b8a62b91Sopenharmony_ci        ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache }}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs
1202b8a62b91Sopenharmony_ci        ninja -C build install
1203b8a62b91Sopenharmony_ci      if: matrix.qemu != '' && matrix.os == 'ubuntu-latest'
1204b8a62b91Sopenharmony_ci
1205b8a62b91Sopenharmony_ci    - run: cd io-uring && cargo update
1206b8a62b91Sopenharmony_ci    - run: sed -i'.bak' 's/^version = "'`cd io-uring && cargo tree --edges=normal |head -1 |sed 's/^[[:alnum:]_-]* v\([[:alnum:].-]*\) (.*/\1/'`'"$/version = '`grep -A1 '^name = "rustix"' io-uring/Cargo.lock |grep ^version |sed 's/^[^"]*//'`'/' Cargo.toml
1207b8a62b91Sopenharmony_ci    - run: cd io-uring && echo '[patch.crates-io]' >> Cargo.toml
1208b8a62b91Sopenharmony_ci    - run: cd io-uring && echo 'rustix = { path = ".." }' >> Cargo.toml
1209b8a62b91Sopenharmony_ci    - run: cd io-uring && cargo test
1210b8a62b91Sopenharmony_ci
1211b8a62b91Sopenharmony_ci  tempfile:
1212b8a62b91Sopenharmony_ci    name: tempfile ported to rustix
1213b8a62b91Sopenharmony_ci    runs-on: ${{ matrix.os }}
1214b8a62b91Sopenharmony_ci    env:
1215b8a62b91Sopenharmony_ci      QEMU_BUILD_VERSION: 7.0.0
1216b8a62b91Sopenharmony_ci    strategy:
1217b8a62b91Sopenharmony_ci      matrix:
1218b8a62b91Sopenharmony_ci        build: [ubuntu, i686-linux, aarch64-linux, powerpc64le-linux, riscv64-linux, mipsel-linux, mips64el-linux, arm-linux, macos-latest]
1219b8a62b91Sopenharmony_ci        include:
1220b8a62b91Sopenharmony_ci          - build: ubuntu
1221b8a62b91Sopenharmony_ci            os: ubuntu-latest
1222b8a62b91Sopenharmony_ci            rust: nightly
1223b8a62b91Sopenharmony_ci          - build: i686-linux
1224b8a62b91Sopenharmony_ci            os: ubuntu-latest
1225b8a62b91Sopenharmony_ci            rust: nightly
1226b8a62b91Sopenharmony_ci            target: i686-unknown-linux-gnu
1227b8a62b91Sopenharmony_ci            gcc_package: gcc-i686-linux-gnu
1228b8a62b91Sopenharmony_ci            gcc: i686-linux-gnu-gcc
1229b8a62b91Sopenharmony_ci            libc_package: libc-dev-i386-cross
1230b8a62b91Sopenharmony_ci          - build: aarch64-linux
1231b8a62b91Sopenharmony_ci            os: ubuntu-latest
1232b8a62b91Sopenharmony_ci            rust: nightly
1233b8a62b91Sopenharmony_ci            target: aarch64-unknown-linux-gnu
1234b8a62b91Sopenharmony_ci            gcc_package: gcc-aarch64-linux-gnu
1235b8a62b91Sopenharmony_ci            gcc: aarch64-linux-gnu-gcc
1236b8a62b91Sopenharmony_ci            qemu: qemu-aarch64
1237b8a62b91Sopenharmony_ci            qemu_args: -L /usr/aarch64-linux-gnu
1238b8a62b91Sopenharmony_ci            qemu_target: aarch64-linux-user
1239b8a62b91Sopenharmony_ci          - build: powerpc64le-linux
1240b8a62b91Sopenharmony_ci            os: ubuntu-latest
1241b8a62b91Sopenharmony_ci            rust: nightly
1242b8a62b91Sopenharmony_ci            target: powerpc64le-unknown-linux-gnu
1243b8a62b91Sopenharmony_ci            gcc_package: gcc-powerpc64le-linux-gnu
1244b8a62b91Sopenharmony_ci            gcc: powerpc64le-linux-gnu-gcc
1245b8a62b91Sopenharmony_ci            qemu: qemu-ppc64le
1246b8a62b91Sopenharmony_ci            qemu_args: -L /usr/powerpc64le-linux-gnu
1247b8a62b91Sopenharmony_ci            qemu_target: ppc64le-linux-user
1248b8a62b91Sopenharmony_ci          - build: mips64el-linux
1249b8a62b91Sopenharmony_ci            os: ubuntu-latest
1250b8a62b91Sopenharmony_ci            rust: nightly
1251b8a62b91Sopenharmony_ci            target: mips64el-unknown-linux-gnuabi64
1252b8a62b91Sopenharmony_ci            gcc_package: gcc-mips64el-linux-gnuabi64
1253b8a62b91Sopenharmony_ci            gcc: mips64el-linux-gnuabi64-gcc
1254b8a62b91Sopenharmony_ci            qemu: qemu-mips64el
1255b8a62b91Sopenharmony_ci            qemu_args: -L /usr/mips64el-linux-gnuabi64
1256b8a62b91Sopenharmony_ci            qemu_target: mips64el-linux-user
1257b8a62b91Sopenharmony_ci          - build: mipsel-linux
1258b8a62b91Sopenharmony_ci            os: ubuntu-latest
1259b8a62b91Sopenharmony_ci            rust: nightly
1260b8a62b91Sopenharmony_ci            target: mipsel-unknown-linux-gnu
1261b8a62b91Sopenharmony_ci            gcc_package: gcc-mipsel-linux-gnu
1262b8a62b91Sopenharmony_ci            gcc: mipsel-linux-gnu-gcc
1263b8a62b91Sopenharmony_ci            qemu: qemu-mipsel
1264b8a62b91Sopenharmony_ci            qemu_args: -L /usr/mipsel-linux-gnu
1265b8a62b91Sopenharmony_ci            qemu_target: mipsel-linux-user
1266b8a62b91Sopenharmony_ci          - build: riscv64-linux
1267b8a62b91Sopenharmony_ci            os: ubuntu-latest
1268b8a62b91Sopenharmony_ci            rust: nightly
1269b8a62b91Sopenharmony_ci            target: riscv64gc-unknown-linux-gnu
1270b8a62b91Sopenharmony_ci            gcc_package: gcc-riscv64-linux-gnu
1271b8a62b91Sopenharmony_ci            gcc: riscv64-linux-gnu-gcc
1272b8a62b91Sopenharmony_ci            qemu: qemu-riscv64
1273b8a62b91Sopenharmony_ci            qemu_args: -L /usr/riscv64-linux-gnu
1274b8a62b91Sopenharmony_ci            qemu_target: riscv64-linux-user
1275b8a62b91Sopenharmony_ci          - build: arm-linux
1276b8a62b91Sopenharmony_ci            os: ubuntu-latest
1277b8a62b91Sopenharmony_ci            rust: nightly
1278b8a62b91Sopenharmony_ci            target: armv5te-unknown-linux-gnueabi
1279b8a62b91Sopenharmony_ci            gcc_package: gcc-arm-linux-gnueabi
1280b8a62b91Sopenharmony_ci            gcc: arm-linux-gnueabi-gcc
1281b8a62b91Sopenharmony_ci            qemu: qemu-arm
1282b8a62b91Sopenharmony_ci            qemu_args: -L /usr/arm-linux-gnueabi
1283b8a62b91Sopenharmony_ci            qemu_target: arm-linux-user
1284b8a62b91Sopenharmony_ci          - build: macos-latest
1285b8a62b91Sopenharmony_ci            os: macos-latest
1286b8a62b91Sopenharmony_ci            rust: nightly
1287b8a62b91Sopenharmony_ci    steps:
1288b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
1289b8a62b91Sopenharmony_ci    - uses: ./.github/actions/install-rust
1290b8a62b91Sopenharmony_ci      with:
1291b8a62b91Sopenharmony_ci        toolchain: ${{ matrix.rust }}
1292b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
1293b8a62b91Sopenharmony_ci      with:
1294b8a62b91Sopenharmony_ci        repository: sunfishcode/tempfile
1295b8a62b91Sopenharmony_ci        path: tempfile
1296b8a62b91Sopenharmony_ci        ref: rustix-0.35.6-beta.2
1297b8a62b91Sopenharmony_ci
1298b8a62b91Sopenharmony_ci    - name: Configure Cargo target
1299b8a62b91Sopenharmony_ci      run: |
1300b8a62b91Sopenharmony_ci        echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
1301b8a62b91Sopenharmony_ci        rustup target add ${{ matrix.target }}
1302b8a62b91Sopenharmony_ci      if: matrix.target != ''
1303b8a62b91Sopenharmony_ci
1304b8a62b91Sopenharmony_ci    - uses: actions/cache@v3
1305b8a62b91Sopenharmony_ci      with:
1306b8a62b91Sopenharmony_ci        path: ${{ runner.tool_cache }}/qemu
1307b8a62b91Sopenharmony_ci        key: qemu-${{ matrix.target }}-${{ env.QEMU_BUILD_VERSION }}-patched
1308b8a62b91Sopenharmony_ci      if: matrix.target != '' && matrix.os == 'ubuntu-latest'
1309b8a62b91Sopenharmony_ci
1310b8a62b91Sopenharmony_ci    - name: Install cross-compilation tools
1311b8a62b91Sopenharmony_ci      run: |
1312b8a62b91Sopenharmony_ci        set -ex
1313b8a62b91Sopenharmony_ci        sudo apt-get update
1314b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build
1315b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
1316b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV
1317b8a62b91Sopenharmony_ci      if: matrix.gcc_package != '' && matrix.os == 'ubuntu-latest'
1318b8a62b91Sopenharmony_ci
1319b8a62b91Sopenharmony_ci    - name: Install cross-compilation libraries
1320b8a62b91Sopenharmony_ci      run: |
1321b8a62b91Sopenharmony_ci        set -ex
1322b8a62b91Sopenharmony_ci        sudo apt-get update
1323b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.libc_package }}
1324b8a62b91Sopenharmony_ci      if: matrix.libc_package != '' && matrix.os == 'ubuntu-latest'
1325b8a62b91Sopenharmony_ci
1326b8a62b91Sopenharmony_ci    - name: Install qemu
1327b8a62b91Sopenharmony_ci      run: |
1328b8a62b91Sopenharmony_ci        set -ex
1329b8a62b91Sopenharmony_ci
1330b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
1331b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_RUNNER=${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ${{ matrix.qemu_args }} >> $GITHUB_ENV
1332b8a62b91Sopenharmony_ci
1333b8a62b91Sopenharmony_ci        # See if qemu is already in the cache
1334b8a62b91Sopenharmony_ci        if [ -f ${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ]; then
1335b8a62b91Sopenharmony_ci          exit 0
1336b8a62b91Sopenharmony_ci        fi
1337b8a62b91Sopenharmony_ci
1338b8a62b91Sopenharmony_ci        # Download and build qemu from source since the most recent release is
1339b8a62b91Sopenharmony_ci        # way faster at arm emulation than the current version github actions'
1340b8a62b91Sopenharmony_ci        # ubuntu image uses. Disable as much as we can to get it to build
1341b8a62b91Sopenharmony_ci        # quickly.
1342b8a62b91Sopenharmony_ci        cd
1343b8a62b91Sopenharmony_ci        curl https://download.qemu.org/qemu-$QEMU_BUILD_VERSION.tar.xz | tar xJf -
1344b8a62b91Sopenharmony_ci        cd qemu-$QEMU_BUILD_VERSION
1345b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/translate-errno.patch
1346b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/getsockopt-timeouts.patch
1347b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/s390x-stat-have-nsec.patch
1348b8a62b91Sopenharmony_ci        ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache }}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs
1349b8a62b91Sopenharmony_ci        ninja -C build install
1350b8a62b91Sopenharmony_ci      if: matrix.qemu != '' && matrix.os == 'ubuntu-latest'
1351b8a62b91Sopenharmony_ci
1352b8a62b91Sopenharmony_ci    - run: cd tempfile && cargo update
1353b8a62b91Sopenharmony_ci    - run: sed -i'.bak' 's/^version = "'`cd tempfile && cargo tree --edges=normal |head -1 |sed 's/^[[:alnum:]_-]* v\([[:alnum:].-]*\) (.*/\1/'`'"$/version = '`grep -A1 '^name = "rustix"' tempfile/Cargo.lock |grep ^version |sed 's/^[^"]*//'`'/' Cargo.toml
1354b8a62b91Sopenharmony_ci    - run: cd tempfile && echo '[patch.crates-io]' >> Cargo.toml
1355b8a62b91Sopenharmony_ci    - run: cd tempfile && echo 'rustix = { path = ".." }' >> Cargo.toml
1356b8a62b91Sopenharmony_ci    - run: cd tempfile && cargo test
1357b8a62b91Sopenharmony_ci
1358b8a62b91Sopenharmony_ci  fd-lock:
1359b8a62b91Sopenharmony_ci    name: fd-lock
1360b8a62b91Sopenharmony_ci    runs-on: ${{ matrix.os }}
1361b8a62b91Sopenharmony_ci    env:
1362b8a62b91Sopenharmony_ci      QEMU_BUILD_VERSION: 7.0.0
1363b8a62b91Sopenharmony_ci    strategy:
1364b8a62b91Sopenharmony_ci      matrix:
1365b8a62b91Sopenharmony_ci        build: [ubuntu, i686-linux, aarch64-linux, powerpc64le-linux, riscv64-linux, mipsel-linux, mips64el-linux, arm-linux, macos-latest]
1366b8a62b91Sopenharmony_ci        include:
1367b8a62b91Sopenharmony_ci          - build: ubuntu
1368b8a62b91Sopenharmony_ci            os: ubuntu-latest
1369b8a62b91Sopenharmony_ci            rust: nightly
1370b8a62b91Sopenharmony_ci          - build: i686-linux
1371b8a62b91Sopenharmony_ci            os: ubuntu-latest
1372b8a62b91Sopenharmony_ci            rust: nightly
1373b8a62b91Sopenharmony_ci            target: i686-unknown-linux-gnu
1374b8a62b91Sopenharmony_ci            gcc_package: gcc-i686-linux-gnu
1375b8a62b91Sopenharmony_ci            gcc: i686-linux-gnu-gcc
1376b8a62b91Sopenharmony_ci            libc_package: libc-dev-i386-cross
1377b8a62b91Sopenharmony_ci          - build: aarch64-linux
1378b8a62b91Sopenharmony_ci            os: ubuntu-latest
1379b8a62b91Sopenharmony_ci            rust: nightly
1380b8a62b91Sopenharmony_ci            target: aarch64-unknown-linux-gnu
1381b8a62b91Sopenharmony_ci            gcc_package: gcc-aarch64-linux-gnu
1382b8a62b91Sopenharmony_ci            gcc: aarch64-linux-gnu-gcc
1383b8a62b91Sopenharmony_ci            qemu: qemu-aarch64
1384b8a62b91Sopenharmony_ci            qemu_args: -L /usr/aarch64-linux-gnu
1385b8a62b91Sopenharmony_ci            qemu_target: aarch64-linux-user
1386b8a62b91Sopenharmony_ci          - build: powerpc64le-linux
1387b8a62b91Sopenharmony_ci            os: ubuntu-latest
1388b8a62b91Sopenharmony_ci            rust: nightly
1389b8a62b91Sopenharmony_ci            target: powerpc64le-unknown-linux-gnu
1390b8a62b91Sopenharmony_ci            gcc_package: gcc-powerpc64le-linux-gnu
1391b8a62b91Sopenharmony_ci            gcc: powerpc64le-linux-gnu-gcc
1392b8a62b91Sopenharmony_ci            qemu: qemu-ppc64le
1393b8a62b91Sopenharmony_ci            qemu_args: -L /usr/powerpc64le-linux-gnu
1394b8a62b91Sopenharmony_ci            qemu_target: ppc64le-linux-user
1395b8a62b91Sopenharmony_ci          - build: mips64el-linux
1396b8a62b91Sopenharmony_ci            os: ubuntu-latest
1397b8a62b91Sopenharmony_ci            rust: nightly
1398b8a62b91Sopenharmony_ci            target: mips64el-unknown-linux-gnuabi64
1399b8a62b91Sopenharmony_ci            gcc_package: gcc-mips64el-linux-gnuabi64
1400b8a62b91Sopenharmony_ci            gcc: mips64el-linux-gnuabi64-gcc
1401b8a62b91Sopenharmony_ci            qemu: qemu-mips64el
1402b8a62b91Sopenharmony_ci            qemu_args: -L /usr/mips64el-linux-gnuabi64
1403b8a62b91Sopenharmony_ci            qemu_target: mips64el-linux-user
1404b8a62b91Sopenharmony_ci          - build: mipsel-linux
1405b8a62b91Sopenharmony_ci            os: ubuntu-latest
1406b8a62b91Sopenharmony_ci            rust: nightly
1407b8a62b91Sopenharmony_ci            target: mipsel-unknown-linux-gnu
1408b8a62b91Sopenharmony_ci            gcc_package: gcc-mipsel-linux-gnu
1409b8a62b91Sopenharmony_ci            gcc: mipsel-linux-gnu-gcc
1410b8a62b91Sopenharmony_ci            qemu: qemu-mipsel
1411b8a62b91Sopenharmony_ci            qemu_args: -L /usr/mipsel-linux-gnu
1412b8a62b91Sopenharmony_ci            qemu_target: mipsel-linux-user
1413b8a62b91Sopenharmony_ci          - build: riscv64-linux
1414b8a62b91Sopenharmony_ci            os: ubuntu-latest
1415b8a62b91Sopenharmony_ci            rust: nightly
1416b8a62b91Sopenharmony_ci            target: riscv64gc-unknown-linux-gnu
1417b8a62b91Sopenharmony_ci            gcc_package: gcc-riscv64-linux-gnu
1418b8a62b91Sopenharmony_ci            gcc: riscv64-linux-gnu-gcc
1419b8a62b91Sopenharmony_ci            qemu: qemu-riscv64
1420b8a62b91Sopenharmony_ci            qemu_args: -L /usr/riscv64-linux-gnu
1421b8a62b91Sopenharmony_ci            qemu_target: riscv64-linux-user
1422b8a62b91Sopenharmony_ci          - build: arm-linux
1423b8a62b91Sopenharmony_ci            os: ubuntu-latest
1424b8a62b91Sopenharmony_ci            rust: nightly
1425b8a62b91Sopenharmony_ci            target: armv5te-unknown-linux-gnueabi
1426b8a62b91Sopenharmony_ci            gcc_package: gcc-arm-linux-gnueabi
1427b8a62b91Sopenharmony_ci            gcc: arm-linux-gnueabi-gcc
1428b8a62b91Sopenharmony_ci            qemu: qemu-arm
1429b8a62b91Sopenharmony_ci            qemu_args: -L /usr/arm-linux-gnueabi
1430b8a62b91Sopenharmony_ci            qemu_target: arm-linux-user
1431b8a62b91Sopenharmony_ci          - build: macos-latest
1432b8a62b91Sopenharmony_ci            os: macos-latest
1433b8a62b91Sopenharmony_ci            rust: nightly
1434b8a62b91Sopenharmony_ci    steps:
1435b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
1436b8a62b91Sopenharmony_ci    - uses: ./.github/actions/install-rust
1437b8a62b91Sopenharmony_ci      with:
1438b8a62b91Sopenharmony_ci        toolchain: ${{ matrix.rust }}
1439b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
1440b8a62b91Sopenharmony_ci      with:
1441b8a62b91Sopenharmony_ci        repository: sunfishcode/fd-lock
1442b8a62b91Sopenharmony_ci        path: fd-lock
1443b8a62b91Sopenharmony_ci        ref: rustix-0.35.6-beta.2
1444b8a62b91Sopenharmony_ci
1445b8a62b91Sopenharmony_ci    - name: Configure Cargo target
1446b8a62b91Sopenharmony_ci      run: |
1447b8a62b91Sopenharmony_ci        echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
1448b8a62b91Sopenharmony_ci        rustup target add ${{ matrix.target }}
1449b8a62b91Sopenharmony_ci      if: matrix.target != ''
1450b8a62b91Sopenharmony_ci
1451b8a62b91Sopenharmony_ci    - uses: actions/cache@v3
1452b8a62b91Sopenharmony_ci      with:
1453b8a62b91Sopenharmony_ci        path: ${{ runner.tool_cache }}/qemu
1454b8a62b91Sopenharmony_ci        key: qemu-${{ matrix.target }}-${{ env.QEMU_BUILD_VERSION }}-patched
1455b8a62b91Sopenharmony_ci      if: matrix.target != '' && matrix.os == 'ubuntu-latest'
1456b8a62b91Sopenharmony_ci
1457b8a62b91Sopenharmony_ci    - name: Install cross-compilation tools
1458b8a62b91Sopenharmony_ci      run: |
1459b8a62b91Sopenharmony_ci        set -ex
1460b8a62b91Sopenharmony_ci        sudo apt-get update
1461b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build
1462b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
1463b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV
1464b8a62b91Sopenharmony_ci      if: matrix.gcc_package != '' && matrix.os == 'ubuntu-latest'
1465b8a62b91Sopenharmony_ci
1466b8a62b91Sopenharmony_ci    - name: Install cross-compilation libraries
1467b8a62b91Sopenharmony_ci      run: |
1468b8a62b91Sopenharmony_ci        set -ex
1469b8a62b91Sopenharmony_ci        sudo apt-get update
1470b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.libc_package }}
1471b8a62b91Sopenharmony_ci      if: matrix.libc_package != '' && matrix.os == 'ubuntu-latest'
1472b8a62b91Sopenharmony_ci
1473b8a62b91Sopenharmony_ci    - name: Install qemu
1474b8a62b91Sopenharmony_ci      run: |
1475b8a62b91Sopenharmony_ci        set -ex
1476b8a62b91Sopenharmony_ci
1477b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
1478b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_RUNNER=${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ${{ matrix.qemu_args }} >> $GITHUB_ENV
1479b8a62b91Sopenharmony_ci
1480b8a62b91Sopenharmony_ci        # See if qemu is already in the cache
1481b8a62b91Sopenharmony_ci        if [ -f ${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ]; then
1482b8a62b91Sopenharmony_ci          exit 0
1483b8a62b91Sopenharmony_ci        fi
1484b8a62b91Sopenharmony_ci
1485b8a62b91Sopenharmony_ci        # Download and build qemu from source since the most recent release is
1486b8a62b91Sopenharmony_ci        # way faster at arm emulation than the current version github actions'
1487b8a62b91Sopenharmony_ci        # ubuntu image uses. Disable as much as we can to get it to build
1488b8a62b91Sopenharmony_ci        # quickly.
1489b8a62b91Sopenharmony_ci        cd
1490b8a62b91Sopenharmony_ci        curl https://download.qemu.org/qemu-$QEMU_BUILD_VERSION.tar.xz | tar xJf -
1491b8a62b91Sopenharmony_ci        cd qemu-$QEMU_BUILD_VERSION
1492b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/translate-errno.patch
1493b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/getsockopt-timeouts.patch
1494b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/s390x-stat-have-nsec.patch
1495b8a62b91Sopenharmony_ci        ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache }}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs
1496b8a62b91Sopenharmony_ci        ninja -C build install
1497b8a62b91Sopenharmony_ci      if: matrix.qemu != '' && matrix.os == 'ubuntu-latest'
1498b8a62b91Sopenharmony_ci
1499b8a62b91Sopenharmony_ci    - run: cd fd-lock && cargo update
1500b8a62b91Sopenharmony_ci    - run: sed -i'.bak' 's/^version = "'`cd fd-lock && cargo tree --edges=normal |head -1 |sed 's/^[[:alnum:]_-]* v\([[:alnum:].-]*\) (.*/\1/'`'"$/version = '`grep -A1 '^name = "rustix"' fd-lock/Cargo.lock |grep ^version |sed 's/^[^"]*//'`'/' Cargo.toml
1501b8a62b91Sopenharmony_ci    - run: cd fd-lock && echo '[patch.crates-io]' >> Cargo.toml
1502b8a62b91Sopenharmony_ci    - run: cd fd-lock && echo 'rustix = { path = ".." }' >> Cargo.toml
1503b8a62b91Sopenharmony_ci    - run: cd fd-lock && cargo test
1504b8a62b91Sopenharmony_ci
1505b8a62b91Sopenharmony_ci  wasmtime:
1506b8a62b91Sopenharmony_ci    name: wasmtime
1507b8a62b91Sopenharmony_ci    runs-on: ${{ matrix.os }}
1508b8a62b91Sopenharmony_ci    strategy:
1509b8a62b91Sopenharmony_ci      matrix:
1510b8a62b91Sopenharmony_ci        # Qemu doesn't support running Wasmtime.
1511b8a62b91Sopenharmony_ci        build: [ubuntu, macos-latest]
1512b8a62b91Sopenharmony_ci        include:
1513b8a62b91Sopenharmony_ci          - build: ubuntu
1514b8a62b91Sopenharmony_ci            os: ubuntu-latest
1515b8a62b91Sopenharmony_ci            rust: nightly
1516b8a62b91Sopenharmony_ci          - build: macos-latest
1517b8a62b91Sopenharmony_ci            os: macos-latest
1518b8a62b91Sopenharmony_ci            rust: nightly
1519b8a62b91Sopenharmony_ci    steps:
1520b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
1521b8a62b91Sopenharmony_ci    - uses: ./.github/actions/install-rust
1522b8a62b91Sopenharmony_ci      with:
1523b8a62b91Sopenharmony_ci        toolchain: ${{ matrix.rust }}
1524b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
1525b8a62b91Sopenharmony_ci      with:
1526b8a62b91Sopenharmony_ci        repository: sunfishcode/wasmtime
1527b8a62b91Sopenharmony_ci        path: wasmtime
1528b8a62b91Sopenharmony_ci        ref: rustix-0.35.6-beta.2
1529b8a62b91Sopenharmony_ci        submodules: true
1530b8a62b91Sopenharmony_ci
1531b8a62b91Sopenharmony_ci    - run: rustup target add wasm32-wasi
1532b8a62b91Sopenharmony_ci    - run: cd wasmtime && cargo update
1533b8a62b91Sopenharmony_ci    - run: sed -i'.bak' 's/^version = "'`cd wasmtime && cargo tree --edges=normal |head -1 |sed 's/^[[:alnum:]_-]* v\([[:alnum:].-]*\) (.*/\1/'`'"$/version = '`grep -A1 '^name = "rustix"' wasmtime/Cargo.lock |grep ^version |sed 's/^[^"]*//'`'/' Cargo.toml
1534b8a62b91Sopenharmony_ci    - run: cd wasmtime && echo '[patch.crates-io]' >> Cargo.toml
1535b8a62b91Sopenharmony_ci    - run: cd wasmtime && echo 'rustix = { path = ".." }' >> Cargo.toml
1536b8a62b91Sopenharmony_ci    - run: cd wasmtime && cargo test --features "test-programs/test_programs" --workspace --exclude 'wasmtime-wasi-*' --exclude wasi-crypto --exclude wasmtime-fuzzing
1537b8a62b91Sopenharmony_ci
1538b8a62b91Sopenharmony_ci  nameless:
1539b8a62b91Sopenharmony_ci    name: nameless
1540b8a62b91Sopenharmony_ci    runs-on: ${{ matrix.os }}
1541b8a62b91Sopenharmony_ci    strategy:
1542b8a62b91Sopenharmony_ci      matrix:
1543b8a62b91Sopenharmony_ci        # Our build script below only runs on Linux at the moment.
1544b8a62b91Sopenharmony_ci        # Our build script below doesn't support cross compilation at the moment.
1545b8a62b91Sopenharmony_ci        build: [ubuntu]
1546b8a62b91Sopenharmony_ci        include:
1547b8a62b91Sopenharmony_ci          - build: ubuntu
1548b8a62b91Sopenharmony_ci            os: ubuntu-latest
1549b8a62b91Sopenharmony_ci            rust: nightly
1550b8a62b91Sopenharmony_ci    steps:
1551b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
1552b8a62b91Sopenharmony_ci    - uses: ./.github/actions/install-rust
1553b8a62b91Sopenharmony_ci      with:
1554b8a62b91Sopenharmony_ci        toolchain: ${{ matrix.rust }}
1555b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
1556b8a62b91Sopenharmony_ci      with:
1557b8a62b91Sopenharmony_ci        repository: sunfishcode/nameless
1558b8a62b91Sopenharmony_ci        path: nameless
1559b8a62b91Sopenharmony_ci        ref: rustix-0.35.6-beta.2
1560b8a62b91Sopenharmony_ci
1561b8a62b91Sopenharmony_ci    - run: |
1562b8a62b91Sopenharmony_ci        set -ex
1563b8a62b91Sopenharmony_ci        sudo apt-get update
1564b8a62b91Sopenharmony_ci        sudo apt-get install -y libssl-dev
1565b8a62b91Sopenharmony_ci    - run: cd nameless && cargo update
1566b8a62b91Sopenharmony_ci    - run: sed -i'.bak' 's/^version = "'`cd nameless && cargo tree --edges=normal |head -1 |sed 's/^[[:alnum:]_-]* v\([[:alnum:].-]*\) (.*/\1/'`'"$/version = '`grep -A1 '^name = "rustix"' nameless/Cargo.lock |grep ^version |sed 's/^[^"]*//'`'/' Cargo.toml
1567b8a62b91Sopenharmony_ci    - run: cd nameless && echo '[patch.crates-io]' >> Cargo.toml
1568b8a62b91Sopenharmony_ci    - run: cd nameless && echo 'rustix = { path = ".." }' >> Cargo.toml
1569b8a62b91Sopenharmony_ci    - run: cd nameless && cargo test
1570b8a62b91Sopenharmony_ci
1571b8a62b91Sopenharmony_ci  cap-std-ext:
1572b8a62b91Sopenharmony_ci    name: cap-std-ext
1573b8a62b91Sopenharmony_ci    runs-on: ${{ matrix.os }}
1574b8a62b91Sopenharmony_ci    env:
1575b8a62b91Sopenharmony_ci      QEMU_BUILD_VERSION: 7.0.0
1576b8a62b91Sopenharmony_ci    strategy:
1577b8a62b91Sopenharmony_ci      matrix:
1578b8a62b91Sopenharmony_ci        # cap-std-ext only builds on Linux at the moment.
1579b8a62b91Sopenharmony_ci        build: [ubuntu, i686-linux, aarch64-linux, powerpc64le-linux, riscv64-linux, mipsel-linux, mips64el-linux, arm-linux]
1580b8a62b91Sopenharmony_ci        include:
1581b8a62b91Sopenharmony_ci          - build: ubuntu
1582b8a62b91Sopenharmony_ci            os: ubuntu-latest
1583b8a62b91Sopenharmony_ci            rust: nightly
1584b8a62b91Sopenharmony_ci          - build: i686-linux
1585b8a62b91Sopenharmony_ci            os: ubuntu-latest
1586b8a62b91Sopenharmony_ci            rust: nightly
1587b8a62b91Sopenharmony_ci            target: i686-unknown-linux-gnu
1588b8a62b91Sopenharmony_ci            gcc_package: gcc-i686-linux-gnu
1589b8a62b91Sopenharmony_ci            gcc: i686-linux-gnu-gcc
1590b8a62b91Sopenharmony_ci            libc_package: libc-dev-i386-cross
1591b8a62b91Sopenharmony_ci          - build: aarch64-linux
1592b8a62b91Sopenharmony_ci            os: ubuntu-latest
1593b8a62b91Sopenharmony_ci            rust: nightly
1594b8a62b91Sopenharmony_ci            target: aarch64-unknown-linux-gnu
1595b8a62b91Sopenharmony_ci            gcc_package: gcc-aarch64-linux-gnu
1596b8a62b91Sopenharmony_ci            gcc: aarch64-linux-gnu-gcc
1597b8a62b91Sopenharmony_ci            qemu: qemu-aarch64
1598b8a62b91Sopenharmony_ci            qemu_args: -L /usr/aarch64-linux-gnu
1599b8a62b91Sopenharmony_ci            qemu_target: aarch64-linux-user
1600b8a62b91Sopenharmony_ci          - build: powerpc64le-linux
1601b8a62b91Sopenharmony_ci            os: ubuntu-latest
1602b8a62b91Sopenharmony_ci            rust: nightly
1603b8a62b91Sopenharmony_ci            target: powerpc64le-unknown-linux-gnu
1604b8a62b91Sopenharmony_ci            gcc_package: gcc-powerpc64le-linux-gnu
1605b8a62b91Sopenharmony_ci            gcc: powerpc64le-linux-gnu-gcc
1606b8a62b91Sopenharmony_ci            qemu: qemu-ppc64le
1607b8a62b91Sopenharmony_ci            qemu_args: -L /usr/powerpc64le-linux-gnu
1608b8a62b91Sopenharmony_ci            qemu_target: ppc64le-linux-user
1609b8a62b91Sopenharmony_ci          - build: mips64el-linux
1610b8a62b91Sopenharmony_ci            os: ubuntu-latest
1611b8a62b91Sopenharmony_ci            rust: nightly
1612b8a62b91Sopenharmony_ci            target: mips64el-unknown-linux-gnuabi64
1613b8a62b91Sopenharmony_ci            gcc_package: gcc-mips64el-linux-gnuabi64
1614b8a62b91Sopenharmony_ci            gcc: mips64el-linux-gnuabi64-gcc
1615b8a62b91Sopenharmony_ci            qemu: qemu-mips64el
1616b8a62b91Sopenharmony_ci            qemu_args: -L /usr/mips64el-linux-gnuabi64
1617b8a62b91Sopenharmony_ci            qemu_target: mips64el-linux-user
1618b8a62b91Sopenharmony_ci          - build: mipsel-linux
1619b8a62b91Sopenharmony_ci            os: ubuntu-latest
1620b8a62b91Sopenharmony_ci            rust: nightly
1621b8a62b91Sopenharmony_ci            target: mipsel-unknown-linux-gnu
1622b8a62b91Sopenharmony_ci            gcc_package: gcc-mipsel-linux-gnu
1623b8a62b91Sopenharmony_ci            gcc: mipsel-linux-gnu-gcc
1624b8a62b91Sopenharmony_ci            qemu: qemu-mipsel
1625b8a62b91Sopenharmony_ci            qemu_args: -L /usr/mipsel-linux-gnu
1626b8a62b91Sopenharmony_ci            qemu_target: mipsel-linux-user
1627b8a62b91Sopenharmony_ci          - build: riscv64-linux
1628b8a62b91Sopenharmony_ci            os: ubuntu-latest
1629b8a62b91Sopenharmony_ci            rust: nightly
1630b8a62b91Sopenharmony_ci            target: riscv64gc-unknown-linux-gnu
1631b8a62b91Sopenharmony_ci            gcc_package: gcc-riscv64-linux-gnu
1632b8a62b91Sopenharmony_ci            gcc: riscv64-linux-gnu-gcc
1633b8a62b91Sopenharmony_ci            qemu: qemu-riscv64
1634b8a62b91Sopenharmony_ci            qemu_args: -L /usr/riscv64-linux-gnu
1635b8a62b91Sopenharmony_ci            qemu_target: riscv64-linux-user
1636b8a62b91Sopenharmony_ci          - build: arm-linux
1637b8a62b91Sopenharmony_ci            os: ubuntu-latest
1638b8a62b91Sopenharmony_ci            rust: nightly
1639b8a62b91Sopenharmony_ci            target: armv5te-unknown-linux-gnueabi
1640b8a62b91Sopenharmony_ci            gcc_package: gcc-arm-linux-gnueabi
1641b8a62b91Sopenharmony_ci            gcc: arm-linux-gnueabi-gcc
1642b8a62b91Sopenharmony_ci            qemu: qemu-arm
1643b8a62b91Sopenharmony_ci            qemu_args: -L /usr/arm-linux-gnueabi
1644b8a62b91Sopenharmony_ci            qemu_target: arm-linux-user
1645b8a62b91Sopenharmony_ci    steps:
1646b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
1647b8a62b91Sopenharmony_ci    - uses: ./.github/actions/install-rust
1648b8a62b91Sopenharmony_ci      with:
1649b8a62b91Sopenharmony_ci        toolchain: ${{ matrix.rust }}
1650b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
1651b8a62b91Sopenharmony_ci      with:
1652b8a62b91Sopenharmony_ci        #repository: coreos/cap-std-ext
1653b8a62b91Sopenharmony_ci        repository: sunfishcode/cap-std-ext
1654b8a62b91Sopenharmony_ci        path: cap-std-ext
1655b8a62b91Sopenharmony_ci        ref: rustix-0.35.6-beta.2
1656b8a62b91Sopenharmony_ci
1657b8a62b91Sopenharmony_ci    - name: Configure Cargo target
1658b8a62b91Sopenharmony_ci      run: |
1659b8a62b91Sopenharmony_ci        echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
1660b8a62b91Sopenharmony_ci        rustup target add ${{ matrix.target }}
1661b8a62b91Sopenharmony_ci      if: matrix.target != ''
1662b8a62b91Sopenharmony_ci
1663b8a62b91Sopenharmony_ci    - uses: actions/cache@v3
1664b8a62b91Sopenharmony_ci      with:
1665b8a62b91Sopenharmony_ci        path: ${{ runner.tool_cache }}/qemu
1666b8a62b91Sopenharmony_ci        key: qemu-${{ matrix.target }}-${{ env.QEMU_BUILD_VERSION }}-patched
1667b8a62b91Sopenharmony_ci      if: matrix.target != '' && matrix.os == 'ubuntu-latest'
1668b8a62b91Sopenharmony_ci
1669b8a62b91Sopenharmony_ci    - name: Install cross-compilation tools
1670b8a62b91Sopenharmony_ci      run: |
1671b8a62b91Sopenharmony_ci        set -ex
1672b8a62b91Sopenharmony_ci        sudo apt-get update
1673b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.gcc_package }} ninja-build
1674b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
1675b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_LINKER=${{ matrix.gcc }} >> $GITHUB_ENV
1676b8a62b91Sopenharmony_ci      if: matrix.gcc_package != '' && matrix.os == 'ubuntu-latest'
1677b8a62b91Sopenharmony_ci
1678b8a62b91Sopenharmony_ci    - name: Install cross-compilation libraries
1679b8a62b91Sopenharmony_ci      run: |
1680b8a62b91Sopenharmony_ci        set -ex
1681b8a62b91Sopenharmony_ci        sudo apt-get update
1682b8a62b91Sopenharmony_ci        sudo apt-get install -y ${{ matrix.libc_package }}
1683b8a62b91Sopenharmony_ci      if: matrix.libc_package != '' && matrix.os == 'ubuntu-latest'
1684b8a62b91Sopenharmony_ci
1685b8a62b91Sopenharmony_ci    - name: Install qemu
1686b8a62b91Sopenharmony_ci      run: |
1687b8a62b91Sopenharmony_ci        set -ex
1688b8a62b91Sopenharmony_ci
1689b8a62b91Sopenharmony_ci        upcase=$(echo ${{ matrix.target }} | awk '{ print toupper($0) }' | sed 's/-/_/g')
1690b8a62b91Sopenharmony_ci        echo CARGO_TARGET_${upcase}_RUNNER=${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ${{ matrix.qemu_args }} >> $GITHUB_ENV
1691b8a62b91Sopenharmony_ci
1692b8a62b91Sopenharmony_ci        # See if qemu is already in the cache
1693b8a62b91Sopenharmony_ci        if [ -f ${{ runner.tool_cache }}/qemu/bin/${{ matrix.qemu }} ]; then
1694b8a62b91Sopenharmony_ci          exit 0
1695b8a62b91Sopenharmony_ci        fi
1696b8a62b91Sopenharmony_ci
1697b8a62b91Sopenharmony_ci        # Download and build qemu from source since the most recent release is
1698b8a62b91Sopenharmony_ci        # way faster at arm emulation than the current version github actions'
1699b8a62b91Sopenharmony_ci        # ubuntu image uses. Disable as much as we can to get it to build
1700b8a62b91Sopenharmony_ci        # quickly.
1701b8a62b91Sopenharmony_ci        cd
1702b8a62b91Sopenharmony_ci        curl https://download.qemu.org/qemu-$QEMU_BUILD_VERSION.tar.xz | tar xJf -
1703b8a62b91Sopenharmony_ci        cd qemu-$QEMU_BUILD_VERSION
1704b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/translate-errno.patch
1705b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/getsockopt-timeouts.patch
1706b8a62b91Sopenharmony_ci        patch -p1 < $GITHUB_WORKSPACE/ci/s390x-stat-have-nsec.patch
1707b8a62b91Sopenharmony_ci        ./configure --target-list=${{ matrix.qemu_target }} --prefix=${{ runner.tool_cache }}/qemu --disable-tools --disable-slirp --disable-fdt --disable-capstone --disable-docs
1708b8a62b91Sopenharmony_ci        ninja -C build install
1709b8a62b91Sopenharmony_ci      if: matrix.qemu != '' && matrix.os == 'ubuntu-latest'
1710b8a62b91Sopenharmony_ci
1711b8a62b91Sopenharmony_ci    - run: cd cap-std-ext && cargo update
1712b8a62b91Sopenharmony_ci    - run: sed -i'.bak' 's/^version = "'`cd cap-std-ext && cargo tree --edges=normal |head -1 |sed 's/^[[:alnum:]_-]* v\([[:alnum:].-]*\) (.*/\1/'`'"$/version = '`grep -A1 '^name = "rustix"' cap-std-ext/Cargo.lock |grep ^version |sed 's/^[^"]*//'`'/' Cargo.toml
1713b8a62b91Sopenharmony_ci    - run: cd cap-std-ext && echo '[patch.crates-io]' >> Cargo.toml
1714b8a62b91Sopenharmony_ci    - run: cd cap-std-ext && echo 'rustix = { path = ".." }' >> Cargo.toml
1715b8a62b91Sopenharmony_ci    - run: cd cap-std-ext && cargo test
1716b8a62b91Sopenharmony_ci
1717b8a62b91Sopenharmony_ci  dbus-rs:
1718b8a62b91Sopenharmony_ci    name: dbus-rs ported to rustix
1719b8a62b91Sopenharmony_ci    runs-on: ${{ matrix.os }}
1720b8a62b91Sopenharmony_ci    strategy:
1721b8a62b91Sopenharmony_ci      matrix:
1722b8a62b91Sopenharmony_ci        # Our build script below only runs on Linux at the moment.
1723b8a62b91Sopenharmony_ci        # Our build script below doesn't support cross compilation at the moment.
1724b8a62b91Sopenharmony_ci        build: [ubuntu]
1725b8a62b91Sopenharmony_ci        include:
1726b8a62b91Sopenharmony_ci          - build: ubuntu
1727b8a62b91Sopenharmony_ci            os: ubuntu-latest
1728b8a62b91Sopenharmony_ci            #rust: nightly
1729b8a62b91Sopenharmony_ci            rust: stable
1730b8a62b91Sopenharmony_ci    steps:
1731b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
1732b8a62b91Sopenharmony_ci    - uses: ./.github/actions/install-rust
1733b8a62b91Sopenharmony_ci      with:
1734b8a62b91Sopenharmony_ci        toolchain: ${{ matrix.rust }}
1735b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
1736b8a62b91Sopenharmony_ci      with:
1737b8a62b91Sopenharmony_ci        repository: sunfishcode/dbus-rs
1738b8a62b91Sopenharmony_ci        path: dbus-rs
1739b8a62b91Sopenharmony_ci        ref: rustix-0.35.6-beta.2
1740b8a62b91Sopenharmony_ci
1741b8a62b91Sopenharmony_ci    - run: |
1742b8a62b91Sopenharmony_ci        set -ex
1743b8a62b91Sopenharmony_ci        sudo apt-get update
1744b8a62b91Sopenharmony_ci        sudo apt-get install -y libdbus-1-dev at-spi2-core pkg-config
1745b8a62b91Sopenharmony_ci    - run: cd dbus-rs && cargo update
1746b8a62b91Sopenharmony_ci    - run: sed -i'.bak' 's/^version = "'`cd dbus-rs && cargo tree --edges=normal |head -1 |sed 's/^[[:alnum:]_-]* v\([[:alnum:].-]*\) (.*/\1/'`'"$/version = '`grep -A1 '^name = "rustix"' dbus-rs/Cargo.lock |grep ^version |sed 's/^[^"]*//'`'/' Cargo.toml
1747b8a62b91Sopenharmony_ci    - run: cd dbus-rs && echo '[patch.crates-io]' >> Cargo.toml
1748b8a62b91Sopenharmony_ci    - run: cd dbus-rs && echo 'rustix = { path = ".." }' >> Cargo.toml
1749b8a62b91Sopenharmony_ci    - run: cd dbus-rs && env DBUS_SESSION_BUS_ADDRESS=`dbus-daemon --session --print-address --fork` cargo test --workspace
1750b8a62b91Sopenharmony_ci
1751b8a62b91Sopenharmony_ci  mustang:
1752b8a62b91Sopenharmony_ci    name: mustang
1753b8a62b91Sopenharmony_ci    runs-on: ${{ matrix.os }}
1754b8a62b91Sopenharmony_ci    strategy:
1755b8a62b91Sopenharmony_ci      matrix:
1756b8a62b91Sopenharmony_ci        build: [ubuntu]
1757b8a62b91Sopenharmony_ci        include:
1758b8a62b91Sopenharmony_ci          - build: ubuntu
1759b8a62b91Sopenharmony_ci            os: ubuntu-latest
1760b8a62b91Sopenharmony_ci            rust: nightly
1761b8a62b91Sopenharmony_ci    steps:
1762b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
1763b8a62b91Sopenharmony_ci    - uses: ./.github/actions/install-rust
1764b8a62b91Sopenharmony_ci      with:
1765b8a62b91Sopenharmony_ci        toolchain: ${{ matrix.rust }}
1766b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
1767b8a62b91Sopenharmony_ci      with:
1768b8a62b91Sopenharmony_ci        repository: sunfishcode/mustang
1769b8a62b91Sopenharmony_ci        path: mustang
1770b8a62b91Sopenharmony_ci
1771b8a62b91Sopenharmony_ci    - run: rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
1772b8a62b91Sopenharmony_ci    - run: cd mustang && cargo update
1773b8a62b91Sopenharmony_ci    - run: sed -i'.bak' 's/^version = "'`cd mustang && cargo tree --edges=normal |head -1 |sed 's/^[[:alnum:]_-]* v\([[:alnum:].-]*\) (.*/\1/'`'"$/version = '`grep -A1 '^name = "rustix"' mustang/Cargo.lock |grep ^version |sed 's/^[^"]*//'`'/' Cargo.toml
1774b8a62b91Sopenharmony_ci    - run: cd mustang && echo '[patch.crates-io]' >> Cargo.toml
1775b8a62b91Sopenharmony_ci    - run: cd mustang && echo 'rustix = { path = ".." }' >> Cargo.toml
1776b8a62b91Sopenharmony_ci    # This test takes too long.
1777b8a62b91Sopenharmony_ci    - run: cd mustang && sed -i'.bak' 's/fn concurrent_recursive_mkdir()/#[ignore]\rfn concurrent_recursive_mkdir()/' tests/fs.rs
1778b8a62b91Sopenharmony_ci    # Use jobs=1 to hopefully avoid apparently oversubscribing the runner.
1779b8a62b91Sopenharmony_ci    - run: cd mustang && cargo test --target=specs/x86_64-mustang-linux-gnu.json -Zbuild-std --jobs=1
1780b8a62b91Sopenharmony_ci
1781b8a62b91Sopenharmony_ci  std:
1782b8a62b91Sopenharmony_ci    name: std ported to rustix
1783b8a62b91Sopenharmony_ci    runs-on: ${{ matrix.os }}
1784b8a62b91Sopenharmony_ci    strategy:
1785b8a62b91Sopenharmony_ci      matrix:
1786b8a62b91Sopenharmony_ci        build: [ubuntu]
1787b8a62b91Sopenharmony_ci        include:
1788b8a62b91Sopenharmony_ci          - build: ubuntu
1789b8a62b91Sopenharmony_ci            os: ubuntu-latest
1790b8a62b91Sopenharmony_ci            rust: nightly
1791b8a62b91Sopenharmony_ci    steps:
1792b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
1793b8a62b91Sopenharmony_ci      with:
1794b8a62b91Sopenharmony_ci        # Fetch everything to get rebase with rustc-dep-of-std.
1795b8a62b91Sopenharmony_ci        fetch-depth: 0
1796b8a62b91Sopenharmony_ci    - uses: ./.github/actions/install-rust
1797b8a62b91Sopenharmony_ci      with:
1798b8a62b91Sopenharmony_ci        toolchain: ${{ matrix.rust }}
1799b8a62b91Sopenharmony_ci    - uses: actions/checkout@v3
1800b8a62b91Sopenharmony_ci      with:
1801b8a62b91Sopenharmony_ci        repository: sunfishcode/rust
1802b8a62b91Sopenharmony_ci        path: rust
1803b8a62b91Sopenharmony_ci        ref: rustix
1804b8a62b91Sopenharmony_ci        submodules: true
1805b8a62b91Sopenharmony_ci        # Fetch at least 200 to let the bootstrap script find an LLVM revision.
1806b8a62b91Sopenharmony_ci        fetch-depth: 200
1807b8a62b91Sopenharmony_ci    # Hack to get git rebase to work.
1808b8a62b91Sopenharmony_ci    - run: git config --global user.email "you@example.com"
1809b8a62b91Sopenharmony_ci    - run: git config --global user.name "Your Name"
1810b8a62b91Sopenharmony_ci    # Include the changes needed to support std.
1811b8a62b91Sopenharmony_ci    - run: git rebase origin/rustc-dep-of-std
1812b8a62b91Sopenharmony_ci    # Download a pre-built LLVM instead of building it from source.
1813b8a62b91Sopenharmony_ci    - run: cd rust && echo "[llvm]" >> config.toml
1814b8a62b91Sopenharmony_ci    - run: cd rust && echo "download-ci-llvm = true" >> config.toml
1815b8a62b91Sopenharmony_ci    - run: cd rust && sed -i'.bak' 's/\<git = "https:\/\/github\.com\/bytecodealliance\/rustix", branch = "rustc-dep-of-std"/path = "..\/..\/.."/' library/std/Cargo.toml
1816b8a62b91Sopenharmony_ci    - run: cd rust && ./x.py test library/std --stage=0
1817b8a62b91Sopenharmony_ci      # See <https://github.com/bytecodealliance/rustix/issues/76#issuecomment-962196433>
1818b8a62b91Sopenharmony_ci      env:
1819b8a62b91Sopenharmony_ci        RUSTFLAGS: --cfg=linux_raw --cfg=asm --cfg=rustc_attrs
1820