Skip to content

Commit

Permalink
Support Ubuntu and Debian containers
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Apr 13, 2024
1 parent ac928c9 commit 379cd17
Show file tree
Hide file tree
Showing 5 changed files with 242 additions and 76 deletions.
1 change: 1 addition & 0 deletions .github/.cspell/project-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ armeabi
BINDGEN
binfmt
CXXSTDLIB
distro
endgroup
haswell
libclang
Expand Down
79 changes: 79 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,82 @@ jobs:
# TODO(windows host): No files were found with the provided path: /tmp/artifacts/. No artifacts will be uploaded.
path: /tmp/artifacts/
if: matrix.runner == '' && matrix.qemu == '' && matrix.wine == ''

test-container:
needs: tidy
strategy:
fail-fast: false
matrix:
container:
- ubuntu:18.04 # glibc 2.27
- ubuntu:20.04 # glibc 2.31
- ubuntu:22.04 # glibc 2.35
- debian:10-slim # glibc 2.28
- debian:11-slim # glibc 2.31
- debian:12-slim # glibc 2.36
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
# TODO: No such file or directory
# - i586-unknown-linux-gnu
# - i686-unknown-linux-gnu
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
- aarch64-linux-android
- x86_64-unknown-freebsd
- x86_64-unknown-netbsd
- wasm32-wasi
- x86_64-pc-windows-gnu
- x86_64-pc-windows-gnullvm
# prettier-ignore
exclude:
# Toolchains not available on ubuntu 18.04
- { target: mipsisa32r6-unknown-linux-gnu, container: 'ubuntu:18.04' }
- { target: mipsisa32r6el-unknown-linux-gnu, container: 'ubuntu:18.04' }
- { target: mipsisa64r6-unknown-linux-gnuabi64, container: 'ubuntu:18.04' }
- { target: mipsisa64r6el-unknown-linux-gnuabi64, container: 'ubuntu:18.04' }
# The latest Wine not available
- { target: x86_64-pc-windows-gnu, container: 'ubuntu:18.04' }
- { target: x86_64-pc-windows-gnu, container: 'debian:10-slim' }
- { target: x86_64-pc-windows-gnullvm, container: 'ubuntu:18.04' }
- { target: x86_64-pc-windows-gnullvm, container: 'debian:10-slim' }
# MinGW unimplemented WaitOnAddress
- { target: x86_64-pc-windows-gnu, container: 'ubuntu:20.04' }
# Linker error "unsupported ISA subset `z'" since nightly-2023-08-09 (LLVM 17)
- { target: riscv64gc-unknown-linux-gnu, container: 'ubuntu:20.04' }
# sparc64-linux-gnu-gcc: error: 20210110/32: No such file or directory
- { target: sparc-unknown-linux-gnu, container: 'debian:11-slim' }
runs-on: ubuntu-latest
timeout-minutes: 60
container:
image: ${{ matrix.container }}
options: --privileged
steps:
- name: Install requirements (ubuntu/debian)
run: |
set -eEuxo pipefail
apt-get -o Acquire::Retries=10 -qq update
apt-get -o Acquire::Retries=10 -qq -o Dpkg::Use-Pty=0 install -y --no-install-recommends ca-certificates curl
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain nightly
echo "$HOME/.cargo/bin" >>"${GITHUB_PATH}"
apt-get -qq -o Dpkg::Use-Pty=0 remove -y curl
if: startsWith(matrix.container, 'ubuntu') || startsWith(matrix.container, 'debian')
- uses: taiki-e/checkout-action@v1
- uses: ./
with:
target: ${{ matrix.target }}
- name: Install requirements for test (ubuntu/debian)
run: |
set -eEuxo pipefail
apt-get -o Acquire::Retries=10 -qq update
apt-get -o Acquire::Retries=10 -qq -o Dpkg::Use-Pty=0 install -y --no-install-recommends gcc libc6-dev jq make cmake
if: startsWith(matrix.container, 'ubuntu') || startsWith(matrix.container, 'debian')
- run: git clone --depth 1 https://github.com/taiki-e/rust-cross-toolchain.git
- run: tools/ci/test.sh ${{ matrix.target }} rust-cross-toolchain/docker/test/fixtures/rust
id: test
# TODO: we should replace ':' from matrix.container: "Error: The artifact name is not valid"
# # For debugging
# - uses: actions/upload-artifact@v4
# with:
# name: ${{ matrix.target }}-${{ matrix.container }}
# path: /tmp/artifacts/
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com

