diff --git a/.github/dependabot.yml b/.github/dependabot.yaml similarity index 100% rename from .github/dependabot.yml rename to .github/dependabot.yaml diff --git a/.github/workflows/full_ci.yml b/.github/workflows/ci.yaml similarity index 51% rename from .github/workflows/full_ci.yml rename to .github/workflows/ci.yaml index 3d60b36c61a55..8fbbed08a1eca 100644 --- a/.github/workflows/full_ci.yml +++ b/.github/workflows/ci.yaml @@ -1,4 +1,4 @@ -name: full CI +name: CI on: merge_group: @@ -9,153 +9,94 @@ env: CARGO_TERM_VERBOSE: true LIBC_CI: 1 +defaults: + run: + shell: bash + jobs: style_check: name: Style check - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain - run: sh ./ci/install-rust.sh + run: ./ci/install-rust.sh - name: Check style - run: sh ci/style.sh + run: ./ci/style.sh - build_channels_linux: - name: Build Channels Linux - runs-on: ubuntu-22.04 - env: - OS: linux + # This runs `cargo build --target ...` for all T1 and T2 targets` + verify_build: + name: Verify build strategy: - fail-fast: true - max-parallel: 5 matrix: - toolchain: - - stable - - beta - - nightly - - 1.63.0 - steps: - - uses: actions/checkout@v4 - - name: Setup Rust toolchain - run: TOOLCHAIN=${{ matrix.toolchain }} sh ./ci/install-rust.sh - - name: Execute build.sh - run: TOOLCHAIN=${{ matrix.toolchain }} sh ./ci/build.sh - - build_channels_macos: - name: Build Channels macOS - needs: macos + toolchain: [stable, nightly, 1.63.0] + os: [ubuntu-24.04, macos-14, windows-2022] + include: + - toolchain: beta + os: ubuntu-24.04 + runs-on: ${{ matrix.os }} env: - OS: macos - strategy: - fail-fast: true - max-parallel: 4 - matrix: - target: - - { toolchain: stable, os: macos-14 } - - { toolchain: beta, os: macos-14 } - - { toolchain: nightly, os: macos-14 } - - { toolchain: 1.63.0, os: macos-14 } - runs-on: ${{ matrix.target.os }} + TOOLCHAIN: ${{ matrix.toolchain }} steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain - run: TOOLCHAIN=${{ matrix.target.toolchain }} sh ./ci/install-rust.sh + run: ./ci/install-rust.sh - name: Execute build.sh - run: TOOLCHAIN=${{ matrix.target.toolchain }} sh ./ci/build.sh + run: ./ci/verify-build.sh - build_channels_windows: - name: Build Channels Windows - runs-on: windows-2022 - env: - OS: windows - strategy: - fail-fast: true - matrix: - toolchain: - - 1.63.0 - - stable - steps: - - uses: actions/checkout@v4 - - name: Self-update rustup - run: rustup self update - shell: bash - - name: Execute build.sh - run: TOOLCHAIN=${{ matrix.toolchain }} sh ./ci/build.sh - shell: bash - - macos: - name: macOS - runs-on: macos-14 + test_tier1: + name: Test tier1 strategy: - fail-fast: true - matrix: - target: - - aarch64-apple-darwin - steps: - - uses: actions/checkout@v4 - - name: Setup Rust toolchain - run: TARGET=${{ matrix.target }} sh ./ci/install-rust.sh - - name: Execute run.sh - run: sh ./ci/run.sh ${{ matrix.target }} - - windows: - name: Windows - runs-on: windows-2022 - env: - OS: windows - strategy: - fail-fast: true matrix: include: + - target: i686-unknown-linux-gnu + docker: true + os: ubuntu-24.04 + - target: x86_64-unknown-linux-gnu + docker: true + os: ubuntu-24.04 + - target: aarch64-apple-darwin + os: macos-14 - target: x86_64-pc-windows-gnu + os: windows-2022 env: ARCH_BITS: 64 ARCH: x86_64 - target: x86_64-pc-windows-msvc + os: windows-2022 # FIXME: It currently causes segfaults. #- target: i686-pc-windows-gnu # env: # ARCH_BITS: 32 # ARCH: i686 - target: i686-pc-windows-msvc - steps: - - uses: actions/checkout@v4 - - name: Self-update rustup - run: rustup self update - shell: bash - - name: Setup Rust toolchain - run: TARGET=${{ matrix.target }} sh ./ci/install-rust.sh - shell: bash - - name: Execute run.sh - run: sh ./ci/run.sh ${{ matrix.target }} - shell: bash - - - docker_linux_tier1: - name: Docker Linux Tier1 - runs-on: ubuntu-22.04 - strategy: - fail-fast: true - matrix: - target: - - i686-unknown-linux-gnu - - x86_64-unknown-linux-gnu + os: windows-2022 + runs-on: ${{ matrix.os }} + env: + TARGET: ${{ matrix.target }} steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain - run: TARGET=${{ matrix.target }} sh ./ci/install-rust.sh - - name: Execute run-docker.sh - run: sh ./ci/run-docker.sh ${{ matrix.target }} + run: ./ci/install-rust.sh + - name: Run natively + if: "!matrix.docker" + run: ./ci/run.sh ${{ matrix.target }} + - name: Run in Docker + if: "matrix.docker" + run: ./ci/run-docker.sh ${{ matrix.target }} - docker_linux_tier2: - name: Docker Linux Tier2 - needs: [docker_linux_tier1, style_check] - runs-on: ubuntu-22.04 + test_tier2: + name: Test tier2 + needs: [test_tier1, style_check] + runs-on: ubuntu-24.04 strategy: fail-fast: true max-parallel: 12 matrix: target: + # FIXME(sparc): this takes much longer to run than any other job, put + # it first to make sure it gets a head start. + - sparc64-unknown-linux-gnu - aarch64-linux-android - aarch64-unknown-linux-gnu - aarch64-unknown-linux-musl @@ -169,12 +110,11 @@ jobs: - powerpc-unknown-linux-gnu - powerpc64-unknown-linux-gnu - powerpc64le-unknown-linux-gnu - - s390x-unknown-linux-gnu - riscv64gc-unknown-linux-gnu + - s390x-unknown-linux-gnu + - wasm32-unknown-emscripten - wasm32-wasip1 - wasm32-wasip2 - - sparc64-unknown-linux-gnu - - wasm32-unknown-emscripten - x86_64-linux-android # FIXME: Exec format error (os error 8) # - x86_64-unknown-linux-gnux32 @@ -182,15 +122,18 @@ jobs: # FIXME: It seems some items in `src/unix/mod.rs` # aren't defined on redox actually. # - x86_64-unknown-redox + env: + TARGET: ${{ matrix.target }} steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain - run: TARGET=${{ matrix.target }} sh ./ci/install-rust.sh + run: ./ci/install-rust.sh - name: Execute run-docker.sh - run: sh ./ci/run-docker.sh ${{ matrix.target }} + run: ./ci/run-docker.sh ${{ matrix.target }} - solaris: - name: Solaris + test_tier2_vm: + name: Test tier2 VM + needs: [test_tier1, style_check] runs-on: ubuntu-latest strategy: fail-fast: true @@ -207,22 +150,23 @@ jobs: mem: 4096 copyback: false prepare: | + set -x source <(curl -s https://raw.githubusercontent.com/psumbera/solaris-rust/refs/heads/main/sh.rust-web-install) - echo "~~~~ rustc --version ~~~~" rustc --version - echo "~~~~ Solaris-version ~~~~" uname -a run: | export PATH=$HOME/.rust_solaris/bin:$PATH - bash ./ci/run.sh ${{ matrix.target }} + ./ci/run.sh ${{ matrix.target }} check_cfg: name: "Check #[cfg]s" - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 + env: + TOOLCHAIN: nightly steps: - uses: actions/checkout@v4 - name: Setup Rust toolchain - run: TOOLCHAIN=nightly sh ./ci/install-rust.sh + run: ./ci/install-rust.sh - name: Build with check-cfg run: LIBC_CHECK_CFG=1 cargo build -Z unstable-options -Z check-cfg @@ -230,17 +174,13 @@ jobs: # protection, rather than having to add each job separately. success: name: success - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 needs: - - docker_linux_tier1 - - docker_linux_tier2 - - macos - - windows - - solaris - style_check - - build_channels_linux - - build_channels_macos - - build_channels_windows + - test_tier1 + - test_tier2 + - test_tier2_vm + - verify_build # Github branch protection is exceedingly silly and treats "jobs skipped because a dependency # failed" as success. So we have to do some contortions to ensure the job fails if any of its # dependencies fails. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2090a0aaa689e..74f49f3e7bb04 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -93,7 +93,7 @@ We have two automated tests running on - `cd libc-test && cargo test` - Use the `skip_*()` functions in `build.rs` if you really need a workaround. 2. Style checker - - [`sh ci/style.sh`](https://github.com/rust-lang/libc/blob/main/ci/style.sh) + - [`./ci/style.sh`](https://github.com/rust-lang/libc/blob/main/ci/style.sh) ## Breaking change policy diff --git a/ci/android-install-ndk.sh b/ci/android-install-ndk.sh old mode 100644 new mode 100755 diff --git a/ci/android-install-sdk.sh b/ci/android-install-sdk.sh old mode 100644 new mode 100755 diff --git a/ci/android-sysimage.sh b/ci/android-sysimage.sh old mode 100644 new mode 100755 diff --git a/ci/docker/aarch64-linux-android/Dockerfile b/ci/docker/aarch64-linux-android/Dockerfile index d6927e5cc80ec..dfd63718a9d0d 100644 --- a/ci/docker/aarch64-linux-android/Dockerfile +++ b/ci/docker/aarch64-linux-android/Dockerfile @@ -20,8 +20,8 @@ COPY android* /android/ ENV ANDROID_ARCH=aarch64 ENV PATH=$PATH:/android/linux-x86_64/bin:/android/sdk/cmdline-tools/tools:/android/sdk/platform-tools -RUN sh /android/android-install-ndk.sh -RUN sh /android/android-install-sdk.sh $ANDROID_ARCH +RUN /android/android-install-ndk.sh +RUN /android/android-install-sdk.sh $ANDROID_ARCH RUN mv /root/.android /tmp RUN chmod 777 -R /tmp/.android RUN chmod 755 /android/sdk/cmdline-tools/tools/* /android/sdk/emulator/qemu/linux-x86_64/* diff --git a/ci/docker/aarch64-unknown-linux-musl/Dockerfile b/ci/docker/aarch64-unknown-linux-musl/Dockerfile index fd4c1e28f2525..65932bd48cfac 100644 --- a/ci/docker/aarch64-unknown-linux-musl/Dockerfile +++ b/ci/docker/aarch64-unknown-linux-musl/Dockerfile @@ -5,7 +5,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gcc-aarch64-linux-gnu qemu-user COPY install-musl.sh / -RUN sh /install-musl.sh aarch64 +RUN /install-musl.sh aarch64 # FIXME: shouldn't need the `-lgcc` here, shouldn't that be in std? ENV PATH=$PATH:/musl-aarch64/bin:/rust/bin \ diff --git a/ci/docker/arm-linux-androideabi/Dockerfile b/ci/docker/arm-linux-androideabi/Dockerfile index 9d6a5c9649832..82f89f48e915c 100644 --- a/ci/docker/arm-linux-androideabi/Dockerfile +++ b/ci/docker/arm-linux-androideabi/Dockerfile @@ -20,8 +20,8 @@ COPY android* /android/ ENV ANDROID_ARCH=arm ENV PATH=$PATH:/android/linux-x86_64/bin:/android/sdk/cmdline-tools/tools:/android/sdk/platform-tools -RUN sh /android/android-install-ndk.sh -RUN sh /android/android-install-sdk.sh $ANDROID_ARCH +RUN /android/android-install-ndk.sh +RUN /android/android-install-sdk.sh $ANDROID_ARCH RUN mv /root/.android /tmp RUN chmod 777 -R /tmp/.android RUN chmod 755 /android/sdk/cmdline-tools/tools/* /android/sdk/emulator/qemu/linux-x86_64/* diff --git a/ci/docker/arm-unknown-linux-musleabihf/Dockerfile b/ci/docker/arm-unknown-linux-musleabihf/Dockerfile index f8a5d27df3b5f..7ed23611c351e 100644 --- a/ci/docker/arm-unknown-linux-musleabihf/Dockerfile +++ b/ci/docker/arm-unknown-linux-musleabihf/Dockerfile @@ -8,7 +8,7 @@ RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ gcc-arm-linux-gnueabihf qemu-user COPY install-musl.sh / -RUN sh /install-musl.sh arm +RUN /install-musl.sh arm ENV PATH=$PATH:/musl-arm/bin:/rust/bin \ CC_arm_unknown_linux_musleabihf=musl-gcc \ diff --git a/ci/docker/asmjs-unknown-emscripten/Dockerfile b/ci/docker/asmjs-unknown-emscripten/Dockerfile index 6f2d5ddfc78e1..085e45ff35ee6 100644 --- a/ci/docker/asmjs-unknown-emscripten/Dockerfile +++ b/ci/docker/asmjs-unknown-emscripten/Dockerfile @@ -18,7 +18,7 @@ RUN apt-get install -y --no-install-recommends \ bzip2 COPY emscripten.sh / -RUN bash /emscripten.sh +RUN /emscripten.sh ENV PATH=$PATH:/rust/bin \ CARGO_TARGET_ASMJS_UNKNOWN_EMSCRIPTEN_RUNNER=node diff --git a/ci/docker/i686-linux-android/Dockerfile b/ci/docker/i686-linux-android/Dockerfile index 0fb48aca342d4..8a159cd0502b5 100644 --- a/ci/docker/i686-linux-android/Dockerfile +++ b/ci/docker/i686-linux-android/Dockerfile @@ -20,8 +20,8 @@ COPY android* /android/ ENV ANDROID_ARCH=i686 ENV PATH=$PATH:/android/linux-x86_64/bin:/android/sdk/cmdline-tools/tools:/android/sdk/platform-tools -RUN sh /android/android-install-ndk.sh -RUN sh /android/android-install-sdk.sh $ANDROID_ARCH +RUN /android/android-install-ndk.sh +RUN /android/android-install-sdk.sh $ANDROID_ARCH RUN mv /root/.android /tmp RUN chmod 777 -R /tmp/.android RUN chmod 755 /android/sdk/cmdline-tools/tools/* /android/sdk/emulator/qemu/linux-x86_64/* diff --git a/ci/docker/i686-unknown-linux-musl/Dockerfile b/ci/docker/i686-unknown-linux-musl/Dockerfile index 4f36d2075485c..ea5e2e963910b 100644 --- a/ci/docker/i686-unknown-linux-musl/Dockerfile +++ b/ci/docker/i686-unknown-linux-musl/Dockerfile @@ -9,7 +9,7 @@ RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ gcc-multilib make libc6-dev git curl ca-certificates libc6-i386 COPY install-musl.sh / -RUN sh /install-musl.sh i686 +RUN /install-musl.sh i686 ENV PATH=$PATH:/musl-i686/bin:/rust/bin \ CC_i686_unknown_linux_musl=musl-gcc \ diff --git a/ci/docker/loongarch64-unknown-linux-musl/Dockerfile b/ci/docker/loongarch64-unknown-linux-musl/Dockerfile index 2efd095b0fddd..f4a23a6666c8a 100644 --- a/ci/docker/loongarch64-unknown-linux-musl/Dockerfile +++ b/ci/docker/loongarch64-unknown-linux-musl/Dockerfile @@ -4,7 +4,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates curl gcc git libc6-dev make qemu-user xz-utils COPY install-musl-cross.sh / -RUN sh /install-musl-cross.sh loongarch64-unknown-linux-musl +RUN /install-musl-cross.sh loongarch64-unknown-linux-musl ENV CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_MUSL_LINKER=loongarch64-unknown-linux-musl-gcc \ CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_MUSL_RUNNER="qemu-loongarch64" \ diff --git a/ci/docker/s390x-unknown-linux-gnu/Dockerfile b/ci/docker/s390x-unknown-linux-gnu/Dockerfile index 306d773a61165..dde2ef24254fc 100644 --- a/ci/docker/s390x-unknown-linux-gnu/Dockerfile +++ b/ci/docker/s390x-unknown-linux-gnu/Dockerfile @@ -8,7 +8,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ cpio COPY linux-s390x.sh / -RUN bash /linux-s390x.sh +RUN /linux-s390x.sh COPY test-runner-linux / diff --git a/ci/docker/s390x-unknown-linux-musl/Dockerfile b/ci/docker/s390x-unknown-linux-musl/Dockerfile index d103a1d7488e0..4e202d1905902 100644 --- a/ci/docker/s390x-unknown-linux-musl/Dockerfile +++ b/ci/docker/s390x-unknown-linux-musl/Dockerfile @@ -7,7 +7,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ qemu-user COPY install-musl.sh / -RUN sh /install-musl.sh s390x +RUN /install-musl.sh s390x # FIXME: shouldn't need the `-lgcc` here, shouldn't that be in std? ENV CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc \ diff --git a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile index 4aff82ee46631..16b930f95a834 100644 --- a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile @@ -15,7 +15,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ p7zip-full cpio linux-libc-dev-sparc64-cross COPY linux-sparc64.sh / -RUN bash /linux-sparc64.sh +RUN /linux-sparc64.sh COPY test-runner-linux / diff --git a/ci/docker/wasm32-unknown-emscripten/Dockerfile b/ci/docker/wasm32-unknown-emscripten/Dockerfile index 5af38ca5258db..0f9cb85dc30e8 100644 --- a/ci/docker/wasm32-unknown-emscripten/Dockerfile +++ b/ci/docker/wasm32-unknown-emscripten/Dockerfile @@ -26,7 +26,7 @@ RUN apt-get install -y --no-install-recommends \ RUN ln -s /usr/bin/python3 /usr/bin/python & \ ln -s /usr/bin/pip3 /usr/bin/pip COPY emscripten.sh / -RUN bash /emscripten.sh +RUN /emscripten.sh ENV PATH=$PATH:/rust/bin \ CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_RUNNER=node-wrapper.sh diff --git a/ci/docker/wasm32-wasip1/Dockerfile b/ci/docker/wasm32-wasip1/Dockerfile index 68940f4615a7e..e85b27ff82099 100644 --- a/ci/docker/wasm32-wasip1/Dockerfile +++ b/ci/docker/wasm32-wasip1/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:24.10 COPY wasi.sh / -RUN bash /wasi.sh +RUN /wasi.sh # Note that `-D_WASI_EMULATED_PROCESS_CLOCKS` is used to enable access to # clock-related defines even though they're emulated. Also note that the usage diff --git a/ci/docker/wasm32-wasip2/Dockerfile b/ci/docker/wasm32-wasip2/Dockerfile index 7abaaf54da02d..be6bff3a843c5 100644 --- a/ci/docker/wasm32-wasip2/Dockerfile +++ b/ci/docker/wasm32-wasip2/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:24.10 COPY wasi.sh / -RUN bash /wasi.sh +RUN /wasi.sh # Note that most of these are copied from `wasm32-wasip1/Dockerfile` # diff --git a/ci/docker/x86_64-linux-android/Dockerfile b/ci/docker/x86_64-linux-android/Dockerfile index f6331f10f3897..3bf350820019f 100644 --- a/ci/docker/x86_64-linux-android/Dockerfile +++ b/ci/docker/x86_64-linux-android/Dockerfile @@ -12,12 +12,12 @@ RUN apt-get update && \ WORKDIR /android/ ENV ANDROID_ARCH=x86_64 COPY android-install-ndk.sh /android/ -RUN sh /android/android-install-ndk.sh +RUN /android/android-install-ndk.sh # We do not run x86_64-linux-android tests on an android emulator. # See ci/android-sysimage.sh for information about how tests are run. COPY android-sysimage.sh /android/ -RUN bash /android/android-sysimage.sh x86_64 x86_64-24_r07.zip +RUN /android/android-sysimage.sh x86_64 x86_64-24_r07.zip ENV PATH=$PATH:/rust/bin:/android/linux-x86_64/bin \ CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=x86_64-linux-android28-clang \ diff --git a/ci/docker/x86_64-unknown-linux-musl/Dockerfile b/ci/docker/x86_64-unknown-linux-musl/Dockerfile index 11fbd6e1be46a..d03df5b4f54ce 100644 --- a/ci/docker/x86_64-unknown-linux-musl/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-musl/Dockerfile @@ -5,7 +5,7 @@ RUN apt-get install -y --no-install-recommends \ gcc make libc6-dev git curl ca-certificates COPY install-musl.sh / -RUN sh /install-musl.sh x86_64 +RUN /install-musl.sh x86_64 ENV PATH=$PATH:/musl-x86_64/bin:/rust/bin \ RUSTFLAGS="-L /musl-x86_64/lib" diff --git a/ci/emscripten.sh b/ci/emscripten.sh old mode 100644 new mode 100755 diff --git a/ci/install-musl-cross.sh b/ci/install-musl-cross.sh old mode 100644 new mode 100755 diff --git a/ci/install-musl.sh b/ci/install-musl.sh old mode 100644 new mode 100755 diff --git a/ci/install-rust.sh b/ci/install-rust.sh old mode 100644 new mode 100755 index becb532d1469d..16fd0b4e8a577 --- a/ci/install-rust.sh +++ b/ci/install-rust.sh @@ -8,17 +8,25 @@ echo "Setup toolchain" toolchain="${TOOLCHAIN:-nightly}" os="${OS:-}" -if [ "$os" = "windows" ]; then - : "${TARGET?The TARGET environment variable must be set.}" - rustup set profile minimal - rustup update --force "$toolchain-$TARGET" - rustup default "$toolchain-$TARGET" -else +case "$(uname -s)" in + Linux*) os=linux ;; + Darwin*) os=macos ;; + MINGW*) os=windows ;; + *) + echo "Unknown system $(uname -s)" + exit 1 + ;; +esac + +if [ "$os" = "windows" ] && [ -n "${TARGET:-}" ]; then + toolchain="$toolchain-$TARGET" rustup set profile minimal - rustup update --force "$toolchain" - rustup default "$toolchain" fi +rustup set profile minimal +rustup update --force "$toolchain" +rustup default "$toolchain" + if [ -n "${TARGET:-}" ]; then echo "Install target" rustup target add "$TARGET" @@ -50,9 +58,6 @@ if [ "$os" = "windows" ]; then fi echo "Query rust and cargo versions" -command -v rustc -command -v cargo -command -v rustup rustc -Vv cargo -V rustup -Vv diff --git a/ci/linux-s390x.sh b/ci/linux-s390x.sh old mode 100644 new mode 100755 diff --git a/ci/linux-sparc64.sh b/ci/linux-sparc64.sh old mode 100644 new mode 100755 diff --git a/ci/run-docker.sh b/ci/run-docker.sh index 4cef3d45c504d..fcd9e1a9d2e03 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -8,6 +8,8 @@ set -eux +target="$1" + # Default to assuming the CARGO_HOME is one directory up (to account for a `bin` # subdir) from where the `cargo` binary in `$PATH` lives. default_cargo_home="$(dirname "$(dirname "$(command -v cargo)")")" @@ -18,17 +20,17 @@ export CARGO_HOME="${CARGO_HOME:-$default_cargo_home}" echo "${HOME}" pwd -# Avoid "no space left on device" failure. -if [ "${1}" = "aarch64-linux-android" ] ; then +# Avoid "no space left on device" failure if running in CI +if [ "${CI:-0}" != "0" ] && [ "$target" = "aarch64-linux-android" ] ; then docker system prune -af docker system df fi run() { - echo "Building docker container for target ${1}" + echo "Building docker container for target $target" # use -f so we can use ci/ as build context - docker build -t "libc-${1}" -f "ci/docker/${1}/Dockerfile" ci/ + docker build -t "libc-$target" -f "ci/docker/$target/Dockerfile" ci/ mkdir -p target if [ -w /dev/kvm ]; then kvm="--volume /dev/kvm:/dev/kvm" @@ -50,8 +52,8 @@ run() { $kvm \ --init \ --workdir /checkout \ - "libc-${1}" \ - sh -c "HOME=/tmp PATH=\$PATH:/rust/bin exec ci/run.sh ${1}" + "libc-$target" \ + sh -c "HOME=/tmp PATH=\$PATH:/rust/bin exec ci/run.sh $target" } build_switch() { @@ -88,13 +90,13 @@ build_switch() { && cargo build -Z build-std=core,alloc --target ci/switch.json" } -if [ -z "${1}" ]; then +if [ -z "$target" ]; then for d in ci/docker/*; do run "${d}" done else - if [ "${1}" != "switch" ]; then - run "${1}" + if [ "$target" != "switch" ]; then + run "$target" else build_switch fi diff --git a/ci/run.sh b/ci/run.sh index f4fef82fcdc2d..22b356a6425b1 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -21,25 +21,21 @@ if [ -n "${QEMU:-}" ]; then if [ -z "${QEMU#*.gz}" ]; then # image is .gz : download and uncompress it - qemufile="$(echo "${QEMU%.gz}" | sed 's/\//__/g')" - if [ ! -f "${tmpdir}/${qemufile}" ]; then - curl --retry 5 "${mirrors_url}/${QEMU}" | - gunzip -d > "${tmpdir}/${qemufile}" - fi + base_file="${QEMU%.gz}" + pipe_cmd="gunzip -d" elif [ -z "${QEMU#*.xz}" ]; then # image is .xz : download and uncompress it - qemufile="$(echo "${QEMU%.xz}" | sed 's/\//__/g')" - if [ ! -f "${tmpdir}/${qemufile}" ]; then - curl --retry 5 "${mirrors_url}/${QEMU}" | - unxz > "${tmpdir}/${qemufile}" - fi + base_file="${QEMU%.xz}" + pipe_cmd="unxz" else # plain qcow2 image: just download it - qemufile="$(echo "${QEMU}" | sed 's/\//__/g')" - if [ ! -f "${tmpdir}/${qemufile}" ]; then - curl --retry 5 "${mirrors_url}/${QEMU}" \ - > "${tmpdir}/${qemufile}" - fi + base_file="$QEMU" + pipe_cmd="cat" # nop to forward the result + fi + + qemufile="$(echo "$base_file" | sed 's/\//__/g')" + if [ ! -f "${tmpdir}/${qemufile}" ]; then + curl --retry 5 "${mirrors_url}/${QEMU}" | $pipe_cmd > "${tmpdir}/${qemufile}" fi # Create a mount a fresh new filesystem image that we'll later pass to QEMU. diff --git a/ci/style.rs b/ci/style.rs index dbc8c633cffab..c4e0fb0db8058 100644 --- a/ci/style.rs +++ b/ci/style.rs @@ -100,7 +100,7 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) { // FIXME: see below // let mut s_macros = 0; - + let mut f_macros = 0; let mut in_impl = false; diff --git a/ci/style.sh b/ci/style.sh index 17a47d037360a..c758712012e16 100755 --- a/ci/style.sh +++ b/ci/style.sh @@ -75,7 +75,7 @@ fi export LC_ALL=C for file in libc-test/semver/*.txt; do - case "$file" in + case "$file" in *TODO*) continue ;; esac diff --git a/ci/build.sh b/ci/verify-build.sh old mode 100644 new mode 100755 similarity index 57% rename from ci/build.sh rename to ci/verify-build.sh index f9c81beb19672..b88e214fb34d1 --- a/ci/build.sh +++ b/ci/verify-build.sh @@ -8,24 +8,45 @@ set -eux : "${TOOLCHAIN?The TOOLCHAIN environment variable must be set.}" -: "${OS?The OS environment variable must be set.}" rust="$TOOLCHAIN" filter="${FILTER:-}" -echo "Testing Rust $rust on $OS" +case "$(uname -s)" in + Linux*) os=linux ;; + Darwin*) os=macos ;; + MINGW*) os=windows ;; + *) + echo "Unknown system $(uname -s)" + exit 1 + ;; +esac + +echo "Testing Rust $rust on $os" if [ "$TOOLCHAIN" = "nightly" ] ; then rustup component add rust-src fi test_target() { - build_cmd="${1}" - target="${2}" - no_std="${3:-}" + target="${1}" + no_dist="${2:-0}" + + RUSTFLAGS="${RUSTFLAGS:-}" + + # The basic command that is run each time + cmd="cargo +$rust build --target $target" + + if [ "${no_dist}" != "0" ]; then + # If we can't download a `core`, we need to build it + cmd="$cmd -Zbuild-std=core,alloc" + + # FIXME: With `build-std` feature, `compiler_builtins` emits a lof of lint warnings. + RUSTFLAGS="${RUSTFLAGS:-} -Aimproper_ctypes_definitions" + export RUSTFLAGS + else + # Otherwise it is available for download; fetch it: - # If there is a std component, fetch it: - if [ "${no_std}" != "1" ]; then # FIXME: rustup often fails to download some artifacts due to network # issues, so we retry this N times. N=5 @@ -39,73 +60,14 @@ test_target() { done fi - # Test that libc builds without any default features (no std) - if [ "$no_std" != "1" ]; then - cargo "+$rust" "$build_cmd" --no-default-features --target "$target" - else - # FIXME: With `build-std` feature, `compiler_builtins` emits a lof of lint warnings. - RUSTFLAGS="-A improper_ctypes_definitions" \ - cargo "+$rust" "$build_cmd" \ - -Z build-std=core,alloc \ - --no-default-features \ - --target "$target" - fi - - # Test that libc builds with default features (e.g. std) - # if the target supports std - if [ "$no_std" != "1" ]; then - cargo "+$rust" "$build_cmd" --target "$target" - else - RUSTFLAGS="-A improper_ctypes_definitions" \ - cargo "+$rust" "${build_cmd}" \ - -Z build-std=core,alloc \ - --target "$target" - fi - - # Test that libc builds with the `extra_traits` feature - if [ "$no_std" != "1" ]; then - cargo "+$rust" "$build_cmd" \ - --no-default-features \ - --features extra_traits \ - --target "$target" - else - RUSTFLAGS="-A improper_ctypes_definitions" \ - cargo "+$rust" "$build_cmd" \ - -Z build-std=core,alloc \ - --no-default-features \ - --features extra_traits \ - --target "$target" - fi - - # Test the 'const-extern-fn' feature on nightly - if [ "${rust}" = "nightly" ]; then - if [ "${no_std}" != "1" ]; then - cargo "+$rust" "$build_cmd" \ - --no-default-features \ - --features const-extern-fn \ - --target "$target" - else - RUSTFLAGS="-A improper_ctypes_definitions" \ - cargo "+$rust" "$build_cmd" \ - -Z build-std=core,alloc \ - --no-default-features \ - --features const-extern-fn \ - --target "$target" - fi - fi + # Test with expected combinations of features + $cmd + $cmd --features const-extern-fn + $cmd --features extra_traits - # Also test that it builds with `extra_traits` and default features: - if [ "$no_std" != "1" ]; then - cargo "+$rust" "$build_cmd" \ - --target "$target" \ - --features extra_traits - else - RUSTFLAGS="-A improper_ctypes_definitions" \ - cargo "+$rust" "$build_cmd" \ - -Z build-std=core,alloc \ - --target "$target" \ - --features extra_traits - fi + # Test again without default features, i.e. without "std" + $cmd --no-default-features + $cmd --no-default-features --features extra_traits } rust_linux_targets="\ @@ -171,48 +133,10 @@ x86_64-pc-windows-gnu \ i686-pc-windows-msvc \ " -# The targets are listed here alphabetically -targets="" -case "${OS}" in - linux*) - targets="$rust_linux_targets" - - if [ "$rust" = "nightly" ]; then - targets="$targets $rust_nightly_linux_targets" - fi - - ;; - macos*) - targets="$rust_apple_targets" - - if [ "$rust" = "nightly" ]; then - targets="$targets $rust_nightly_apple_targets" - fi - - ;; - windows*) - targets=${rust_nightly_windows_targets} - ;; - *) ;; -esac - -for target in $targets; do - if echo "$target" | grep -q "$filter"; then - if [ "${OS}" = "windows" ]; then - TARGET="$target" sh ./ci/install-rust.sh - test_target build "$target" - else - test_target build "$target" - fi - - test_run=1 - fi -done - # Targets which are not available via rustup and must be built with -Zbuild-std # FIXME(hexagon): hexagon-unknown-linux-musl should be tested but currently has # duplicate symbol errors from `compiler_builtins`. -rust_linux_no_core_targets="\ +rust_linux_no_dist_targets="\ aarch64-pc-windows-msvc \ aarch64-unknown-freebsd \ aarch64-unknown-hermit \ @@ -276,31 +200,59 @@ x86_64-unknown-openbsd \ x86_64-wrs-vxworks \ " -if [ "${rust}" = "nightly" ] && [ "${OS}" = "linux" ]; then - for target in $rust_linux_no_core_targets; do - if echo "$target" | grep -q "$FILTER"; then - test_target "$target" 1 - fi - - test_run=1 - done -fi - -rust_apple_no_core_targets="\ +rust_apple_no_dist_targets="\ armv7s-apple-ios \ i686-apple-darwin \ i386-apple-ios \ " -if [ "${rust}" = "nightly" ] && [ "${OS}" = "macos" ]; then - for target in $rust_apple_no_core_targets; do - if echo "$target" | grep -q "$FILTER"; then +# The targets are listed here alphabetically +if [ "$os" = "linux" ]; then + targets="$rust_linux_targets" + nightly_targets="$rust_nightly_linux_targets" + no_dist_targets="$rust_linux_no_dist_targets" +elif [ "$os" = "macos" ]; then + targets="$rust_apple_targets" + nightly_targets="$rust_nightly_apple_targets" + no_dist_targets="$rust_apple_no_dist_targets" +elif [ "$os" = "windows" ]; then + targets=${rust_nightly_windows_targets} +else + exit 1 +fi + +if [ "$rust" = "nightly" ]; then + targets="$targets ${nightly_targets:-}" +else + # build-std requires nightly + no_dist_targets="" +fi + +for target in $targets; do + if echo "$target" | grep -q "$filter"; then + if [ "$os" = "windows" ]; then + TARGET="$target" ./ci/install-rust.sh + test_target "$target" + else + test_target "$target" + fi + + test_run=1 + fi +done + +for target in ${no_dist_targets:-}; do + if echo "$target" | grep -q "$filter"; then + if [ "$os" = "windows" ]; then + TARGET="$target" ./ci/install-rust.sh + test_target "$target" 1 + else test_target "$target" 1 fi test_run=1 - done -fi + fi +done # Make sure we didn't accidentally filter everything if [ "${test_run:-}" != 1 ]; then diff --git a/ci/wasi.sh b/ci/wasi.sh old mode 100644 new mode 100755