mirror of
https://github.com/ziglang/zig.git
synced 2025-12-27 08:33:15 +00:00
Azure is hitting OOM on test-toolchain. This commit is trying to coast for another week until we switch to Drone CI for this job.
143 lines
5.0 KiB
Bash
Executable File
143 lines
5.0 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -x
|
|
set -e
|
|
|
|
sudo apt-get update -q
|
|
sudo apt-get install -y cmake s3cmd tidy
|
|
|
|
ZIGDIR="$(pwd)"
|
|
ARCH="$(uname -m)"
|
|
TARGET="$ARCH-linux-musl"
|
|
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.8.1-dev.94+535615117"
|
|
PREFIX="$HOME/$CACHE_BASENAME"
|
|
MCPU="baseline"
|
|
JOBS="-j$(nproc)"
|
|
|
|
rm -rf $PREFIX
|
|
cd $HOME
|
|
|
|
wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
|
|
tar xf "$CACHE_BASENAME.tar.xz"
|
|
|
|
QEMUBASE="qemu-linux-x86_64-6.1.0.1"
|
|
wget -nv "https://ziglang.org/deps/$QEMUBASE.tar.xz"
|
|
tar xf "$QEMUBASE.tar.xz"
|
|
export PATH="$(pwd)/$QEMUBASE/bin:$PATH"
|
|
|
|
WASMTIME="wasmtime-v0.26.1-x86_64-linux"
|
|
wget -nv "https://github.com/bytecodealliance/wasmtime/releases/download/v0.26.1/$WASMTIME.tar.xz"
|
|
tar xf "$WASMTIME.tar.xz"
|
|
export PATH="$(pwd)/$WASMTIME:$PATH"
|
|
|
|
ZIG="$PREFIX/bin/zig"
|
|
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
|
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
|
|
|
cd $ZIGDIR
|
|
|
|
# Make the `zig version` number consistent.
|
|
# This will affect the cmake command below.
|
|
git config core.abbrev 9
|
|
git fetch --unshallow || true
|
|
git fetch --tags
|
|
|
|
mkdir build
|
|
cd build
|
|
cmake .. \
|
|
-DCMAKE_INSTALL_PREFIX="$(pwd)/release" \
|
|
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DZIG_TARGET_TRIPLE="$TARGET" \
|
|
-DZIG_TARGET_MCPU="$MCPU" \
|
|
-DZIG_STATIC=ON
|
|
|
|
# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
|
|
# so that installation and testing do not get affected by them.
|
|
unset CC
|
|
unset CXX
|
|
|
|
make $JOBS install
|
|
|
|
# Look for non-conforming code formatting.
|
|
# Formatting errors can be fixed by running `zig fmt` on the files printed here.
|
|
release/bin/zig fmt --check ..
|
|
|
|
# Here we rebuild zig but this time using the Zig binary we just now produced to
|
|
# build zig1.o rather than relying on the one built with stage0. See
|
|
# https://github.com/ziglang/zig/issues/6830 for more details.
|
|
cmake .. -DZIG_EXECUTABLE="$(pwd)/release/bin/zig"
|
|
make $JOBS install
|
|
|
|
release/bin/zig test ../test/behavior.zig -fno-stage1 -fLLVM -I ../test
|
|
|
|
release/bin/zig build test-behavior -Denable-qemu -Denable-wasmtime
|
|
release/bin/zig build test-compiler-rt -Denable-qemu -Denable-wasmtime
|
|
release/bin/zig build test-std -Denable-qemu -Denable-wasmtime
|
|
release/bin/zig build test-minilibc -Denable-qemu -Denable-wasmtime
|
|
release/bin/zig build test-test-compare-output -Denable-qemu -Denable-wasmtime
|
|
release/bin/zig build test-standalone -Denable-qemu -Denable-wasmtime
|
|
release/bin/zig build test-stack-traces -Denable-qemu -Denable-wasmtime
|
|
release/bin/zig build test-cli -Denable-qemu -Denable-wasmtime
|
|
release/bin/zig build test-asm-link -Denable-qemu -Denable-wasmtime
|
|
release/bin/zig build test-runtime-safety -Denable-qemu -Denable-wasmtime
|
|
release/bin/zig build test-translate-c -Denable-qemu -Denable-wasmtime
|
|
release/bin/zig build test-run-translated-c -Denable-qemu -Denable-wasmtime
|
|
release/bin/zig build docs -Denable-qemu -Denable-wasmtime
|
|
release/bin/zig build # test building self-hosted without LLVM
|
|
release/bin/zig build test-fmt -Denable-qemu -Denable-wasmtime
|
|
release/bin/zig build test-stage2 -Denable-qemu -Denable-wasmtime
|
|
|
|
# Look for HTML errors.
|
|
tidy -qe ../zig-cache/langref.html
|
|
|
|
if [ "${BUILD_REASON}" != "PullRequest" ]; then
|
|
# Produce the experimental std lib documentation.
|
|
mkdir -p release/docs/std
|
|
release/bin/zig test ../lib/std/std.zig \
|
|
--zig-lib-dir ../lib \
|
|
-femit-docs=release/docs/std \
|
|
-fno-emit-bin
|
|
|
|
mv ../LICENSE release/
|
|
mv ../zig-cache/langref.html release/docs/
|
|
|
|
# Remove the unnecessary bin dir in $prefix/bin/zig
|
|
mv release/bin/zig release/
|
|
rmdir release/bin
|
|
|
|
# Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig
|
|
mv release/lib/zig release/lib2
|
|
rmdir release/lib
|
|
mv release/lib2 release/lib
|
|
|
|
VERSION=$(release/zig version)
|
|
DIRNAME="zig-linux-$ARCH-$VERSION"
|
|
TARBALL="$DIRNAME.tar.xz"
|
|
mv release "$DIRNAME"
|
|
tar cfJ "$TARBALL" "$DIRNAME"
|
|
|
|
mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg"
|
|
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
|
|
|
|
SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1)
|
|
BYTESIZE=$(wc -c < $TARBALL)
|
|
|
|
JSONFILE="linux-$GITBRANCH.json"
|
|
touch $JSONFILE
|
|
echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
|
|
echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
|
|
echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
|
|
|
|
s3cmd put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE"
|
|
s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/$ARCH-linux-$VERSION.json"
|
|
|
|
# `set -x` causes these variables to be mangled.
|
|
# See https://developercommunity.visualstudio.com/content/problem/375679/pipeline-variable-incorrectly-inserts-single-quote.html
|
|
set +x
|
|
echo "##vso[task.setvariable variable=tarball;isOutput=true]$TARBALL"
|
|
echo "##vso[task.setvariable variable=shasum;isOutput=true]$SHASUM"
|
|
echo "##vso[task.setvariable variable=bytesize;isOutput=true]$BYTESIZE"
|
|
echo "##vso[task.setvariable variable=version;isOutput=true]$VERSION"
|
|
fi
|