## [Unreleased]

- Support containers.

Note:
- Only Ubuntu and Debian containers are currently supported.
- Not fully supported for some targets.
- `--privileged` option is currently required (due to binfmt).

```yaml
container:
image: '...'
options: --privileged
```
- Improve robustness of installation.
## [1.20.0] - 2024-01-25
- Update the default Wine version to 9.0 from 8.0.
Expand Down
98 changes: 57 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ GitHub Action for setup toolchains for cross compilation and cross testing for R
- [Windows (LLVM MinGW)](#windows-llvm-mingw)
- [Windows (MSVC)](#windows-msvc)
- [macOS](#macos)
- [Compatibility](#compatibility)
- [Related Projects](#related-projects)
- [License](#license)

Expand Down Expand Up @@ -187,43 +188,42 @@ jobs:
| target | host | runner | note |
| ------ | ---- | ------ | ---- |
| `aarch64-unknown-linux-gnu` | Ubuntu (20.04 [1], 18.04 [2], 22.04 [3]) | qemu-user | |
| `aarch64_be-unknown-linux-gnu` | Ubuntu (<!-- 20.04, -->18.04, 22.04) [4] | qemu-user | tier3 |
| `arm-unknown-linux-gnueabi` | Ubuntu (20.04 [1], 18.04 [2], 22.04 [3]) | qemu-user | |
| `armeb-unknown-linux-gnueabi` | Ubuntu (<!-- 20.04, -->18.04, 22.04) [6] | qemu-user | tier3 |
| `armv5te-unknown-linux-gnueabi` | Ubuntu (20.04 [1], 18.04 [2], 22.04 [3]) | qemu-user | |
| `armv7-unknown-linux-gnueabi` | Ubuntu (20.04 [1], 18.04 [2], 22.04 [3]) | qemu-user | |
| `armv7-unknown-linux-gnueabihf` | Ubuntu (20.04 [1], 18.04 [2], 22.04 [3]) | qemu-user | |
| `i586-unknown-linux-gnu` | Ubuntu (20.04 [1], 18.04 [2], 22.04 [3]) | qemu-user (default), native | |
| `i686-unknown-linux-gnu` | Ubuntu (20.04 [1], 18.04 [2], 22.04 [3]) | native (default), qemu-user | |
| `loongarch64-unknown-linux-gnu` | Ubuntu (20.04, 22.04) [7] | qemu-user | experimental |
| `mips-unknown-linux-gnu` | Ubuntu (<!-- 20.04 [1], -->18.04 [2], 22.04 [3]) | qemu-user | tier3 [8] |
| `mips64-unknown-linux-gnuabi64` | Ubuntu (<!-- 20.04 [1], -->18.04 [2], 22.04 [3]) | qemu-user | tier3 |
| `mips64el-unknown-linux-gnuabi64` | Ubuntu (20.04 [1], 18.04 [2], 22.04 [3]) | qemu-user | tier3 |
| `mipsel-unknown-linux-gnu` | Ubuntu (20.04 [1], 18.04 [2], 22.04 [3]) | qemu-user | tier3 [8] |
| `mipsisa32r6-unknown-linux-gnu` | Ubuntu (<!-- 20.04 [1], -->22.04 [3]) | qemu-user | tier3 |
| `mipsisa32r6el-unknown-linux-gnu` | Ubuntu (20.04 [1], 22.04 [3]) | qemu-user | tier3 |
| `mipsisa64r6-unknown-linux-gnuabi64` | Ubuntu (<!-- 20.04 [1], -->22.04 [3]) | qemu-user | tier3 |
| `mipsisa64r6el-unknown-linux-gnuabi64` | Ubuntu (20.04 [1], 22.04 [3]) | qemu-user | tier3 |
| `powerpc-unknown-linux-gnu` | Ubuntu (20.04 [1], 18.04 [2], 22.04 [3]) | qemu-user | |
| `powerpc64-unknown-linux-gnu` | Ubuntu (<!-- 20.04 [1], -->18.04 [2], 22.04 [3]) | qemu-user | |
| `powerpc64le-unknown-linux-gnu` | Ubuntu (20.04 [1], 18.04 [2], 22.04 [3]) | qemu-user | |
| `riscv32gc-unknown-linux-gnu` | Ubuntu (20.04, 18.04, 22.04) [5] | qemu-user | |
| `riscv64gc-unknown-linux-gnu` | ubuntu (<!-- 20.04 [1], 18.04 [2], -->22.04 [3]) | qemu-user | |
| `s390x-unknown-linux-gnu` | Ubuntu (20.04 [1], 18.04 [2], 22.04 [3]) | qemu-user | |
| `sparc-unknown-linux-gnu` | Ubuntu (<!-- 20.04 [1], -->18.04 [2], 22.04 [3]) | qemu-user | tier3, experimental |
| `sparc64-unknown-linux-gnu` | Ubuntu (<!-- 20.04 [1], -->18.04 [2], 22.04 [3]) | qemu-user | |
| `thumbv7neon-unknown-linux-gnueabihf` | Ubuntu (20.04 [1], 18.04 [2], 22.04 [3]) | qemu-user | |
| `x86_64-unknown-linux-gnu` | Ubuntu (20.04 [1], 18.04 [2], 22.04 [3]) | native (default), qemu-user | |

[1] [GCC 9](https://packages.ubuntu.com/en/focal/gcc), [glibc 2.31](https://packages.ubuntu.com/en/focal/libc6-dev)<br>
[2] [GCC 7](https://packages.ubuntu.com/en/bionic/gcc), [glibc 2.27](https://packages.ubuntu.com/en/bionic/libc6-dev)<br>
[3] [GCC 11](https://packages.ubuntu.com/en/jammy/gcc), [glibc 2.35](https://packages.ubuntu.com/en/jammy/libc6-dev)<br>
[4] GCC 10, glibc 2.31<br>
| `aarch64-unknown-linux-gnu` | Ubuntu (18.04, 20.04, 22.04), Debian (10, 11, 12) [1] | qemu-user | |
| `aarch64_be-unknown-linux-gnu` | Ubuntu (18.04, 22.04), Debian (10, 11, 12) [2] | qemu-user | tier3 |
| `arm-unknown-linux-gnueabi` | Ubuntu (18.04, 20.04, 22.04), Debian (10, 11, 12) [1] | qemu-user | |
| `armeb-unknown-linux-gnueabi` | Ubuntu (18.04, 22.04), Debian (10, 11, 12) [3] | qemu-user | tier3 |
| `armv5te-unknown-linux-gnueabi` | Ubuntu (18.04, 20.04, 22.04), Debian (10, 11, 12) [1] | qemu-user | |
| `armv7-unknown-linux-gnueabi` | Ubuntu (18.04, 20.04, 22.04), Debian (10, 11, 12) [1] | qemu-user | |
| `armv7-unknown-linux-gnueabihf` | Ubuntu (18.04, 20.04, 22.04), Debian (10, 11, 12) [1] | qemu-user | |
| `i586-unknown-linux-gnu` | Ubuntu (18.04, 20.04, 22.04) [1] | qemu-user (default), native | [7] |
| `i686-unknown-linux-gnu` | Ubuntu (18.04, 20.04, 22.04) [1] | native (default), qemu-user | [7] |
| `loongarch64-unknown-linux-gnu` | Ubuntu (18.04, 20.04, 22.04), Debian (10, 11, 12) [4] | qemu-user | experimental |
| `mips-unknown-linux-gnu` | Ubuntu (18.04, 22.04), Debian (10, 11, 12) [1] | qemu-user | tier3 [6] |
| `mips64-unknown-linux-gnuabi64` | Ubuntu (18.04, 22.04), Debian (10, 11, 12) [1] | qemu-user | tier3 |
| `mips64el-unknown-linux-gnuabi64` | Ubuntu (18.04, 20.04, 22.04), Debian (10, 11, 12) [1] | qemu-user | tier3 |
| `mipsel-unknown-linux-gnu` | Ubuntu (18.04, 20.04, 22.04), Debian (10, 11, 12) [1] | qemu-user | tier3 [6] |
| `mipsisa32r6-unknown-linux-gnu` | Ubuntu (22.04), Debian (10, 11, 12) [1] | qemu-user | tier3 |
| `mipsisa32r6el-unknown-linux-gnu` | Ubuntu (20.04, 22.04), Debian (10, 11, 12) [1] | qemu-user | tier3 |
| `mipsisa64r6-unknown-linux-gnuabi64` | Ubuntu (22.04), Debian (10, 11, 12) [1] | qemu-user | tier3 |
| `mipsisa64r6el-unknown-linux-gnuabi64` | Ubuntu (20.04, 22.04), Debian (10, 11, 12) [1] | qemu-user | tier3 |
| `powerpc-unknown-linux-gnu` | Ubuntu (18.04, 20.04, 22.04), Debian (10, 11, 12) [1] | qemu-user | |
| `powerpc64-unknown-linux-gnu` | Ubuntu (18.04, 22.04), Debian (10, 11, 12) [1] | qemu-user | |
| `powerpc64le-unknown-linux-gnu` | Ubuntu (18.04, 20.04, 22.04), Debian (10, 11, 12) [1] | qemu-user | |
| `riscv32gc-unknown-linux-gnu` | Ubuntu (18.04, 20.04, 22.04), Debian (10, 11, 12) [5] | qemu-user | |
| `riscv64gc-unknown-linux-gnu` | ubuntu (18.04, 22.04), Debian (10, 11, 12) [1] | qemu-user | |
| `s390x-unknown-linux-gnu` | Ubuntu (18.04, 20.04, 22.04), Debian (10, 11, 12) [1] | qemu-user | |
| `sparc-unknown-linux-gnu` | Ubuntu (18.04, 22.04), Debian (10, 12) [1] | qemu-user | tier3, experimental |
| `sparc64-unknown-linux-gnu` | Ubuntu (18.04, 22.04), Debian (10, 11, 12) [1] | qemu-user | |
| `thumbv7neon-unknown-linux-gnueabihf` | Ubuntu (18.04, 20.04, 22.04), Debian (10, 11, 12) [1] | qemu-user | |
| `x86_64-unknown-linux-gnu` | Ubuntu (18.04, 20.04, 22.04), Debian (10, 11, 12) [1] | native (default), qemu-user | |

[1] [GCC 7](https://packages.ubuntu.com/en/bionic/gcc), [glibc 2.27](https://packages.ubuntu.com/en/bionic/libc6-dev) for Ubuntu 18.04. [GCC 9](https://packages.ubuntu.com/en/focal/gcc), [glibc 2.31](https://packages.ubuntu.com/en/focal/libc6-dev) for Ubuntu 20.04. [GCC 11](https://packages.ubuntu.com/en/jammy/gcc), [glibc 2.35](https://packages.ubuntu.com/en/jammy/libc6-dev) for Ubuntu 22.04. [GCC 8](https://packages.debian.org/en/buster/gcc), [glibc 2.28](https://packages.debian.org/en/buster/libc6-dev) for Debian 10. [GCC 10](https://packages.debian.org/en/bullseye/gcc), [glibc 2.31](https://packages.debian.org/en/bullseye/libc6-dev) for Debian 11. [GCC 12](https://packages.debian.org/en/bookworm/gcc), [glibc 2.36](https://packages.debian.org/en/bookworm/libc6-dev) for Debian 12.<br>
[2] GCC 10, glibc 2.31<br>
[3] GCC 7, glibc 2.25<br>
[4] GCC 13, glibc 2.36<br>
[5] GCC 11, glibc 2.33<br>
[6] GCC 7, glibc 2.25<br>
[7] GCC 13, glibc 2.36<br>
[8] [Since nightly-2023-07-05](https://github.com/rust-lang/compiler-team/issues/648), mips{,el}-unknown-linux-gnu requires release mode for building std<br>
[6] [Since nightly-2023-07-05](https://github.com/rust-lang/compiler-team/issues/648), mips{,el}-unknown-linux-gnu requires release mode for building std<br>
[7] Not fully supported with containers<br>

<!-- omit in toc -->
#### <a name="qemu-user-runner"></a>qemu-user runner
Expand Down Expand Up @@ -333,9 +333,9 @@ For the `qemu-user` runner, see ["qemu-user runner" section for linux-gnu target

| target | version | host | note |
| ------ | ------- | ---- | ---- |
| `aarch64-unknown-freebsd` | 12.4 (default), 13.2, 14.0 | Linux [1] | tier3 |
| `i686-unknown-freebsd` | 12.4 (default), 13.2, 14.0 | Linux [1] | |
| `x86_64-unknown-freebsd` | 12.4 (default), 13.2, 14.0 | Linux [1] | |
| `aarch64-unknown-freebsd` | 12.4 (default), 13.2, 14.0 | Ubuntu, Debian [1] | tier3 |
| `i686-unknown-freebsd` | 12.4 (default), 13.2, 14.0 | Ubuntu, Debian [1] | |
| `x86_64-unknown-freebsd` | 12.4 (default), 13.2, 14.0 | Ubuntu, Debian [1] | |

[1] Clang 13 for Ubuntu 18.04, otherwise Clang 15<br>

Expand Down Expand Up @@ -398,9 +398,9 @@ Only specifying a major version is supported.

| target | host | runner | note |
| ------ | ---- | ------ | ---- |
| `x86_64-pc-windows-gnu` | *Windows*, Ubuntu (22.04 [1]) | native (Windows host) / wine (Linux host) | |
| `x86_64-pc-windows-gnu` | *Windows*, Ubuntu (22.04), Debian (11, 12) [1] | native (Windows host) / wine (Linux host) | |

[1] [GCC 10](https://packages.ubuntu.com/en/jammy/gcc-mingw-w64-base), [MinGW-w64 8](https://packages.ubuntu.com/en/jammy/mingw-w64-x86-64-dev)<br>
[1] [GCC 10](https://packages.ubuntu.com/en/jammy/gcc-mingw-w64-base), [MinGW-w64 8](https://packages.ubuntu.com/en/jammy/mingw-w64-x86-64-dev) for Ubuntu 22.04. [GCC 10](https://packages.debian.org/en/bullseye/gcc-mingw-w64-base), [MinGW-w64 8](https://packages.debian.org/en/bullseye/mingw-w64-x86-64-dev) for Debian 11. [GCC 12](https://packages.debian.org/en/bookworm/gcc-mingw-w64-base), [MinGW-w64 10](https://packages.debian.org/en/bookworm/mingw-w64-x86-64-dev) for Debian 12.<br>

On Windows host, GitHub-provided Windows runners support cross-compile for other architectures or environments, so this action just runs `rustup target add` and/or sets some environment variables.

Expand Down Expand Up @@ -488,6 +488,22 @@ GitHub-provided macOS runners support cross-compile for other architectures or e

(Other macOS targets may also work, although this action's CI has not tested them.)

## Compatibility

This action has been tested for GitHub-hosted runners (Ubuntu, macOS, Windows) and containers (Ubuntu, Debian).
To use this action in self-hosted runners or in containers, at least the following tools are required:

- bash
- rustup, cargo

`--privileged` option is currently required when using with containers (due to binfmt).

```yaml
container:
image: '...'
options: --privileged
```

## Related Projects

- [rust-cross-toolchain]: Toolchains for cross compilation and cross testing for Rust.
Expand Down
Loading

0 comments on commit 379cd17

Please sign in to comment.