blob 61320ce0 (3808B) - Raw
1 #!/bin/sh 2 3 # Requires cmake ninja-build 4 5 set -x 6 set -e 7 8 ARCH="$(uname -m)" 9 TARGET="$ARCH-linux-musl" 10 MCPU="baseline" 11 CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.12.0-dev.203+d3bc1cfc4" 12 PREFIX="$HOME/deps/$CACHE_BASENAME" 13 ZIG="$PREFIX/bin/zig" 14 15 export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$HOME/deps/qemu-linux-x86_64-6.1.0.1/bin:$PATH" 16 17 # Make the `zig version` number consistent. 18 # This will affect the cmake command below. 19 git config core.abbrev 9 20 git fetch --unshallow || true 21 git fetch --tags 22 23 # Test building from source without LLVM. 24 git clean -fd 25 rm -rf zig-out 26 cc -o bootstrap bootstrap.c 27 ./bootstrap build -Dno-lib 28 # In order to run these behavior tests we need to move the `@cImport` ones to somewhere else. 29 # ./zig-out/bin/zig test test/behavior.zig 30 31 export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" 32 export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" 33 34 rm -rf build-release 35 mkdir build-release 36 cd build-release 37 38 # Override the cache directories because they won't actually help other CI runs 39 # which will be testing alternate versions of zig, and ultimately would just 40 # fill up space on the hard drive for no reason. 41 export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-global-cache" 42 export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache" 43 44 cmake .. \ 45 -DCMAKE_INSTALL_PREFIX="stage3-release" \ 46 -DCMAKE_PREFIX_PATH="$PREFIX" \ 47 -DCMAKE_BUILD_TYPE=Release \ 48 -DZIG_TARGET_TRIPLE="$TARGET" \ 49 -DZIG_TARGET_MCPU="$MCPU" \ 50 -DZIG_STATIC=ON \ 51 -DZIG_NO_LIB=ON \ 52 -GNinja 53 54 # Now cmake will use zig as the C/C++ compiler. We reset the environment variables 55 # so that installation and testing do not get affected by them. 56 unset CC 57 unset CXX 58 59 ninja install 60 61 # TODO: move this to a build.zig step (check-fmt) 62 echo "Looking for non-conforming code formatting..." 63 stage3-release/bin/zig fmt --check .. \ 64 --exclude ../test/cases/ \ 65 --exclude ../build-debug \ 66 --exclude ../build-release 67 68 # simultaneously test building self-hosted without LLVM and with 32-bit arm 69 stage3-release/bin/zig build \ 70 -Dtarget=arm-linux-musleabihf \ 71 -Dno-lib 72 73 stage3-release/bin/zig build test docs \ 74 --maxrss 21000000000 \ 75 -fqemu \ 76 -fwasmtime \ 77 -Dstatic-llvm \ 78 -Dtarget=native-native-musl \ 79 --search-prefix "$PREFIX" \ 80 --zig-lib-dir "$(pwd)/../lib" 81 82 # Look for HTML errors. 83 # TODO: move this to a build.zig flag (-Denable-tidy) 84 tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html" 85 86 # Ensure that stage3 and stage4 are byte-for-byte identical. 87 stage3-release/bin/zig build \ 88 --prefix stage4-release \ 89 -Denable-llvm \ 90 -Dno-lib \ 91 -Doptimize=ReleaseFast \ 92 -Dstrip \ 93 -Dtarget=$TARGET \ 94 -Duse-zig-libcxx \ 95 -Dversion-string="$(stage3-release/bin/zig version)" 96 97 # diff returns an error code if the files differ. 98 echo "If the following command fails, it means nondeterminism has been" 99 echo "introduced, making stage3 and stage4 no longer byte-for-byte identical." 100 diff stage3-release/bin/zig stage4-release/bin/zig 101 102 # Ensure that updating the wasm binary from this commit will result in a viable build. 103 stage3-release/bin/zig build update-zig1 104 105 rm -rf ../build-new 106 mkdir ../build-new 107 cd ../build-new 108 109 export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-global-cache" 110 export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache" 111 export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" 112 export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" 113 114 cmake .. \ 115 -DCMAKE_PREFIX_PATH="$PREFIX" \ 116 -DCMAKE_BUILD_TYPE=Release \ 117 -DZIG_TARGET_TRIPLE="$TARGET" \ 118 -DZIG_TARGET_MCPU="$MCPU" \ 119 -DZIG_STATIC=ON \ 120 -DZIG_NO_LIB=ON \ 121 -GNinja 122 123 unset CC 124 unset CXX 125 126 ninja install 127 128 stage3/bin/zig test ../test/behavior.zig -I../test 129 stage3/bin/zig build -p stage4 \ 130 -Dstatic-llvm \ 131 -Dtarget=native-native-musl \ 132 -Dno-lib \ 133 --search-prefix "$PREFIX" \ 134 --zig-lib-dir "$(pwd)/../lib" 135 stage4/bin/zig test ../test/behavior.zig -I../test