diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7a278e070e82ecff35cd505b46bf326eb2be2556..52b047dc36bab5dff310d07f12dd2098cd870c95 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,16 +15,28 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Build and Test - run: sh ./ci/linux/build-x86_64-debug.sh - - name: Print Version - run: echo "$(build-debug/stage3-debug/bin/zig version)" + run: sh ci/x86_64-linux-debug.sh x86_64-linux-release: runs-on: [self-hosted, Linux, x86_64] steps: - name: Checkout uses: actions/checkout@v3 - name: Build and Test - run: sh ./ci/linux/build-x86_64-release.sh + run: sh ci/x86_64-linux-release.sh + aarch64-linux-debug: + runs-on: [self-hosted, Linux, aarch64] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Build and Test + run: sh ci/aarch64-linux-debug.sh + aarch64-linux-release: + runs-on: [self-hosted, Linux, aarch64] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Build and Test + run: sh ci/aarch64-linux-release.sh x86_64-macos: runs-on: "macos-11" env: @@ -33,23 +45,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Build and Test - run: ./ci/macos/build-x86_64.sh - x86_64-windows: - runs-on: windows-latest - env: - ARCH: "x86_64" - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Build and Test - run: ./ci/windows/build.ps1 - aarch64-linux: - runs-on: [self-hosted, Linux, aarch64] - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Build and Test - run: sh ./ci/linux/build-aarch64.sh + run: ci/x86_64-macos.sh aarch64-macos: runs-on: [self-hosted, macOS, aarch64] env: @@ -58,4 +54,13 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Build and Test - run: ./ci/macos/build-aarch64.sh + run: ci/aarch64-macos.sh + x86_64-windows: + runs-on: windows-latest + env: + ARCH: "x86_64" + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Build and Test + run: ci/x86_64-windows.ps1 diff --git a/ci/aarch64-linux-debug.sh b/ci/aarch64-linux-debug.sh new file mode 100644 index 0000000000000000000000000000000000000000..13bcef5aa9daff7aa4658b5343759ddaeb91b040 --- /dev/null +++ b/ci/aarch64-linux-debug.sh @@ -0,0 +1,66 @@ +#!/bin/sh + +# Requires cmake ninja-build + +set -x +set -e + +ARCH="$(uname -m)" +TARGET="$ARCH-linux-musl" +MCPU="baseline" +CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.256+271cc52a1" +PREFIX="$HOME/deps/$CACHE_BASENAME" +ZIG="$PREFIX/bin/zig" + +export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$PATH" + +# 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 + +export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" +export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" + +rm -rf build-debug +mkdir build-debug +cd build-debug +cmake .. \ + -DCMAKE_INSTALL_PREFIX="stage3-debug" \ + -DCMAKE_PREFIX_PATH="$PREFIX" \ + -DCMAKE_BUILD_TYPE=Debug \ + -DZIG_TARGET_TRIPLE="$TARGET" \ + -DZIG_TARGET_MCPU="$MCPU" \ + -DZIG_STATIC=ON \ + -GNinja + +# 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 + +ninja install + +echo "Looking for non-conforming code formatting..." +stage3-debug/bin/zig fmt --check .. \ + --exclude ../test/cases/ \ + --exclude ../build-debug + +# simultaneously test building self-hosted without LLVM and with 32-bit arm +stage3-debug/bin/zig build -Dtarget=arm-linux-musleabihf + +# TODO: add -fqemu back to this line + +stage3-debug/bin/zig build test docs \ + -fwasmtime \ + -Dstatic-llvm \ + -Dtarget=native-native-musl \ + --search-prefix "$PREFIX" \ + --zig-lib-dir "$(pwd)/../lib" + +# Look for HTML errors. +tidy --drop-empty-elements no -qe ../zig-cache/langref.html + +# Produce the experimental std lib documentation. +stage3-debug/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib diff --git a/ci/aarch64-linux-release.sh b/ci/aarch64-linux-release.sh new file mode 100644 index 0000000000000000000000000000000000000000..07e3d3cf093e0e1a8e4da30712c03336b1fb0418 --- /dev/null +++ b/ci/aarch64-linux-release.sh @@ -0,0 +1,69 @@ +#!/bin/sh + +# Requires cmake ninja-build + +set -x +set -e + +ARCH="$(uname -m)" +TARGET="$ARCH-linux-musl" +MCPU="baseline" +CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.256+271cc52a1" +PREFIX="$HOME/deps/$CACHE_BASENAME" +ZIG="$PREFIX/bin/zig" + +export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$PATH" + +# 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 + +export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" +export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" + +rm -rf build-release +mkdir build-release +cd build-release +cmake .. \ + -DCMAKE_INSTALL_PREFIX="stage3-release" \ + -DCMAKE_PREFIX_PATH="$PREFIX" \ + -DCMAKE_BUILD_TYPE=Release \ + -DZIG_TARGET_TRIPLE="$TARGET" \ + -DZIG_TARGET_MCPU="$MCPU" \ + -DZIG_STATIC=ON \ + -GNinja + +# 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 + +ninja install + +echo "Looking for non-conforming code formatting..." +stage3-release/bin/zig fmt --check .. \ + --exclude ../test/cases/ \ + --exclude ../build-release + +# simultaneously test building self-hosted without LLVM and with 32-bit arm +stage3-release/bin/zig build -Dtarget=arm-linux-musleabihf + +# TODO: add -fqemu back to this line + +stage3-release/bin/zig build test docs \ + -fwasmtime \ + -Dstatic-llvm \ + -Dtarget=native-native-musl \ + --search-prefix "$PREFIX" \ + --zig-lib-dir "$(pwd)/../lib" + +# Look for HTML errors. +tidy --drop-empty-elements no -qe ../zig-cache/langref.html + +# Produce the experimental std lib documentation. +stage3-release/bin/zig test ../lib/std/std.zig \ + -femit-docs \ + -fno-emit-bin \ + --zig-lib-dir "$(pwd)/../lib" diff --git a/ci/aarch64-macos.sh b/ci/aarch64-macos.sh new file mode 100755 index 0000000000000000000000000000000000000000..e8fe795b42350eb79b290e1f4cafe05b519b619c --- /dev/null +++ b/ci/aarch64-macos.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +set -x +set -e + +# Script assumes the presence of the following: +# s3cmd + +ZIGDIR="$(pwd)" +TARGET="$ARCH-macos-none" +MCPU="baseline" +CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.10.0-dev.4560+828735ac0" +PREFIX="$HOME/$CACHE_BASENAME" +ZIG="$PREFIX/bin/zig" + +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 +PATH="$HOME/local/bin:$PATH" cmake .. \ + -DCMAKE_INSTALL_PREFIX="stage3-release" \ + -DCMAKE_PREFIX_PATH="$PREFIX" \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER="$ZIG;cc;-target;$TARGET;-mcpu=$MCPU" \ + -DCMAKE_CXX_COMPILER="$ZIG;c++;-target;$TARGET;-mcpu=$MCPU" \ + -DZIG_TARGET_TRIPLE="$TARGET" \ + -DZIG_TARGET_MCPU="$MCPU" \ + -DZIG_STATIC=ON \ + -GNinja + +$HOME/local/bin/ninja install + +stage3-release/bin/zig build test docs \ + --zig-lib-dir "$(pwd)/../lib" \ + -Denable-macos-sdk \ + -Dstatic-llvm \ + -Dskip-non-native \ + --search-prefix "$PREFIX" + +# Produce the experimental std lib documentation. +mkdir -p "stage3-release/doc/std" +stage3-release/bin/zig test "$(pwd)/../lib/std/std.zig" \ + --zig-lib-dir "$(pwd)/../lib" \ + -femit-docs="$(pwd)/stage3-release/doc/std" \ + -fno-emit-bin diff --git a/ci/linux/build-aarch64.sh b/ci/linux/build-aarch64.sh deleted file mode 100644 index 07e3d3cf093e0e1a8e4da30712c03336b1fb0418..0000000000000000000000000000000000000000 --- a/ci/linux/build-aarch64.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh - -# Requires cmake ninja-build - -set -x -set -e - -ARCH="$(uname -m)" -TARGET="$ARCH-linux-musl" -MCPU="baseline" -CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.256+271cc52a1" -PREFIX="$HOME/deps/$CACHE_BASENAME" -ZIG="$PREFIX/bin/zig" - -export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$PATH" - -# 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 - -export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" -export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" - -rm -rf build-release -mkdir build-release -cd build-release -cmake .. \ - -DCMAKE_INSTALL_PREFIX="stage3-release" \ - -DCMAKE_PREFIX_PATH="$PREFIX" \ - -DCMAKE_BUILD_TYPE=Release \ - -DZIG_TARGET_TRIPLE="$TARGET" \ - -DZIG_TARGET_MCPU="$MCPU" \ - -DZIG_STATIC=ON \ - -GNinja - -# 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 - -ninja install - -echo "Looking for non-conforming code formatting..." -stage3-release/bin/zig fmt --check .. \ - --exclude ../test/cases/ \ - --exclude ../build-release - -# simultaneously test building self-hosted without LLVM and with 32-bit arm -stage3-release/bin/zig build -Dtarget=arm-linux-musleabihf - -# TODO: add -fqemu back to this line - -stage3-release/bin/zig build test docs \ - -fwasmtime \ - -Dstatic-llvm \ - -Dtarget=native-native-musl \ - --search-prefix "$PREFIX" \ - --zig-lib-dir "$(pwd)/../lib" - -# Look for HTML errors. -tidy --drop-empty-elements no -qe ../zig-cache/langref.html - -# Produce the experimental std lib documentation. -stage3-release/bin/zig test ../lib/std/std.zig \ - -femit-docs \ - -fno-emit-bin \ - --zig-lib-dir "$(pwd)/../lib" diff --git a/ci/linux/build-x86_64-debug.sh b/ci/linux/build-x86_64-debug.sh deleted file mode 100755 index b6e98efec275c107a732ff52e590e749346a970f..0000000000000000000000000000000000000000 --- a/ci/linux/build-x86_64-debug.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh - -# Requires cmake ninja-build - -set -x -set -e - -ARCH="$(uname -m)" -TARGET="$ARCH-linux-musl" -MCPU="baseline" -CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.256+271cc52a1" -PREFIX="$HOME/deps/$CACHE_BASENAME" -ZIG="$PREFIX/bin/zig" - -export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$HOME/deps/qemu-linux-x86_64-6.1.0.1/bin:$PATH" - -# 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 - -export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" -export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" - -rm -rf build-debug -mkdir build-debug -cd build-debug -cmake .. \ - -DCMAKE_INSTALL_PREFIX="stage3-debug" \ - -DCMAKE_PREFIX_PATH="$PREFIX" \ - -DCMAKE_BUILD_TYPE=Debug \ - -DZIG_TARGET_TRIPLE="$TARGET" \ - -DZIG_TARGET_MCPU="$MCPU" \ - -DZIG_STATIC=ON \ - -GNinja - -# 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 - -ninja install - -echo "Looking for non-conforming code formatting..." -stage3-debug/bin/zig fmt --check .. \ - --exclude ../test/cases/ \ - --exclude ../build-debug \ - --exclude ../build-release - -# simultaneously test building self-hosted without LLVM and with 32-bit arm -stage3-debug/bin/zig build -Dtarget=arm-linux-musleabihf - -stage3-debug/bin/zig build test docs \ - -fqemu \ - -fwasmtime \ - -Dstatic-llvm \ - -Dtarget=native-native-musl \ - --search-prefix "$PREFIX" \ - --zig-lib-dir "$(pwd)/../lib" - -# Look for HTML errors. -tidy --drop-empty-elements no -qe ../zig-cache/langref.html - -# Produce the experimental std lib documentation. -stage3-debug/bin/zig test ../lib/std/std.zig \ - -femit-docs \ - -fno-emit-bin \ - --zig-lib-dir "$(pwd)/../lib" diff --git a/ci/linux/build-x86_64-release.sh b/ci/linux/build-x86_64-release.sh deleted file mode 100755 index 1155b3c8f7dbb04f51849d9ec41fbbf47a6da58a..0000000000000000000000000000000000000000 --- a/ci/linux/build-x86_64-release.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/sh - -# Requires cmake ninja-build - -set -x -set -e - -ARCH="$(uname -m)" -TARGET="$ARCH-linux-musl" -MCPU="baseline" -CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.256+271cc52a1" -PREFIX="$HOME/deps/$CACHE_BASENAME" -ZIG="$PREFIX/bin/zig" - -export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$HOME/deps/qemu-linux-x86_64-6.1.0.1/bin:$PATH" - -# 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 - -export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" -export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" - -rm -rf build-release -mkdir build-release -cd build-release -cmake .. \ - -DCMAKE_INSTALL_PREFIX="stage3-release" \ - -DCMAKE_PREFIX_PATH="$PREFIX" \ - -DCMAKE_BUILD_TYPE=Release \ - -DZIG_TARGET_TRIPLE="$TARGET" \ - -DZIG_TARGET_MCPU="$MCPU" \ - -DZIG_STATIC=ON \ - -GNinja - -# 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 - -ninja install - -echo "Looking for non-conforming code formatting..." -stage3-release/bin/zig fmt --check .. \ - --exclude ../test/cases/ \ - --exclude ../build-debug \ - --exclude ../build-release - -# simultaneously test building self-hosted without LLVM and with 32-bit arm -stage3-release/bin/zig build -Dtarget=arm-linux-musleabihf - -stage3-release/bin/zig build test docs \ - -fqemu \ - -fwasmtime \ - -Dstatic-llvm \ - -Dtarget=native-native-musl \ - --search-prefix "$PREFIX" \ - --zig-lib-dir "$(pwd)/../lib" - -# Look for HTML errors. -tidy --drop-empty-elements no -qe ../zig-cache/langref.html - -# Produce the experimental std lib documentation. -stage3-release/bin/zig test ../lib/std/std.zig \ - -femit-docs \ - -fno-emit-bin \ - --zig-lib-dir "$(pwd)/../lib" - -stage3-release/bin/zig build \ - --prefix stage4-release \ - -Denable-llvm \ - -Denable-stage1 \ - -Dno-lib \ - -Drelease \ - -Dstrip \ - -Dtarget=$TARGET \ - -Duse-zig-libcxx \ - -Dversion-string="$(stage3-release/bin/zig version)" - -# diff returns an error code if the files differ. -echo "If the following command fails, it means nondeterminism has been" -echo "introduced, making stage3 and stage4 no longer byte-for-byte identical." -diff stage3-release/bin/zig stage4-release/bin/zig diff --git a/ci/macos/build-aarch64.sh b/ci/macos/build-aarch64.sh deleted file mode 100755 index e8fe795b42350eb79b290e1f4cafe05b519b619c..0000000000000000000000000000000000000000 --- a/ci/macos/build-aarch64.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh - -set -x -set -e - -# Script assumes the presence of the following: -# s3cmd - -ZIGDIR="$(pwd)" -TARGET="$ARCH-macos-none" -MCPU="baseline" -CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.10.0-dev.4560+828735ac0" -PREFIX="$HOME/$CACHE_BASENAME" -ZIG="$PREFIX/bin/zig" - -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 -PATH="$HOME/local/bin:$PATH" cmake .. \ - -DCMAKE_INSTALL_PREFIX="stage3-release" \ - -DCMAKE_PREFIX_PATH="$PREFIX" \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_C_COMPILER="$ZIG;cc;-target;$TARGET;-mcpu=$MCPU" \ - -DCMAKE_CXX_COMPILER="$ZIG;c++;-target;$TARGET;-mcpu=$MCPU" \ - -DZIG_TARGET_TRIPLE="$TARGET" \ - -DZIG_TARGET_MCPU="$MCPU" \ - -DZIG_STATIC=ON \ - -GNinja - -$HOME/local/bin/ninja install - -stage3-release/bin/zig build test docs \ - --zig-lib-dir "$(pwd)/../lib" \ - -Denable-macos-sdk \ - -Dstatic-llvm \ - -Dskip-non-native \ - --search-prefix "$PREFIX" - -# Produce the experimental std lib documentation. -mkdir -p "stage3-release/doc/std" -stage3-release/bin/zig test "$(pwd)/../lib/std/std.zig" \ - --zig-lib-dir "$(pwd)/../lib" \ - -femit-docs="$(pwd)/stage3-release/doc/std" \ - -fno-emit-bin diff --git a/ci/macos/build-x86_64.sh b/ci/macos/build-x86_64.sh deleted file mode 100755 index ea19abce45e82db483964fab02c42e9f656482e7..0000000000000000000000000000000000000000 --- a/ci/macos/build-x86_64.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh - -set -x -set -e - -# Script assumes the presence of the following: -# s3cmd - -ZIGDIR="$(pwd)" -TARGET="$ARCH-macos-none" -MCPU="baseline" -CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.10.0-dev.4560+828735ac0" -PREFIX="$HOME/$CACHE_BASENAME" -JOBS="-j3" - -rm -rf $PREFIX -cd $HOME - -curl -L -O "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz" -tar xf "$CACHE_BASENAME.tar.xz" - -ZIG="$PREFIX/bin/zig" - -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="stage3-release" \ - -DCMAKE_PREFIX_PATH="$PREFIX" \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_C_COMPILER="$ZIG;cc;-target;$TARGET;-mcpu=$MCPU" \ - -DCMAKE_CXX_COMPILER="$ZIG;c++;-target;$TARGET;-mcpu=$MCPU" \ - -DZIG_TARGET_TRIPLE="$TARGET" \ - -DZIG_TARGET_MCPU="$MCPU" \ - -DZIG_STATIC=ON - -make $JOBS install - -stage3-release/bin/zig build test docs \ - --zig-lib-dir "$(pwd)/../lib" \ - -Denable-macos-sdk \ - -Dstatic-llvm \ - -Dskip-non-native \ - --search-prefix "$PREFIX" - -# Produce the experimental std lib documentation. -mkdir -p "stage3-release/doc/std" -stage3-release/bin/zig test "$(pwd)/../lib/std/std.zig" \ - --zig-lib-dir "$(pwd)/../lib" \ - -femit-docs="$(pwd)/stage3-release/doc/std" \ - -fno-emit-bin diff --git a/ci/windows/build.ps1 b/ci/windows/build.ps1 deleted file mode 100644 index 358e331683fb3f36a1af212b1706a21298b7afe3..0000000000000000000000000000000000000000 --- a/ci/windows/build.ps1 +++ /dev/null @@ -1,65 +0,0 @@ -$TARGET = "$($Env:ARCH)-windows-gnu" -$ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.11.0-dev.25+499dddb4c" -$ZIG_LLVM_CLANG_LLD_URL = "https://ziglang.org/deps/$ZIG_LLVM_CLANG_LLD_NAME.zip" - -Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL" - -Invoke-WebRequest -Uri "$ZIG_LLVM_CLANG_LLD_URL" -OutFile "$ZIG_LLVM_CLANG_LLD_NAME.zip" - -Write-Output "Extracting..." - -Add-Type -AssemblyName System.IO.Compression.FileSystem ; -[System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD/$ZIG_LLVM_CLANG_LLD_NAME.zip", "$PWD") - -Set-Variable -Name ZIGLIBDIR -Value "$(Get-Location)\lib" -Set-Variable -Name ZIGINSTALLDIR -Value "$(Get-Location)\stage3-release" -Set-Variable -Name ZIGPREFIXPATH -Value "$(Get-Location)\$ZIG_LLVM_CLANG_LLD_NAME" - -function CheckLastExitCode { - if (!$?) { - exit 1 - } - return 0 -} - -# Make the `zig version` number consistent. -# This will affect the `zig build` command below which uses `git describe`. -git config core.abbrev 9 -git fetch --tags - -if ((git rev-parse --is-shallow-repository) -eq "true") { - git fetch --unshallow # `git describe` won't work on a shallow repo -} - -Write-Output "Building Zig..." - -& "$ZIGPREFIXPATH\bin\zig.exe" build ` - --prefix "$ZIGINSTALLDIR" ` - --search-prefix "$ZIGPREFIXPATH" ` - --zig-lib-dir "$ZIGLIBDIR" ` - -Denable-stage1 ` - -Dstatic-llvm ` - -Drelease ` - -Duse-zig-libcxx ` - -Dtarget="$TARGET" -CheckLastExitCode - -Write-Output " zig build test docs..." - -& "$ZIGINSTALLDIR\bin\zig.exe" build test docs ` - --search-prefix "$ZIGPREFIXPATH" ` - -Dstatic-llvm ` - -Dskip-non-native ` - -Denable-symlinks-windows -CheckLastExitCode - -# Produce the experimental std lib documentation. -mkdir "$ZIGINSTALLDIR\doc\std" -force - -Write-Output "zig test std/std.zig..." - -& "$ZIGINSTALLDIR\bin\zig.exe" test "$ZIGLIBDIR\std\std.zig" ` - --zig-lib-dir "$ZIGLIBDIR" ` - -femit-docs="$ZIGINSTALLDIR\doc\std" ` - -fno-emit-bin -CheckLastExitCode diff --git a/ci/x86_64-linux-debug.sh b/ci/x86_64-linux-debug.sh new file mode 100755 index 0000000000000000000000000000000000000000..84529ab4719d9ad3b7f5046369f37e7942f23bb3 --- /dev/null +++ b/ci/x86_64-linux-debug.sh @@ -0,0 +1,68 @@ +#!/bin/sh + +# Requires cmake ninja-build + +set -x +set -e + +ARCH="$(uname -m)" +TARGET="$ARCH-linux-musl" +MCPU="baseline" +CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.256+271cc52a1" +PREFIX="$HOME/deps/$CACHE_BASENAME" +ZIG="$PREFIX/bin/zig" + +export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$HOME/deps/qemu-linux-x86_64-6.1.0.1/bin:$PATH" + +# 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 + +export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" +export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" + +rm -rf build-debug +mkdir build-debug +cd build-debug +cmake .. \ + -DCMAKE_INSTALL_PREFIX="stage3-debug" \ + -DCMAKE_PREFIX_PATH="$PREFIX" \ + -DCMAKE_BUILD_TYPE=Debug \ + -DZIG_TARGET_TRIPLE="$TARGET" \ + -DZIG_TARGET_MCPU="$MCPU" \ + -DZIG_STATIC=ON \ + -GNinja + +# 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 + +ninja install + +echo "Looking for non-conforming code formatting..." +stage3-debug/bin/zig fmt --check .. \ + --exclude ../test/cases/ \ + --exclude ../build-debug + +# simultaneously test building self-hosted without LLVM and with 32-bit arm +stage3-debug/bin/zig build -Dtarget=arm-linux-musleabihf + +stage3-debug/bin/zig build test docs \ + -fqemu \ + -fwasmtime \ + -Dstatic-llvm \ + -Dtarget=native-native-musl \ + --search-prefix "$PREFIX" \ + --zig-lib-dir "$(pwd)/../lib" + +# Look for HTML errors. +tidy --drop-empty-elements no -qe ../zig-cache/langref.html + +# Produce the experimental std lib documentation. +stage3-debug/bin/zig test ../lib/std/std.zig \ + -femit-docs \ + -fno-emit-bin \ + --zig-lib-dir "$(pwd)/../lib" diff --git a/ci/x86_64-linux-release.sh b/ci/x86_64-linux-release.sh new file mode 100755 index 0000000000000000000000000000000000000000..1155b3c8f7dbb04f51849d9ec41fbbf47a6da58a --- /dev/null +++ b/ci/x86_64-linux-release.sh @@ -0,0 +1,85 @@ +#!/bin/sh + +# Requires cmake ninja-build + +set -x +set -e + +ARCH="$(uname -m)" +TARGET="$ARCH-linux-musl" +MCPU="baseline" +CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.256+271cc52a1" +PREFIX="$HOME/deps/$CACHE_BASENAME" +ZIG="$PREFIX/bin/zig" + +export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$HOME/deps/qemu-linux-x86_64-6.1.0.1/bin:$PATH" + +# 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 + +export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" +export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" + +rm -rf build-release +mkdir build-release +cd build-release +cmake .. \ + -DCMAKE_INSTALL_PREFIX="stage3-release" \ + -DCMAKE_PREFIX_PATH="$PREFIX" \ + -DCMAKE_BUILD_TYPE=Release \ + -DZIG_TARGET_TRIPLE="$TARGET" \ + -DZIG_TARGET_MCPU="$MCPU" \ + -DZIG_STATIC=ON \ + -GNinja + +# 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 + +ninja install + +echo "Looking for non-conforming code formatting..." +stage3-release/bin/zig fmt --check .. \ + --exclude ../test/cases/ \ + --exclude ../build-debug \ + --exclude ../build-release + +# simultaneously test building self-hosted without LLVM and with 32-bit arm +stage3-release/bin/zig build -Dtarget=arm-linux-musleabihf + +stage3-release/bin/zig build test docs \ + -fqemu \ + -fwasmtime \ + -Dstatic-llvm \ + -Dtarget=native-native-musl \ + --search-prefix "$PREFIX" \ + --zig-lib-dir "$(pwd)/../lib" + +# Look for HTML errors. +tidy --drop-empty-elements no -qe ../zig-cache/langref.html + +# Produce the experimental std lib documentation. +stage3-release/bin/zig test ../lib/std/std.zig \ + -femit-docs \ + -fno-emit-bin \ + --zig-lib-dir "$(pwd)/../lib" + +stage3-release/bin/zig build \ + --prefix stage4-release \ + -Denable-llvm \ + -Denable-stage1 \ + -Dno-lib \ + -Drelease \ + -Dstrip \ + -Dtarget=$TARGET \ + -Duse-zig-libcxx \ + -Dversion-string="$(stage3-release/bin/zig version)" + +# diff returns an error code if the files differ. +echo "If the following command fails, it means nondeterminism has been" +echo "introduced, making stage3 and stage4 no longer byte-for-byte identical." +diff stage3-release/bin/zig stage4-release/bin/zig diff --git a/ci/x86_64-macos.sh b/ci/x86_64-macos.sh new file mode 100755 index 0000000000000000000000000000000000000000..ea19abce45e82db483964fab02c42e9f656482e7 --- /dev/null +++ b/ci/x86_64-macos.sh @@ -0,0 +1,58 @@ +#!/bin/sh + +set -x +set -e + +# Script assumes the presence of the following: +# s3cmd + +ZIGDIR="$(pwd)" +TARGET="$ARCH-macos-none" +MCPU="baseline" +CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.10.0-dev.4560+828735ac0" +PREFIX="$HOME/$CACHE_BASENAME" +JOBS="-j3" + +rm -rf $PREFIX +cd $HOME + +curl -L -O "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz" +tar xf "$CACHE_BASENAME.tar.xz" + +ZIG="$PREFIX/bin/zig" + +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="stage3-release" \ + -DCMAKE_PREFIX_PATH="$PREFIX" \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER="$ZIG;cc;-target;$TARGET;-mcpu=$MCPU" \ + -DCMAKE_CXX_COMPILER="$ZIG;c++;-target;$TARGET;-mcpu=$MCPU" \ + -DZIG_TARGET_TRIPLE="$TARGET" \ + -DZIG_TARGET_MCPU="$MCPU" \ + -DZIG_STATIC=ON + +make $JOBS install + +stage3-release/bin/zig build test docs \ + --zig-lib-dir "$(pwd)/../lib" \ + -Denable-macos-sdk \ + -Dstatic-llvm \ + -Dskip-non-native \ + --search-prefix "$PREFIX" + +# Produce the experimental std lib documentation. +mkdir -p "stage3-release/doc/std" +stage3-release/bin/zig test "$(pwd)/../lib/std/std.zig" \ + --zig-lib-dir "$(pwd)/../lib" \ + -femit-docs="$(pwd)/stage3-release/doc/std" \ + -fno-emit-bin diff --git a/ci/x86_64-windows.ps1 b/ci/x86_64-windows.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..358e331683fb3f36a1af212b1706a21298b7afe3 --- /dev/null +++ b/ci/x86_64-windows.ps1 @@ -0,0 +1,65 @@ +$TARGET = "$($Env:ARCH)-windows-gnu" +$ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.11.0-dev.25+499dddb4c" +$ZIG_LLVM_CLANG_LLD_URL = "https://ziglang.org/deps/$ZIG_LLVM_CLANG_LLD_NAME.zip" + +Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL" + +Invoke-WebRequest -Uri "$ZIG_LLVM_CLANG_LLD_URL" -OutFile "$ZIG_LLVM_CLANG_LLD_NAME.zip" + +Write-Output "Extracting..." + +Add-Type -AssemblyName System.IO.Compression.FileSystem ; +[System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD/$ZIG_LLVM_CLANG_LLD_NAME.zip", "$PWD") + +Set-Variable -Name ZIGLIBDIR -Value "$(Get-Location)\lib" +Set-Variable -Name ZIGINSTALLDIR -Value "$(Get-Location)\stage3-release" +Set-Variable -Name ZIGPREFIXPATH -Value "$(Get-Location)\$ZIG_LLVM_CLANG_LLD_NAME" + +function CheckLastExitCode { + if (!$?) { + exit 1 + } + return 0 +} + +# Make the `zig version` number consistent. +# This will affect the `zig build` command below which uses `git describe`. +git config core.abbrev 9 +git fetch --tags + +if ((git rev-parse --is-shallow-repository) -eq "true") { + git fetch --unshallow # `git describe` won't work on a shallow repo +} + +Write-Output "Building Zig..." + +& "$ZIGPREFIXPATH\bin\zig.exe" build ` + --prefix "$ZIGINSTALLDIR" ` + --search-prefix "$ZIGPREFIXPATH" ` + --zig-lib-dir "$ZIGLIBDIR" ` + -Denable-stage1 ` + -Dstatic-llvm ` + -Drelease ` + -Duse-zig-libcxx ` + -Dtarget="$TARGET" +CheckLastExitCode + +Write-Output " zig build test docs..." + +& "$ZIGINSTALLDIR\bin\zig.exe" build test docs ` + --search-prefix "$ZIGPREFIXPATH" ` + -Dstatic-llvm ` + -Dskip-non-native ` + -Denable-symlinks-windows +CheckLastExitCode + +# Produce the experimental std lib documentation. +mkdir "$ZIGINSTALLDIR\doc\std" -force + +Write-Output "zig test std/std.zig..." + +& "$ZIGINSTALLDIR\bin\zig.exe" test "$ZIGLIBDIR\std\std.zig" ` + --zig-lib-dir "$ZIGLIBDIR" ` + -femit-docs="$ZIGINSTALLDIR\doc\std" ` + -fno-emit-bin +CheckLastExitCode diff --git a/doc/langref.html.in b/doc/langref.html.in index 1a7ef8f5638a92dc5616c9b394cc05f1dbc102ec..bd81484d6f13f7c25d99f94512d6897d299b02b1 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -7029,8 +7029,7 @@ test "fibonacci" { undefined behavior, which is always a compile error if the compiler knows it happened. But what would have happened if we used a signed integer?
- {#code_begin|test_err|evaluation exceeded 1000 backwards branches#} - {#backend_stage1#} + {#code_begin|syntax#} const assert = @import("std").debug.assert; fn fibonacci(index: i32) i32 { @@ -7045,13 +7044,22 @@ test "fibonacci" { } {#code_end#}- The compiler noticed that evaluating this function at compile-time took a long time, - and thus emitted a compile error and gave up. If the programmer wants to increase - the budget for compile-time computation, they can use a built-in function called - {#link|@setEvalBranchQuota#} to change the default number 1000 to something else. + The compiler is supposed to notice that evaluating this function at + compile-time took more than 1000 branches, and thus emits an error and + gives up. If the programmer wants to increase the budget for compile-time + computation, they can use a built-in function called + {#link|@setEvalBranchQuota#} to change the default number 1000 to + something else.
- What if we fix the base case, but put the wrong value in the {#syntax#}expect{#endsyntax#} line? + However, there is a design + flaw in the compiler causing it to stack overflow instead of having the proper + behavior here. I'm terribly sorry about that. I hope to get this resolved + before the next release. +
++ What if we fix the base case, but put the wrong value in the + {#syntax#}expect{#endsyntax#} line?
{#code_begin|test_err|reached unreachable#} const assert = @import("std").debug.assert;