master
1#!/bin/sh
2
3set -x
4set -e
5
6ZIGDIR="$PWD"
7TARGET="aarch64-macos-none"
8MCPU="baseline"
9CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.16.0-dev.104+689461e31"
10PREFIX="$HOME/$CACHE_BASENAME"
11ZIG="$PREFIX/bin/zig"
12
13if [ ! -d "$PREFIX" ]; then
14 cd $HOME
15 curl -L -O "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
16 tar xf "$CACHE_BASENAME.tar.xz"
17fi
18
19cd $ZIGDIR
20
21# Override the cache directories because they won't actually help other CI runs
22# which will be testing alternate versions of zig, and ultimately would just
23# fill up space on the hard drive for no reason.
24export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
25export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
26
27mkdir build-release
28cd build-release
29
30cmake .. \
31 -DCMAKE_INSTALL_PREFIX="stage3-release" \
32 -DCMAKE_PREFIX_PATH="$PREFIX" \
33 -DCMAKE_BUILD_TYPE=Release \
34 -DCMAKE_C_COMPILER="$ZIG;cc;-target;$TARGET;-mcpu=$MCPU" \
35 -DCMAKE_CXX_COMPILER="$ZIG;c++;-target;$TARGET;-mcpu=$MCPU" \
36 -DZIG_TARGET_TRIPLE="$TARGET" \
37 -DZIG_TARGET_MCPU="$MCPU" \
38 -DZIG_STATIC=ON \
39 -DZIG_NO_LIB=ON \
40 -GNinja
41
42ninja install
43
44stage3-release/bin/zig build test docs \
45 --zig-lib-dir "$PWD/../lib" \
46 -Denable-macos-sdk \
47 -Dstatic-llvm \
48 -Dskip-non-native \
49 --search-prefix "$PREFIX" \
50 --test-timeout 2m
51
52# Ensure that stage3 and stage4 are byte-for-byte identical.
53stage3-release/bin/zig build \
54 --prefix stage4-release \
55 -Denable-llvm \
56 -Dno-lib \
57 -Doptimize=ReleaseFast \
58 -Dstrip \
59 -Dtarget=$TARGET \
60 -Duse-zig-libcxx \
61 -Dversion-string="$(stage3-release/bin/zig version)"
62
63# diff returns an error code if the files differ.
64echo "If the following command fails, it means nondeterminism has been"
65echo "introduced, making stage3 and stage4 no longer byte-for-byte identical."
66diff stage3-release/bin/zig stage4-release/bin/zig