From 06c42a0c68b5e3ce54135738704cc7c6c5b92565 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 8 Aug 2022 16:59:38 -0700 Subject: [PATCH] CI: test both stage3-debug and stage3-release on x86-linux --- ci/zinc/drone.yml | 12 ++- ...nux_test.sh => linux_test_stage3_debug.sh} | 29 +----- ci/zinc/linux_test_stage3_release.sh | 91 +++++++++++++++++++ 3 files changed, 104 insertions(+), 28 deletions(-) rename ci/zinc/{linux_test.sh => linux_test_stage3_debug.sh} (84%) create mode 100755 ci/zinc/linux_test_stage3_release.sh diff --git a/ci/zinc/drone.yml b/ci/zinc/drone.yml index 6bb7d73b41..38185df7e7 100644 --- a/ci/zinc/drone.yml +++ b/ci/zinc/drone.yml @@ -9,14 +9,20 @@ workspace: path: /workspace steps: -- name: test +- name: test_stage3_debug image: ci/debian-amd64:11.1-6 commands: - - ./ci/zinc/linux_test.sh + - ./ci/zinc/linux_test_stage3_debug.sh + +- name: test_stage3_release + image: ci/debian-amd64:11.1-6 + commands: + - ./ci/zinc/linux_test_stage3_release.sh - name: package depends_on: - - test + - test_stage3_debug + - test_stage3_release when: branch: - master diff --git a/ci/zinc/linux_test.sh b/ci/zinc/linux_test_stage3_debug.sh similarity index 84% rename from ci/zinc/linux_test.sh rename to ci/zinc/linux_test_stage3_debug.sh index 1b280fbae5..85cfb57b2e 100755 --- a/ci/zinc/linux_test.sh +++ b/ci/zinc/linux_test_stage3_debug.sh @@ -10,13 +10,13 @@ MCPU="baseline" # This will affect the cmake command below. git config core.abbrev 9 -echo "building debug zig with zig version $($OLD_ZIG version)" +echo "building stage3-debug with zig version $($OLD_ZIG version)" export CC="$OLD_ZIG cc -target $TARGET -mcpu=$MCPU" export CXX="$OLD_ZIG c++ -target $TARGET -mcpu=$MCPU" -mkdir _debug -cd _debug +mkdir build-debug +cd build-debug cmake .. \ -DCMAKE_INSTALL_PREFIX="$DEBUG_STAGING" \ -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \ @@ -63,29 +63,8 @@ stage3/bin/zig build test-standalone -fqemu -fwasmtime -Dstatic-llvm -Dtar stage3/bin/zig build test-cli -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" stage3/bin/zig build test-cases -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" stage3/bin/zig build test-link -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" +stage3/bin/zig build test-stack-traces -fqemu -fwasmtime -fstage1 stage3/bin/zig build docs -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" -stage3/bin/zig build test-stack-traces -fqemu -fwasmtime -fstage1 - -# Produce the experimental std lib documentation. -mkdir -p "$RELEASE_STAGING/docs/std" -stage3/bin/zig test lib/std/std.zig \ - --zig-lib-dir lib \ - -femit-docs=$RELEASE_STAGING/docs/std \ - -fno-emit-bin - -# Look for HTML errors. -tidy --drop-empty-elements no -qe zig-cache/langref.html - -# Build release zig. -stage3/bin/zig build \ - --prefix "$RELEASE_STAGING" \ - --search-prefix "$DEPS_LOCAL" \ - -Dstatic-llvm \ - -Drelease \ - -Dstrip \ - -Dtarget="$TARGET" \ - -Denable-stage1 - # Explicit exit helps show last command duration. exit diff --git a/ci/zinc/linux_test_stage3_release.sh b/ci/zinc/linux_test_stage3_release.sh new file mode 100755 index 0000000000..764c89db8f --- /dev/null +++ b/ci/zinc/linux_test_stage3_release.sh @@ -0,0 +1,91 @@ +#!/bin/sh + +. ./ci/zinc/linux_base.sh + +OLD_ZIG="$DEPS_LOCAL/bin/zig" +TARGET="${ARCH}-linux-musl" +MCPU="baseline" + +# Make the `zig version` number consistent. +# This will affect the cmake command below. +git config core.abbrev 9 + +echo "building stage3-release with zig version $($OLD_ZIG version)" + +export CC="$OLD_ZIG cc -target $TARGET -mcpu=$MCPU" +export CXX="$OLD_ZIG c++ -target $TARGET -mcpu=$MCPU" + +mkdir build-release +cd build-release +STAGE2_PREFIX="$(pwd)/stage2" +cmake .. \ + -DCMAKE_INSTALL_PREFIX="$STAGE2_PREFIX" \ + -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \ + -DCMAKE_BUILD_TYPE=Release \ + -DZIG_TARGET_TRIPLE="$TARGET" \ + -DZIG_TARGET_MCPU="$MCPU" \ + -DZIG_STATIC=ON \ + -GNinja + +# Now cmake will use zig as the C/C++ compiler. We reset the environment variables +# so that installation and testing do not get affected by them. +unset CC +unset CXX + +ninja install + +# Here we rebuild zig but this time using the Zig binary we just now produced to +# build zig1.o rather than relying on the one built with stage0. See +# https://github.com/ziglang/zig/issues/6830 for more details. +cmake .. -DZIG_EXECUTABLE="$STAGE2_PREFIX/bin/zig" +ninja install + +# This is the binary we will distribute. We intentionally test this one in this +# script. If any test failures occur, hopefully they also occur in the debug +# version of this script for easier troubleshooting. This prevents distribution +# of a Zig binary that passes tests in debug mode but has a miscompilation in +# release mode. +"$STAGE2_PREFIX/bin/zig" build \ + --prefix "$RELEASE_STAGING" \ + --search-prefix "$DEPS_LOCAL" \ + -Dstatic-llvm \ + -Drelease \ + -Dstrip \ + -Dtarget="$TARGET" \ + -Denable-stage1 + +cd $WORKSPACE + +ZIG="$RELEASE_STAGING/bin/zig" + +$ZIG build \ + test-compiler-rt \ + test-behavior \ + test-std \ + test-universal-libc \ + test-compare-output \ + test-asm-link \ + test-translate-c \ + test-run-translated-c \ + test-standalone \ + test-cli \ + test-cases \ + test-link \ + -fqemu \ + -fwasmtime \ + -Dstatic-llvm \ + -Dtarget=native-native-musl \ + --search-prefix "$DEPS_LOCAL" + +# Produce the experimental std lib documentation. +mkdir -p "$RELEASE_STAGING/docs/std" +$ZIG test lib/std/std.zig \ + --zig-lib-dir lib \ + -femit-docs=$RELEASE_STAGING/docs/std \ + -fno-emit-bin + +# Look for HTML errors. +tidy --drop-empty-elements no -qe zig-cache/langref.html + +# Explicit exit helps show last command duration. +exit