|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# Requires cmake ninja-build |
| 4 | + |
| 5 | +set -x |
| 6 | +set -e |
| 7 | + |
| 8 | +ARCH="x86_64" |
| 9 | +TARGET="$ARCH-freebsd-none" |
| 10 | +MCPU="baseline" |
| 11 | +CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.16.0-dev.312+164c598cd" |
| 12 | +PREFIX="$HOME/deps/$CACHE_BASENAME" |
| 13 | +ZIG="$PREFIX/bin/zig" |
| 14 | + |
| 15 | +# Make the `zig version` number consistent. |
| 16 | +# This will affect the cmake command below. |
| 17 | +git fetch --unshallow || true |
| 18 | +git fetch --tags |
| 19 | + |
| 20 | +# Override the cache directories because they won't actually help other CI runs |
| 21 | +# which will be testing alternate versions of zig, and ultimately would just |
| 22 | +# fill up space on the hard drive for no reason. |
| 23 | +export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache" |
| 24 | +export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache" |
| 25 | + |
| 26 | +mkdir build-release |
| 27 | +cd build-release |
| 28 | + |
| 29 | +export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" |
| 30 | +export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" |
| 31 | + |
| 32 | +cmake .. \ |
| 33 | + -DCMAKE_INSTALL_PREFIX="stage3-release" \ |
| 34 | + -DCMAKE_PREFIX_PATH="$PREFIX" \ |
| 35 | + -DCMAKE_BUILD_TYPE=Release \ |
| 36 | + -DZIG_TARGET_TRIPLE="$TARGET" \ |
| 37 | + -DZIG_TARGET_MCPU="$MCPU" \ |
| 38 | + -DZIG_STATIC=ON \ |
| 39 | + -DZIG_NO_LIB=ON \ |
| 40 | + -GNinja \ |
| 41 | + -DCMAKE_C_LINKER_DEPFILE_SUPPORTED=FALSE \ |
| 42 | + -DCMAKE_CXX_LINKER_DEPFILE_SUPPORTED=FALSE |
| 43 | +# https://github.com/ziglang/zig/issues/22213 |
| 44 | + |
| 45 | +# Now cmake will use zig as the C/C++ compiler. We reset the environment variables |
| 46 | +# so that installation and testing do not get affected by them. |
| 47 | +unset CC |
| 48 | +unset CXX |
| 49 | + |
| 50 | +ninja install |
| 51 | + |
| 52 | +stage3-release/bin/zig build test docs \ |
| 53 | + --maxrss 32212254720 \ |
| 54 | + -Dstatic-llvm \ |
| 55 | + -Dskip-linux \ |
| 56 | + -Dskip-netbsd \ |
| 57 | + -Dskip-windows \ |
| 58 | + -Dskip-macos \ |
| 59 | + -Dtarget=native-native-none \ |
| 60 | + --search-prefix "$PREFIX" \ |
| 61 | + --zig-lib-dir "$PWD/../lib" |
| 62 | + |
| 63 | +# Ensure that stage3 and stage4 are byte-for-byte identical. |
| 64 | +stage3-release/bin/zig build \ |
| 65 | + --prefix stage4-release \ |
| 66 | + -Denable-llvm \ |
| 67 | + -Dno-lib \ |
| 68 | + -Doptimize=ReleaseFast \ |
| 69 | + -Dstrip \ |
| 70 | + -Dtarget=$TARGET \ |
| 71 | + -Duse-zig-libcxx \ |
| 72 | + -Dversion-string="$(stage3-release/bin/zig version)" |
| 73 | + |
| 74 | +# diff returns an error code if the files differ. |
| 75 | +echo "If the following command fails, it means nondeterminism has been" |
| 76 | +echo "introduced, making stage3 and stage4 no longer byte-for-byte identical." |
| 77 | +diff stage3-release/bin/zig stage4-release/bin/zig |
0 commit comments