Commit 06c42a0c68

Andrew Kelley <andrew@ziglang.org>
2022-08-09 01:59:38
CI: test both stage3-debug and stage3-release on x86-linux
1 parent 507aae4
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
ci/zinc/linux_test.sh → 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
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