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