master
1#!/bin/sh
2
3# Requires cmake ninja-build
4
5set -x
6set -e
7
8TARGET="x86_64-linux-musl"
9MCPU="baseline"
10CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.16.0-dev.104+689461e31"
11PREFIX="$HOME/deps/$CACHE_BASENAME"
12ZIG="$PREFIX/bin/zig"
13
14export PATH="$HOME/deps/wasmtime-v38.0.3-x86_64-linux:$HOME/deps/qemu-linux-x86_64-10.1.1.1/bin:$HOME/local/bin:$PATH"
15
16# Override the cache directories because they won't actually help other CI runs
17# which will be testing alternate versions of zig, and ultimately would just
18# fill up space on the hard drive for no reason.
19export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
20export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
21
22# Test building from source without LLVM.
23cc -o bootstrap bootstrap.c
24./bootstrap
25./zig2 build -Dno-lib
26./zig-out/bin/zig test test/behavior.zig
27
28mkdir build-release
29cd build-release
30
31export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
32export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
33
34cmake .. \
35 -DCMAKE_INSTALL_PREFIX="stage3-release" \
36 -DCMAKE_PREFIX_PATH="$PREFIX" \
37 -DCMAKE_BUILD_TYPE=Release \
38 -DZIG_TARGET_TRIPLE="$TARGET" \
39 -DZIG_TARGET_MCPU="$MCPU" \
40 -DZIG_STATIC=ON \
41 -DZIG_NO_LIB=ON \
42 -GNinja
43
44# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
45# so that installation and testing do not get affected by them.
46unset CC
47unset CXX
48
49ninja install
50
51# simultaneously test building self-hosted without LLVM and with 32-bit arm
52stage3-release/bin/zig build \
53 -Dtarget=arm-linux-musleabihf \
54 -Dno-lib
55
56stage3-release/bin/zig build test docs \
57 --maxrss 21000000000 \
58 -Dlldb=$HOME/deps/lldb-zig/Release-e0a42bb34/bin/lldb \
59 -fqemu \
60 -fwasmtime \
61 -Dstatic-llvm \
62 -Dtarget=native-native-musl \
63 --search-prefix "$PREFIX" \
64 --zig-lib-dir "$PWD/../lib" \
65 -Denable-superhtml \
66 --test-timeout 12m
67
68# Ensure that stage3 and stage4 are byte-for-byte identical.
69stage3-release/bin/zig build \
70 --prefix stage4-release \
71 -Denable-llvm \
72 -Dno-lib \
73 -Doptimize=ReleaseFast \
74 -Dstrip \
75 -Dtarget=$TARGET \
76 -Duse-zig-libcxx \
77 -Dversion-string="$(stage3-release/bin/zig version)"
78
79# diff returns an error code if the files differ.
80echo "If the following command fails, it means nondeterminism has been"
81echo "introduced, making stage3 and stage4 no longer byte-for-byte identical."
82diff stage3-release/bin/zig stage4-release/bin/zig
83
84# Ensure that updating the wasm binary from this commit will result in a viable build.
85stage3-release/bin/zig build update-zig1
86
87mkdir ../build-new
88cd ../build-new
89
90export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
91export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
92
93cmake .. \
94 -DCMAKE_PREFIX_PATH="$PREFIX" \
95 -DCMAKE_BUILD_TYPE=Release \
96 -DZIG_TARGET_TRIPLE="$TARGET" \
97 -DZIG_TARGET_MCPU="$MCPU" \
98 -DZIG_STATIC=ON \
99 -DZIG_NO_LIB=ON \
100 -GNinja
101
102unset CC
103unset CXX
104
105ninja install
106
107stage3/bin/zig test ../test/behavior.zig
108stage3/bin/zig build -p stage4 \
109 -Dstatic-llvm \
110 -Dtarget=native-native-musl \
111 -Dno-lib \
112 --search-prefix "$PREFIX" \
113 --zig-lib-dir "$PWD/../lib"
114stage4/bin/zig test ../test/behavior.zig