From 7d5de709c8fbe24bb34817d289ac91f0d2e3a6b8 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sun, 7 Jan 2024 11:18:13 -0500 Subject: Check if tier 2 targets build in the nightly cron job --- src/tools/miri/.github/workflows/ci.yml | 4 +- src/tools/miri/.github/workflows/sysroots.yml | 49 +++++++++ src/tools/miri/cargo-miri/Cargo.lock | 4 +- src/tools/miri/ci.sh | 145 -------------------------- src/tools/miri/ci/build-all-targets.sh | 27 +++++ src/tools/miri/ci/ci.sh | 145 ++++++++++++++++++++++++++ src/tools/miri/ci/scrape-targets.py | 15 +++ 7 files changed, 240 insertions(+), 149 deletions(-) create mode 100644 src/tools/miri/.github/workflows/sysroots.yml delete mode 100755 src/tools/miri/ci.sh create mode 100755 src/tools/miri/ci/build-all-targets.sh create mode 100755 src/tools/miri/ci/ci.sh create mode 100644 src/tools/miri/ci/scrape-targets.py (limited to 'src/tools') diff --git a/src/tools/miri/.github/workflows/ci.yml b/src/tools/miri/.github/workflows/ci.yml index dec85e9232f..0954c57a1db 100644 --- a/src/tools/miri/.github/workflows/ci.yml +++ b/src/tools/miri/.github/workflows/ci.yml @@ -73,7 +73,7 @@ jobs: cargo -V - name: Test - run: ./ci.sh + run: ./ci/ci.sh style: name: style checks @@ -169,7 +169,7 @@ jobs: --message 'Dear @*T-miri*, It would appear that the [Miri cron job build]('"https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"') failed. - + This likely means that rustc changed the miri directory and we now need to do a [`./miri rustc-pull`](https://github.com/rust-lang/miri/blob/master/CONTRIBUTING.md#importing-changes-from-the-rustc-repo). diff --git a/src/tools/miri/.github/workflows/sysroots.yml b/src/tools/miri/.github/workflows/sysroots.yml new file mode 100644 index 00000000000..509521e7478 --- /dev/null +++ b/src/tools/miri/.github/workflows/sysroots.yml @@ -0,0 +1,49 @@ +name: Tier 2 sysroots + +on: push +# schedule: +# - cron: '44 4 * * *' # At 4:44 UTC every day. + +defaults: + run: + shell: bash + +jobs: + sysroots: + name: Build the sysroots + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build the sysroots + run: | + cargo install -f rustup-toolchain-install-master + ./miri toolchain -c rust-docs # Docs are the only place targets are separated by tier + ./miri install + python3 -m pip install beautifulsoup4 + ./ci/build-all-targets.sh + + sysroots-cron-fail-notify: + name: sysroots cronjob failure notification + runs-on: ubuntu-latest + needs: [sysroots] + if: failure() || cancelled() + steps: + # Send a Zulip notification + - name: Install zulip-send + run: pip3 install zulip + - name: Send Zulip notification + env: + ZULIP_BOT_EMAIL: ${{ secrets.ZULIP_BOT_EMAIL }} + ZULIP_API_TOKEN: ${{ secrets.ZULIP_API_TOKEN }} + run: | + ~/.local/bin/zulip-send --user $ZULIP_BOT_EMAIL --api-key $ZULIP_API_TOKEN --site https://rust-lang.zulipchat.com \ + --stream miri --subject "Cron Job Failure (miri, $(date -u +%Y-%m))" \ + --message 'Dear @*T-miri*, + + It would appear that the [Miri sysroots cron job build]('"https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"') failed. + + Would you mind investigating this issue? + + Thanks in advance! + Sincerely, + The Miri Cronjobs Bot' diff --git a/src/tools/miri/cargo-miri/Cargo.lock b/src/tools/miri/cargo-miri/Cargo.lock index 8f442b3de13..e648a05025d 100644 --- a/src/tools/miri/cargo-miri/Cargo.lock +++ b/src/tools/miri/cargo-miri/Cargo.lock @@ -212,9 +212,9 @@ dependencies = [ [[package]] name = "rustc-build-sysroot" -version = "0.4.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ed2a90dfa5232ed5ff21d53d4df655f315ab316ea06fc508f1c74bcedb1ce6c" +checksum = "39dcf8d82b1f79a179bdb284dc44db440a9666eefa5a6df5ef282d6db930d544" dependencies = [ "anyhow", "rustc_version", diff --git a/src/tools/miri/ci.sh b/src/tools/miri/ci.sh deleted file mode 100755 index 6bcc68ebf7c..00000000000 --- a/src/tools/miri/ci.sh +++ /dev/null @@ -1,145 +0,0 @@ -#!/bin/bash -set -euo pipefail - -function begingroup { - echo "::group::$@" - set -x -} - -function endgroup { - set +x - echo "::endgroup" -} - -begingroup "Building Miri" - -# Determine configuration for installed build -echo "Installing release version of Miri" -export RUSTFLAGS="-D warnings" -export CARGO_INCREMENTAL=0 -export CARGO_EXTRA_FLAGS="--locked" -./miri install - -# Prepare debug build for direct `./miri` invocations -echo "Building debug version of Miri" -./miri check --no-default-features # make sure this can be built -./miri check --all-features # and this, too -./miri build --all-targets # the build that all the `./miri test` below will use - -endgroup - -# Test -function run_tests { - if [ -n "${MIRI_TEST_TARGET:-}" ]; then - begingroup "Testing foreign architecture $MIRI_TEST_TARGET" - else - begingroup "Testing host architecture" - fi - - ## ui test suite - # On the host and on Linux, also stress-test the GC. - if [ -z "${MIRI_TEST_TARGET:-}" ] || [ "$HOST_TARGET" = x86_64-unknown-linux-gnu ]; then - MIRIFLAGS="${MIRIFLAGS:-} -Zmiri-provenance-gc=1" ./miri test - else - ./miri test - fi - - # Host-only tests - if [ -z "${MIRI_TEST_TARGET:-}" ]; then - # Running these on all targets is unlikely to catch more problems and would - # cost a lot of CI time. - - # Tests with optimizations (`-O` is what cargo passes, but crank MIR optimizations up all the - # way, too). - # Optimizations change diagnostics (mostly backtraces), so we don't check - # them. Also error locations change so we don't run the failing tests. - # We explicitly enable debug-assertions here, they are disabled by -O but we have tests - # which exist to check that we panic on debug assertion failures. - MIRIFLAGS="${MIRIFLAGS:-} -O -Zmir-opt-level=4 -Cdebug-assertions=yes" MIRI_SKIP_UI_CHECKS=1 ./miri test -- tests/{pass,panic} - - # Also run some many-seeds tests. 64 seeds means this takes around a minute per test. - for FILE in tests/many-seeds/*.rs; do - MIRI_SEEDS=64 ./miri many-seeds ./miri run "$FILE" - done - - # Check that the benchmarks build and run, but without actually benchmarking. - HYPERFINE="bash -c" ./miri bench - fi - - ## test-cargo-miri - # On Windows, there is always "python", not "python3" or "python2". - if command -v python3 > /dev/null; then - PYTHON=python3 - else - PYTHON=python - fi - # Some environment setup that attempts to confuse the heck out of cargo-miri. - if [ "$HOST_TARGET" = x86_64-unknown-linux-gnu ]; then - # These act up on Windows (`which miri` produces a filename that does not exist?!?), - # so let's do this only on Linux. Also makes sure things work without these set. - export RUSTC=$(which rustc) # Produces a warning unless we also set MIRI - export MIRI=$(rustc +miri --print sysroot)/bin/miri - fi - mkdir -p .cargo - echo 'build.rustc-wrapper = "thisdoesnotexist"' > .cargo/config.toml - # Run the actual test - ${PYTHON} test-cargo-miri/run-test.py - # Clean up - unset RUSTC MIRI - rm -rf .cargo - - endgroup -} - -function run_tests_minimal { - if [ -n "${MIRI_TEST_TARGET:-}" ]; then - begingroup "Testing MINIMAL foreign architecture $MIRI_TEST_TARGET: only testing $@" - else - echo "run_tests_minimal requires MIRI_TEST_TARGET to be set" - exit 1 - fi - - ./miri test -- "$@" - - # Ensure that a small smoke test of cargo-miri works. - cargo miri run --manifest-path test-cargo-miri/no-std-smoke/Cargo.toml --target ${MIRI_TEST_TARGET-$HOST_TARGET} - - endgroup -} - -## Main Testing Logic ## - -# Host target. -run_tests - -# Extra targets. -# In particular, fully cover all tier 1 targets. -case $HOST_TARGET in - x86_64-unknown-linux-gnu) - MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests - MIRI_TEST_TARGET=aarch64-unknown-linux-gnu run_tests - MIRI_TEST_TARGET=aarch64-apple-darwin run_tests - MIRI_TEST_TARGET=i686-pc-windows-gnu run_tests - # Some targets are only partially supported. - MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple pthread-threadname libc-getentropy libc-getrandom libc-misc libc-fs atomic env align - MIRI_TEST_TARGET=i686-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple pthread-threadname libc-getentropy libc-getrandom libc-misc libc-fs atomic env align - MIRI_TEST_TARGET=aarch64-linux-android run_tests_minimal hello integer vec panic/panic - MIRI_TEST_TARGET=wasm32-wasi run_tests_minimal no_std integer strings wasm - MIRI_TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std integer strings wasm - MIRI_TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std # no_std embedded architecture - MIRI_TEST_TARGET=tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std # JSON target file - ;; - x86_64-apple-darwin) - MIRI_TEST_TARGET=s390x-unknown-linux-gnu run_tests # big-endian architecture - MIRI_TEST_TARGET=x86_64-pc-windows-msvc run_tests - ;; - i686-pc-windows-msvc) - MIRI_TEST_TARGET=arm-unknown-linux-gnueabi run_tests - MIRI_TEST_TARGET=x86_64-unknown-linux-gnu run_tests - MIRI_TEST_TARGET=x86_64-pc-windows-gnu run_tests - ;; - *) - echo "FATAL: unknown OS" - exit 1 - ;; -esac diff --git a/src/tools/miri/ci/build-all-targets.sh b/src/tools/miri/ci/build-all-targets.sh new file mode 100755 index 00000000000..bf3ffd07017 --- /dev/null +++ b/src/tools/miri/ci/build-all-targets.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +set -eu +set -o pipefail + +FAILS_DIR=failures + +rm -rf $FAILS_DIR +mkdir $FAILS_DIR + +PLATFORM_SUPPORT_FILE=$(rustc +miri --print sysroot)/share/doc/rust/html/rustc/platform-support.html + +for target in $(python3 ci/scrape-targets.py $PLATFORM_SUPPORT_FILE); do + # Wipe the cache before every build to minimize disk usage + rm -rf ~/.cache/miri + if cargo +miri miri setup --target $target 2>&1 | tee failures/$target; then + # If the build succeeds, delete its output. If we have output, a build failed. + rm $FAILS_DIR/$target + fi +done + +# If the sysroot for any target fails to build, we will have a file in FAILS_DIR. +if [[ $(ls failures | wc -l) -ne 0 ]]; then + echo "Sysroots for the following targets failed to build:" + ls $FAILS_DIR + exit 1 +fi diff --git a/src/tools/miri/ci/ci.sh b/src/tools/miri/ci/ci.sh new file mode 100755 index 00000000000..6bcc68ebf7c --- /dev/null +++ b/src/tools/miri/ci/ci.sh @@ -0,0 +1,145 @@ +#!/bin/bash +set -euo pipefail + +function begingroup { + echo "::group::$@" + set -x +} + +function endgroup { + set +x + echo "::endgroup" +} + +begingroup "Building Miri" + +# Determine configuration for installed build +echo "Installing release version of Miri" +export RUSTFLAGS="-D warnings" +export CARGO_INCREMENTAL=0 +export CARGO_EXTRA_FLAGS="--locked" +./miri install + +# Prepare debug build for direct `./miri` invocations +echo "Building debug version of Miri" +./miri check --no-default-features # make sure this can be built +./miri check --all-features # and this, too +./miri build --all-targets # the build that all the `./miri test` below will use + +endgroup + +# Test +function run_tests { + if [ -n "${MIRI_TEST_TARGET:-}" ]; then + begingroup "Testing foreign architecture $MIRI_TEST_TARGET" + else + begingroup "Testing host architecture" + fi + + ## ui test suite + # On the host and on Linux, also stress-test the GC. + if [ -z "${MIRI_TEST_TARGET:-}" ] || [ "$HOST_TARGET" = x86_64-unknown-linux-gnu ]; then + MIRIFLAGS="${MIRIFLAGS:-} -Zmiri-provenance-gc=1" ./miri test + else + ./miri test + fi + + # Host-only tests + if [ -z "${MIRI_TEST_TARGET:-}" ]; then + # Running these on all targets is unlikely to catch more problems and would + # cost a lot of CI time. + + # Tests with optimizations (`-O` is what cargo passes, but crank MIR optimizations up all the + # way, too). + # Optimizations change diagnostics (mostly backtraces), so we don't check + # them. Also error locations change so we don't run the failing tests. + # We explicitly enable debug-assertions here, they are disabled by -O but we have tests + # which exist to check that we panic on debug assertion failures. + MIRIFLAGS="${MIRIFLAGS:-} -O -Zmir-opt-level=4 -Cdebug-assertions=yes" MIRI_SKIP_UI_CHECKS=1 ./miri test -- tests/{pass,panic} + + # Also run some many-seeds tests. 64 seeds means this takes around a minute per test. + for FILE in tests/many-seeds/*.rs; do + MIRI_SEEDS=64 ./miri many-seeds ./miri run "$FILE" + done + + # Check that the benchmarks build and run, but without actually benchmarking. + HYPERFINE="bash -c" ./miri bench + fi + + ## test-cargo-miri + # On Windows, there is always "python", not "python3" or "python2". + if command -v python3 > /dev/null; then + PYTHON=python3 + else + PYTHON=python + fi + # Some environment setup that attempts to confuse the heck out of cargo-miri. + if [ "$HOST_TARGET" = x86_64-unknown-linux-gnu ]; then + # These act up on Windows (`which miri` produces a filename that does not exist?!?), + # so let's do this only on Linux. Also makes sure things work without these set. + export RUSTC=$(which rustc) # Produces a warning unless we also set MIRI + export MIRI=$(rustc +miri --print sysroot)/bin/miri + fi + mkdir -p .cargo + echo 'build.rustc-wrapper = "thisdoesnotexist"' > .cargo/config.toml + # Run the actual test + ${PYTHON} test-cargo-miri/run-test.py + # Clean up + unset RUSTC MIRI + rm -rf .cargo + + endgroup +} + +function run_tests_minimal { + if [ -n "${MIRI_TEST_TARGET:-}" ]; then + begingroup "Testing MINIMAL foreign architecture $MIRI_TEST_TARGET: only testing $@" + else + echo "run_tests_minimal requires MIRI_TEST_TARGET to be set" + exit 1 + fi + + ./miri test -- "$@" + + # Ensure that a small smoke test of cargo-miri works. + cargo miri run --manifest-path test-cargo-miri/no-std-smoke/Cargo.toml --target ${MIRI_TEST_TARGET-$HOST_TARGET} + + endgroup +} + +## Main Testing Logic ## + +# Host target. +run_tests + +# Extra targets. +# In particular, fully cover all tier 1 targets. +case $HOST_TARGET in + x86_64-unknown-linux-gnu) + MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests + MIRI_TEST_TARGET=aarch64-unknown-linux-gnu run_tests + MIRI_TEST_TARGET=aarch64-apple-darwin run_tests + MIRI_TEST_TARGET=i686-pc-windows-gnu run_tests + # Some targets are only partially supported. + MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple pthread-threadname libc-getentropy libc-getrandom libc-misc libc-fs atomic env align + MIRI_TEST_TARGET=i686-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple pthread-threadname libc-getentropy libc-getrandom libc-misc libc-fs atomic env align + MIRI_TEST_TARGET=aarch64-linux-android run_tests_minimal hello integer vec panic/panic + MIRI_TEST_TARGET=wasm32-wasi run_tests_minimal no_std integer strings wasm + MIRI_TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std integer strings wasm + MIRI_TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std # no_std embedded architecture + MIRI_TEST_TARGET=tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std # JSON target file + ;; + x86_64-apple-darwin) + MIRI_TEST_TARGET=s390x-unknown-linux-gnu run_tests # big-endian architecture + MIRI_TEST_TARGET=x86_64-pc-windows-msvc run_tests + ;; + i686-pc-windows-msvc) + MIRI_TEST_TARGET=arm-unknown-linux-gnueabi run_tests + MIRI_TEST_TARGET=x86_64-unknown-linux-gnu run_tests + MIRI_TEST_TARGET=x86_64-pc-windows-gnu run_tests + ;; + *) + echo "FATAL: unknown OS" + exit 1 + ;; +esac diff --git a/src/tools/miri/ci/scrape-targets.py b/src/tools/miri/ci/scrape-targets.py new file mode 100644 index 00000000000..c0cc5b2c3b4 --- /dev/null +++ b/src/tools/miri/ci/scrape-targets.py @@ -0,0 +1,15 @@ +import sys +from bs4 import BeautifulSoup + +html = open(sys.argv[1], 'r').read() +soup = BeautifulSoup(html, features="html.parser") +# The tables are: +# Tier 1 <-- this is already checked by main CI, so we ignore it here +# Tier 2 with host tools <-- we want this one +# Tier 2 without host tools <-- and also this +# Tier 3 +for table in soup.find_all("table")[1:3]: + for row in table.find_all('tr'): + code = row.find('code') + if code is not None: + print(code.text) -- cgit 1.4.1-3-g733a5