| 1 | #!/bin/sh |
| 2 | |
| 3 | # Requires cc cmake ninja-build |
| 4 | |
| 5 | set -x |
| 6 | set -e |
| 7 | |
| 8 | TARGET="x86_64-linux-musl" |
| 9 | MCPU="baseline" |
| 10 | CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.17.0-dev.203+073889523" |
| 11 | PREFIX="$HOME/deps/$CACHE_BASENAME" |
| 12 | ZIG="$PREFIX/bin/zig" |
| 13 | |
| 14 | export PATH="$HOME/deps/wasmtime-v46.0.1-x86_64-linux:$HOME/deps/qemu-linux-x86_64-11.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. |
| 19 | export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache" |
| 20 | export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache" |
| 21 | |
| 22 | # Test building from source without LLVM. |
| 23 | cc -o bootstrap bootstrap.c |
| 24 | ./bootstrap |
| 25 | ./zig2 build -Dno-lib |
| 26 | ./zig-out/bin/zig test test/behavior.zig |
| 27 | |
| 28 | mkdir build-release |
| 29 | cd build-release |
| 30 | |
| 31 | export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" |
| 32 | export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" |
| 33 | |
| 34 | cmake .. \ |
| 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. |
| 46 | unset CC |
| 47 | unset CXX |
| 48 | |
| 49 | ninja install |
| 50 | |
| 51 | # Must not be set while using the other `zig cc` which has its own zig lib dir. |
| 52 | export ZIG_LIB_DIR="$PWD/../lib" |
| 53 | |
| 54 | # Covers several things: |
| 55 | # 1. building the compiler without LLVM |
| 56 | # 2. 32-bit |
| 57 | # 3. arm |
| 58 | stage3-release/bin/zig build \ |
| 59 | -Dtarget=arm-linux-musleabihf \ |
| 60 | -Dno-lib |
| 61 | |
| 62 | stage3-release/bin/zig build test docs \ |
| 63 | --maxrss ${ZSF_MAX_RSS:-0} \ |
| 64 | -Dlldb=$HOME/deps/lldb-zig/Release-7c1090fd46/bin/lldb \ |
| 65 | -Dlibc-test-path=$HOME/deps/libc-test-b95fe84 \ |
| 66 | -fqemu \ |
| 67 | --libc-runtimes $HOME/deps/glibc-2.43-musl-1.2.5 \ |
| 68 | -fwasmtime \ |
| 69 | -Dstatic-llvm \ |
| 70 | -Dtarget=native-native-musl \ |
| 71 | --search-prefix "$PREFIX" \ |
| 72 | -Denable-superhtml \ |
| 73 | --test-timeout 12m |
| 74 | |
| 75 | # Ensure that the fuzzer at least compiles. |
| 76 | stage3-release/bin/zig build test-std --fuzz=1K -Dno-lib -Dfuzz-only -Doptimize=ReleaseSafe |
| 77 | stage3-release/bin/zig build test-std --fuzz=1K -Dno-lib -Dfuzz-only -Doptimize=Debug |
| 78 | |
| 79 | # Ensure that stage3 and stage4 are byte-for-byte identical. |
| 80 | stage3-release/bin/zig build \ |
| 81 | --prefix stage4-release \ |
| 82 | -Denable-llvm \ |
| 83 | -Dno-lib \ |
| 84 | -Doptimize=ReleaseFast \ |
| 85 | -Dstrip \ |
| 86 | -Dtarget=$TARGET \ |
| 87 | -Duse-zig-libcxx \ |
| 88 | -Dversion-string="$(stage3-release/bin/zig version)" |
| 89 | |
| 90 | echo "If the following command fails, it means nondeterminism has been" |
| 91 | echo "introduced, making stage3 and stage4 no longer byte-for-byte identical." |
| 92 | diff stage3-release/bin/zig stage4-release/bin/zig |
| 93 | |
| 94 | # Ensure that updating the wasm binary from this commit will result in a viable build. |
| 95 | stage3-release/bin/zig build update-zig1 |
| 96 | |
| 97 | mkdir ../build-new |
| 98 | cd ../build-new |
| 99 | |
| 100 | export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" |
| 101 | export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" |
| 102 | unset ZIG_LIB_DIR |
| 103 | |
| 104 | cmake .. \ |
| 105 | -DCMAKE_PREFIX_PATH="$PREFIX" \ |
| 106 | -DCMAKE_BUILD_TYPE=Release \ |
| 107 | -DZIG_TARGET_TRIPLE="$TARGET" \ |
| 108 | -DZIG_TARGET_MCPU="$MCPU" \ |
| 109 | -DZIG_STATIC=ON \ |
| 110 | -DZIG_NO_LIB=ON \ |
| 111 | -GNinja \ |
| 112 | -DCMAKE_C_LINKER_DEPFILE_SUPPORTED=FALSE \ |
| 113 | -DCMAKE_CXX_LINKER_DEPFILE_SUPPORTED=FALSE |
| 114 | # https://github.com/ziglang/zig/issues/22213 |
| 115 | |
| 116 | unset CC |
| 117 | unset CXX |
| 118 | |
| 119 | ninja install |
| 120 | |
| 121 | export ZIG_LIB_DIR="$PWD/../lib" |
| 122 | |
| 123 | stage3/bin/zig test ../test/behavior.zig |
| 124 | stage3/bin/zig build -p stage4 \ |
| 125 | -Dstatic-llvm \ |
| 126 | -Dtarget=native-native-musl \ |
| 127 | -Dno-lib \ |
| 128 | --search-prefix "$PREFIX" |
| 129 | stage4/bin/zig test ../test/behavior.zig |