|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +. ./ci/zinc/linux_base.sh |
| 4 | + |
| 5 | +OLD_ZIG="$DEPS_LOCAL/bin/zig" |
| 6 | +TARGET="${ARCH}-linux-musl" |
| 7 | +MCPU="baseline" |
| 8 | + |
| 9 | +# Make the `zig version` number consistent. |
| 10 | +# This will affect the cmake command below. |
| 11 | +git config core.abbrev 9 |
| 12 | + |
| 13 | +echo "building stage3-release with zig version $($OLD_ZIG version)" |
| 14 | + |
| 15 | +export CC="$OLD_ZIG cc -target $TARGET -mcpu=$MCPU" |
| 16 | +export CXX="$OLD_ZIG c++ -target $TARGET -mcpu=$MCPU" |
| 17 | + |
| 18 | +mkdir build-release |
| 19 | +cd build-release |
| 20 | +STAGE2_PREFIX="$(pwd)/stage2" |
| 21 | +cmake .. \ |
| 22 | + -DCMAKE_INSTALL_PREFIX="$STAGE2_PREFIX" \ |
| 23 | + -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \ |
| 24 | + -DCMAKE_BUILD_TYPE=Release \ |
| 25 | + -DZIG_TARGET_TRIPLE="$TARGET" \ |
| 26 | + -DZIG_TARGET_MCPU="$MCPU" \ |
| 27 | + -DZIG_STATIC=ON \ |
| 28 | + -GNinja |
| 29 | + |
| 30 | +# Now cmake will use zig as the C/C++ compiler. We reset the environment variables |
| 31 | +# so that installation and testing do not get affected by them. |
| 32 | +unset CC |
| 33 | +unset CXX |
| 34 | + |
| 35 | +ninja install |
| 36 | + |
| 37 | +# Here we rebuild zig but this time using the Zig binary we just now produced to |
| 38 | +# build zig1.o rather than relying on the one built with stage0. See |
| 39 | +# https://github.com/ziglang/zig/issues/6830 for more details. |
| 40 | +cmake .. -DZIG_EXECUTABLE="$STAGE2_PREFIX/bin/zig" |
| 41 | +ninja install |
| 42 | + |
| 43 | +# This is the binary we will distribute. We intentionally test this one in this |
| 44 | +# script. If any test failures occur, hopefully they also occur in the debug |
| 45 | +# version of this script for easier troubleshooting. This prevents distribution |
| 46 | +# of a Zig binary that passes tests in debug mode but has a miscompilation in |
| 47 | +# release mode. |
| 48 | +"$STAGE2_PREFIX/bin/zig" build \ |
| 49 | + --prefix "$RELEASE_STAGING" \ |
| 50 | + --search-prefix "$DEPS_LOCAL" \ |
| 51 | + -Dstatic-llvm \ |
| 52 | + -Drelease \ |
| 53 | + -Dstrip \ |
| 54 | + -Dtarget="$TARGET" \ |
| 55 | + -Denable-stage1 |
| 56 | + |
| 57 | +cd $WORKSPACE |
| 58 | + |
| 59 | +ZIG="$RELEASE_STAGING/bin/zig" |
| 60 | + |
| 61 | +$ZIG build \ |
| 62 | + test-compiler-rt \ |
| 63 | + test-behavior \ |
| 64 | + test-std \ |
| 65 | + test-universal-libc \ |
| 66 | + test-compare-output \ |
| 67 | + test-asm-link \ |
| 68 | + test-translate-c \ |
| 69 | + test-run-translated-c \ |
| 70 | + test-standalone \ |
| 71 | + test-cli \ |
| 72 | + test-cases \ |
| 73 | + test-link \ |
| 74 | + -fqemu \ |
| 75 | + -fwasmtime \ |
| 76 | + -Dstatic-llvm \ |
| 77 | + -Dtarget=native-native-musl \ |
| 78 | + --search-prefix "$DEPS_LOCAL" |
| 79 | + |
| 80 | +# Produce the experimental std lib documentation. |
| 81 | +mkdir -p "$RELEASE_STAGING/docs/std" |
| 82 | +$ZIG test lib/std/std.zig \ |
| 83 | + --zig-lib-dir lib \ |
| 84 | + -femit-docs=$RELEASE_STAGING/docs/std \ |
| 85 | + -fno-emit-bin |
| 86 | + |
| 87 | +# Look for HTML errors. |
| 88 | +tidy --drop-empty-elements no -qe zig-cache/langref.html |
| 89 | + |
| 90 | +# Explicit exit helps show last command duration. |
| 91 | +exit |
0 commit comments