| author | |
| committer | |
| log | 373a4990a4cc5ab04e33620c3b624d18ea1896a9 |
| tree | 892954a97033d5585532b4d66c42b669f492b0a5 |
| parent | a57479afc2cea1b7c2c6802b7e8a1a7db973a3a3 |
19 files changed, 1172 insertions(+), 977 deletions(-)
.github/workflows/ci.yaml+122-33| ... | @@ -4,95 +4,184 @@ on: | ... | @@ -4,95 +4,184 @@ on: |
| 4 | push: | 4 | push: |
| 5 | branches: | 5 | branches: |
| 6 | - master | 6 | - master |
| 7 | - llvm18 | 7 | - ci-scripts |
| 8 | concurrency: | 8 | env: |
| 9 | # Cancels pending runs when a PR gets updated. | 9 | ci-zig-version: 0.13.0-dev.76+dee9f82f6 |
| 10 | group: ${{ github.head_ref || github.run_id }}-${{ github.actor }} | ||
| 11 | cancel-in-progress: true | ||
| 12 | jobs: | 10 | jobs: |
| 13 | x86_64-linux-debug: | 11 | x86_64-linux-debug: |
| 14 | timeout-minutes: 420 | 12 | if: github.repository_owner == 'ziglang' |
| 15 | runs-on: [self-hosted, Linux, x86_64] | 13 | runs-on: [self-hosted, Linux, x86_64] |
| 16 | steps: | 14 | steps: |
| 17 | - name: Checkout | 15 | - name: Checkout |
| 18 | uses: actions/checkout@v4 | 16 | uses: actions/checkout@v4 |
| 17 | with: | ||
| 18 | fetch-depth: 0 | ||
| 19 | - name: Build and Test | 19 | - name: Build and Test |
| 20 | run: sh ci/x86_64-linux-debug.sh | 20 | working-directory: ci |
| 21 | run: ~/deps/zig-x86_64-linux-musl-${{env.ci-zig-version}}/bin/zig build --maxrss 21000000000 -Dbuild-type=Debug -Dextra-target=arm-linux-musleabihf test-cmake-bootstrap update-stage1 | ||
| 21 | x86_64-linux-release: | 22 | x86_64-linux-release: |
| 22 | timeout-minutes: 420 | 23 | if: github.repository_owner == 'ziglang' |
| 23 | runs-on: [self-hosted, Linux, x86_64] | 24 | runs-on: [self-hosted, Linux, x86_64] |
| 24 | steps: | 25 | steps: |
| 25 | - name: Checkout | 26 | - name: Checkout |
| 26 | uses: actions/checkout@v4 | 27 | uses: actions/checkout@v4 |
| 28 | with: | ||
| 29 | fetch-depth: 0 | ||
| 27 | - name: Build and Test | 30 | - name: Build and Test |
| 28 | run: sh ci/x86_64-linux-release.sh | 31 | working-directory: ci |
| 32 | run: ~/deps/zig-x86_64-linux-musl-${{env.ci-zig-version}}/bin/zig build --maxrss 21000000000 -Dbuild-type=Release -Dextra-target=arm-linux-musleabihf -Dcc=cc test-cc-bootstrap test-cmake-bootstrap reproducible update-stage1 | ||
| 29 | aarch64-linux-debug: | 33 | aarch64-linux-debug: |
| 30 | timeout-minutes: 480 | 34 | if: github.repository_owner == 'ziglang' |
| 31 | runs-on: [self-hosted, Linux, aarch64] | 35 | runs-on: [self-hosted, Linux, aarch64] |
| 32 | steps: | 36 | steps: |
| 33 | - name: Checkout | 37 | - name: Checkout |
| 34 | uses: actions/checkout@v4 | 38 | uses: actions/checkout@v4 |
| 39 | with: | ||
| 40 | fetch-depth: 0 | ||
| 35 | - name: Build and Test | 41 | - name: Build and Test |
| 36 | run: sh ci/aarch64-linux-debug.sh | 42 | working-directory: ci |
| 43 | run: ~/deps/zig-aarch64-linux-musl-${{env.ci-zig-version}}/bin/zig build --maxrss 24696061952 -Dbuild-type=Debug -Dextra-target=arm-linux-musleabihf test-cmake-bootstrap update-stage1 | ||
| 37 | aarch64-linux-release: | 44 | aarch64-linux-release: |
| 38 | timeout-minutes: 480 | 45 | if: github.repository_owner == 'ziglang' |
| 39 | runs-on: [self-hosted, Linux, aarch64] | 46 | runs-on: [self-hosted, Linux, aarch64] |
| 40 | steps: | 47 | steps: |
| 41 | - name: Checkout | 48 | - name: Checkout |
| 42 | uses: actions/checkout@v4 | 49 | uses: actions/checkout@v4 |
| 50 | with: | ||
| 51 | fetch-depth: 0 | ||
| 43 | - name: Build and Test | 52 | - name: Build and Test |
| 44 | run: sh ci/aarch64-linux-release.sh | 53 | working-directory: ci |
| 54 | run: ~/deps/zig-aarch64-linux-musl-${{env.ci-zig-version}}/bin/zig build --maxrss 24696061952 -Dbuild-type=Release -Dextra-target=arm-linux-musleabihf test-cmake-bootstrap reproducible update-stage1 | ||
| 55 | x86_64-macos-debug: | ||
| 56 | if: github.repository_owner == 'ziglang' | ||
| 57 | runs-on: macos-12 | ||
| 58 | steps: | ||
| 59 | - name: Restore Zig Cache | ||
| 60 | id: zig-cache | ||
| 61 | uses: actions/cache/restore@v4 | ||
| 62 | with: | ||
| 63 | path: ~/deps/zig-x86_64-macos-none-${{env.ci-zig-version}} | ||
| 64 | key: zig-x86_64-macos-none-${{env.ci-zig-version}} | ||
| 65 | - name: Download Zig | ||
| 66 | if: steps.zig-cache.outputs.cache-hit != 'true' | ||
| 67 | run: 'mkdir -p ~/deps && curl https://jacobly.com/deps/zig-x86_64-macos-none-${{env.ci-zig-version}}.tar.xz | tar xJ -C ~/deps' | ||
| 68 | - name: Save Zig Cache | ||
| 69 | if: steps.zig-cache.outputs.cache-hit != 'true' | ||
| 70 | uses: actions/cache/save@v4 | ||
| 71 | with: | ||
| 72 | path: ~/deps/zig-x86_64-macos-none-${{env.ci-zig-version}} | ||
| 73 | key: ${{steps.zig-cache.outputs.cache-primary-key}} | ||
| 74 | - name: Checkout | ||
| 75 | uses: actions/checkout@v4 | ||
| 76 | with: | ||
| 77 | fetch-depth: 0 | ||
| 78 | - name: Restore Package Cache | ||
| 79 | id: package-cache | ||
| 80 | uses: actions/cache/restore@v4 | ||
| 81 | with: | ||
| 82 | path: ~/.cache/zig | ||
| 83 | key: x86_64-macos-package-${{hashFiles('ci/build.zig.zon')}} | ||
| 84 | restore-keys: x86_64-macos-package- | ||
| 85 | - name: Build and Test | ||
| 86 | working-directory: ci | ||
| 87 | run: ~/deps/zig-x86_64-macos-none-${{env.ci-zig-version}}/bin/zig build -Dbuild-type=Debug -Dskip-non-native test-cmake-bootstrap update-stage1 | ||
| 88 | - name: Save Package Cache | ||
| 89 | if: steps.package-cache.outputs.cache-hit != 'true' | ||
| 90 | uses: actions/cache/save@v4 | ||
| 91 | with: | ||
| 92 | path: ~/.cache/zig | ||
| 93 | key: ${{steps.package-cache.outputs.cache-primary-key}} | ||
| 45 | x86_64-macos-release: | 94 | x86_64-macos-release: |
| 46 | runs-on: "macos-12" | 95 | if: github.repository_owner == 'ziglang' |
| 47 | env: | 96 | runs-on: macos-12 |
| 48 | ARCH: "x86_64" | ||
| 49 | steps: | 97 | steps: |
| 98 | - name: Restore Zig Cache | ||
| 99 | id: zig-cache | ||
| 100 | uses: actions/cache/restore@v4 | ||
| 101 | with: | ||
| 102 | path: ~/deps/zig-x86_64-macos-none-${{env.ci-zig-version}} | ||
| 103 | key: zig-x86_64-macos-none-${{env.ci-zig-version}} | ||
| 104 | - name: Download Zig | ||
| 105 | if: steps.zig-cache.outputs.cache-hit != 'true' | ||
| 106 | run: 'mkdir -p ~/deps && curl https://jacobly.com/deps/zig-x86_64-macos-none-${{env.ci-zig-version}}.tar.xz | tar xJ -C ~/deps' | ||
| 107 | - name: Save Zig Cache | ||
| 108 | if: steps.zig-cache.outputs.cache-hit != 'true' | ||
| 109 | uses: actions/cache/save@v4 | ||
| 110 | with: | ||
| 111 | path: ~/deps/zig-x86_64-macos-none-${{env.ci-zig-version}} | ||
| 112 | key: ${{steps.zig-cache.outputs.cache-primary-key}} | ||
| 50 | - name: Checkout | 113 | - name: Checkout |
| 51 | uses: actions/checkout@v4 | 114 | uses: actions/checkout@v4 |
| 115 | with: | ||
| 116 | fetch-depth: 0 | ||
| 117 | - name: Restore Package Cache | ||
| 118 | id: package-cache | ||
| 119 | uses: actions/cache/restore@v4 | ||
| 120 | with: | ||
| 121 | path: ~/.cache/zig | ||
| 122 | key: x86_64-macos-package-${{hashFiles('ci/build.zig.zon')}} | ||
| 123 | restore-keys: x86_64-macos-package- | ||
| 52 | - name: Build and Test | 124 | - name: Build and Test |
| 53 | run: ci/x86_64-macos-release.sh | 125 | working-directory: ci |
| 126 | run: ~/deps/zig-x86_64-macos-none-${{env.ci-zig-version}}/bin/zig build -Dbuild-type=Release -Dcc=cc -Dskip-non-native test-cc-bootstrap test-cmake-bootstrap reproducible update-stage1 | ||
| 127 | - name: Save Package Cache | ||
| 128 | if: steps.package-cache.outputs.cache-hit != 'true' | ||
| 129 | uses: actions/cache/save@v4 | ||
| 130 | with: | ||
| 131 | path: ~/.cache/zig | ||
| 132 | key: ${{steps.package-cache.outputs.cache-primary-key}} | ||
| 54 | aarch64-macos-debug: | 133 | aarch64-macos-debug: |
| 134 | if: github.repository_owner == 'ziglang' | ||
| 55 | runs-on: [self-hosted, macOS, aarch64] | 135 | runs-on: [self-hosted, macOS, aarch64] |
| 56 | env: | ||
| 57 | ARCH: "aarch64" | ||
| 58 | steps: | 136 | steps: |
| 59 | - name: Checkout | 137 | - name: Checkout |
| 60 | uses: actions/checkout@v4 | 138 | uses: actions/checkout@v4 |
| 139 | with: | ||
| 140 | fetch-depth: 0 | ||
| 61 | - name: Build and Test | 141 | - name: Build and Test |
| 62 | run: ci/aarch64-macos-debug.sh | 142 | working-directory: ci |
| 143 | run: ~/deps/zig-aarch64-macos-none-${{env.ci-zig-version}}/bin/zig build -Dbuild-type=Debug -Dskip-non-native test-cmake-bootstrap update-stage1 | ||
| 63 | aarch64-macos-release: | 144 | aarch64-macos-release: |
| 145 | if: github.repository_owner == 'ziglang' | ||
| 64 | runs-on: [self-hosted, macOS, aarch64] | 146 | runs-on: [self-hosted, macOS, aarch64] |
| 65 | env: | ||
| 66 | ARCH: "aarch64" | ||
| 67 | steps: | 147 | steps: |
| 68 | - name: Checkout | 148 | - name: Checkout |
| 69 | uses: actions/checkout@v4 | 149 | uses: actions/checkout@v4 |
| 150 | with: | ||
| 151 | fetch-depth: 0 | ||
| 70 | - name: Build and Test | 152 | - name: Build and Test |
| 71 | run: ci/aarch64-macos-release.sh | 153 | working-directory: ci |
| 154 | run: ~/deps/zig-aarch64-macos-none-${{env.ci-zig-version}}/bin/zig build -Dbuild-type=Release -Dskip-non-native test-cmake-bootstrap reproducible update-stage1 | ||
| 72 | x86_64-windows-debug: | 155 | x86_64-windows-debug: |
| 156 | if: github.repository_owner == 'ziglang' | ||
| 73 | runs-on: [self-hosted, Windows, x86_64] | 157 | runs-on: [self-hosted, Windows, x86_64] |
| 74 | env: | ||
| 75 | ARCH: "x86_64" | ||
| 76 | steps: | 158 | steps: |
| 77 | - name: Checkout | 159 | - name: Checkout |
| 78 | uses: actions/checkout@v4 | 160 | uses: actions/checkout@v4 |
| 161 | with: | ||
| 162 | fetch-depth: 0 | ||
| 79 | - name: Build and Test | 163 | - name: Build and Test |
| 80 | run: ci/x86_64-windows-debug.ps1 | 164 | working-directory: ci |
| 165 | run: '& $Env:USERPROFILE\deps\zig-x86_64-windows-gnu-${{env.ci-zig-version}}\bin\zig.exe build -Dbuild-type=Debug -Dskip-non-native test-cmake-bootstrap update-stage1 msvc' | ||
| 81 | x86_64-windows-release: | 166 | x86_64-windows-release: |
| 167 | if: github.repository_owner == 'ziglang' | ||
| 82 | runs-on: [self-hosted, Windows, x86_64] | 168 | runs-on: [self-hosted, Windows, x86_64] |
| 83 | env: | ||
| 84 | ARCH: "x86_64" | ||
| 85 | steps: | 169 | steps: |
| 86 | - name: Checkout | 170 | - name: Checkout |
| 87 | uses: actions/checkout@v4 | 171 | uses: actions/checkout@v4 |
| 172 | with: | ||
| 173 | fetch-depth: 0 | ||
| 88 | - name: Build and Test | 174 | - name: Build and Test |
| 89 | run: ci/x86_64-windows-release.ps1 | 175 | working-directory: ci |
| 90 | aarch64-windows: | 176 | run: '& $Env:USERPROFILE\deps\zig-x86_64-windows-gnu-${{env.ci-zig-version}}\bin\zig.exe build -Dbuild-type=Release -Dskip-non-native test-cmake-bootstrap update-stage1 msvc' # reproducible |
| 177 | aarch64-windows-release: | ||
| 178 | if: github.repository_owner == 'ziglang' | ||
| 91 | runs-on: [self-hosted, Windows, aarch64] | 179 | runs-on: [self-hosted, Windows, aarch64] |
| 92 | env: | ||
| 93 | ARCH: "aarch64" | ||
| 94 | steps: | 180 | steps: |
| 95 | - name: Checkout | 181 | - name: Checkout |
| 96 | uses: actions/checkout@v4 | 182 | uses: actions/checkout@v4 |
| 183 | with: | ||
| 184 | fetch-depth: 0 | ||
| 97 | - name: Build and Test | 185 | - name: Build and Test |
| 98 | run: ci/aarch64-windows.ps1 | 186 | working-directory: ci |
| 187 | run: '& $Env:USERPROFILE\deps\zig-aarch64-windows-gnu-${{env.ci-zig-version}}\bin\zig.exe build -Dbuild-type=Release -Dskip-non-native test-cmake-bootstrap' # reproducible |
CMakeLists.txt+4-2| ... | @@ -944,10 +944,12 @@ set(ZIG_BUILD_ARGS | ... | @@ -944,10 +944,12 @@ set(ZIG_BUILD_ARGS |
| 944 | 944 | ||
| 945 | if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") | 945 | if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") |
| 946 | list(APPEND ZIG_BUILD_ARGS -Doptimize=Debug) | 946 | list(APPEND ZIG_BUILD_ARGS -Doptimize=Debug) |
| 947 | elseif("${CMAKE_BUILD_TYPE}" STREQUAL "Release") | ||
| 948 | list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseFast -Dstrip) | ||
| 947 | elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo") | 949 | elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo") |
| 948 | list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseFast) | 950 | list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseFast) |
| 949 | else() | 951 | elseif("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel") |
| 950 | list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseFast -Dstrip) | 952 | list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseSmall) |
| 951 | endif() | 953 | endif() |
| 952 | 954 | ||
| 953 | if(ZIG_STATIC AND NOT MSVC) | 955 | if(ZIG_STATIC AND NOT MSVC) |
ci/aarch64-linux-debug.sh deleted-100| ... | @@ -1,100 +0,0 @@ | ||
| 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.13.0-dev.130+98a30acad" | ||
| 12 | PREFIX="$HOME/deps/$CACHE_BASENAME" | ||
| 13 | ZIG="$PREFIX/bin/zig" | ||
| 14 | |||
| 15 | export PATH="$HOME/deps/wasmtime-v10.0.2-$ARCH-linux:$PATH" | ||
| 16 | |||
| 17 | # Make the `zig version` number consistent. | ||
| 18 | # This will affect the cmake command below. | ||
| 19 | git fetch --unshallow || true | ||
| 20 | git fetch --tags | ||
| 21 | |||
| 22 | export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" | ||
| 23 | export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" | ||
| 24 | |||
| 25 | rm -rf build-debug | ||
| 26 | mkdir build-debug | ||
| 27 | cd build-debug | ||
| 28 | |||
| 29 | # Override the cache directories because they won't actually help other CI runs | ||
| 30 | # which will be testing alternate versions of zig, and ultimately would just | ||
| 31 | # fill up space on the hard drive for no reason. | ||
| 32 | export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache" | ||
| 33 | export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache" | ||
| 34 | |||
| 35 | cmake .. \ | ||
| 36 | -DCMAKE_INSTALL_PREFIX="stage3-debug" \ | ||
| 37 | -DCMAKE_PREFIX_PATH="$PREFIX" \ | ||
| 38 | -DCMAKE_BUILD_TYPE=Debug \ | ||
| 39 | -DZIG_TARGET_TRIPLE="$TARGET" \ | ||
| 40 | -DZIG_TARGET_MCPU="$MCPU" \ | ||
| 41 | -DZIG_STATIC=ON \ | ||
| 42 | -DZIG_NO_LIB=ON \ | ||
| 43 | -GNinja | ||
| 44 | |||
| 45 | # Now cmake will use zig as the C/C++ compiler. We reset the environment variables | ||
| 46 | # so that installation and testing do not get affected by them. | ||
| 47 | unset CC | ||
| 48 | unset CXX | ||
| 49 | |||
| 50 | ninja install | ||
| 51 | |||
| 52 | # simultaneously test building self-hosted without LLVM and with 32-bit arm | ||
| 53 | stage3-debug/bin/zig build \ | ||
| 54 | -Dtarget=arm-linux-musleabihf \ | ||
| 55 | -Dno-lib | ||
| 56 | |||
| 57 | # TODO: add -fqemu back to this line | ||
| 58 | stage3-debug/bin/zig build test docs \ | ||
| 59 | --maxrss 24696061952 \ | ||
| 60 | -fwasmtime \ | ||
| 61 | -Dstatic-llvm \ | ||
| 62 | -Dtarget=native-native-musl \ | ||
| 63 | --search-prefix "$PREFIX" \ | ||
| 64 | --zig-lib-dir "$PWD/../lib" \ | ||
| 65 | -Denable-tidy | ||
| 66 | |||
| 67 | # Ensure that updating the wasm binary from this commit will result in a viable build. | ||
| 68 | stage3-debug/bin/zig build update-zig1 | ||
| 69 | |||
| 70 | rm -rf ../build-new | ||
| 71 | mkdir ../build-new | ||
| 72 | cd ../build-new | ||
| 73 | |||
| 74 | export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache" | ||
| 75 | export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache" | ||
| 76 | export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" | ||
| 77 | export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" | ||
| 78 | |||
| 79 | cmake .. \ | ||
| 80 | -DCMAKE_PREFIX_PATH="$PREFIX" \ | ||
| 81 | -DCMAKE_BUILD_TYPE=Debug \ | ||
| 82 | -DZIG_TARGET_TRIPLE="$TARGET" \ | ||
| 83 | -DZIG_TARGET_MCPU="$MCPU" \ | ||
| 84 | -DZIG_STATIC=ON \ | ||
| 85 | -DZIG_NO_LIB=ON \ | ||
| 86 | -GNinja | ||
| 87 | |||
| 88 | unset CC | ||
| 89 | unset CXX | ||
| 90 | |||
| 91 | ninja install | ||
| 92 | |||
| 93 | stage3/bin/zig test ../test/behavior.zig | ||
| 94 | stage3/bin/zig build -p stage4 \ | ||
| 95 | -Dstatic-llvm \ | ||
| 96 | -Dtarget=native-native-musl \ | ||
| 97 | -Dno-lib \ | ||
| 98 | --search-prefix "$PREFIX" \ | ||
| 99 | --zig-lib-dir "$PWD/../lib" | ||
| 100 | stage4/bin/zig test ../test/behavior.zig | ||
ci/aarch64-linux-release.sh deleted-100| ... | @@ -1,100 +0,0 @@ | ||
| 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.13.0-dev.130+98a30acad" | ||
| 12 | PREFIX="$HOME/deps/$CACHE_BASENAME" | ||
| 13 | ZIG="$PREFIX/bin/zig" | ||
| 14 | |||
| 15 | export PATH="$HOME/deps/wasmtime-v10.0.2-$ARCH-linux:$PATH" | ||
| 16 | |||
| 17 | # Make the `zig version` number consistent. | ||
| 18 | # This will affect the cmake command below. | ||
| 19 | git fetch --unshallow || true | ||
| 20 | git fetch --tags | ||
| 21 | |||
| 22 | export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" | ||
| 23 | export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" | ||
| 24 | |||
| 25 | rm -rf build-release | ||
| 26 | mkdir build-release | ||
| 27 | cd build-release | ||
| 28 | |||
| 29 | # Override the cache directories because they won't actually help other CI runs | ||
| 30 | # which will be testing alternate versions of zig, and ultimately would just | ||
| 31 | # fill up space on the hard drive for no reason. | ||
| 32 | export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache" | ||
| 33 | export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache" | ||
| 34 | |||
| 35 | cmake .. \ | ||
| 36 | -DCMAKE_INSTALL_PREFIX="stage3-release" \ | ||
| 37 | -DCMAKE_PREFIX_PATH="$PREFIX" \ | ||
| 38 | -DCMAKE_BUILD_TYPE=Release \ | ||
| 39 | -DZIG_TARGET_TRIPLE="$TARGET" \ | ||
| 40 | -DZIG_TARGET_MCPU="$MCPU" \ | ||
| 41 | -DZIG_STATIC=ON \ | ||
| 42 | -DZIG_NO_LIB=ON \ | ||
| 43 | -GNinja | ||
| 44 | |||
| 45 | # Now cmake will use zig as the C/C++ compiler. We reset the environment variables | ||
| 46 | # so that installation and testing do not get affected by them. | ||
| 47 | unset CC | ||
| 48 | unset CXX | ||
| 49 | |||
| 50 | ninja install | ||
| 51 | |||
| 52 | # simultaneously test building self-hosted without LLVM and with 32-bit arm | ||
| 53 | stage3-release/bin/zig build \ | ||
| 54 | -Dtarget=arm-linux-musleabihf \ | ||
| 55 | -Dno-lib | ||
| 56 | |||
| 57 | # TODO: add -fqemu back to this line | ||
| 58 | stage3-release/bin/zig build test docs \ | ||
| 59 | --maxrss 24696061952 \ | ||
| 60 | -fwasmtime \ | ||
| 61 | -Dstatic-llvm \ | ||
| 62 | -Dtarget=native-native-musl \ | ||
| 63 | --search-prefix "$PREFIX" \ | ||
| 64 | --zig-lib-dir "$PWD/../lib" \ | ||
| 65 | -Denable-tidy | ||
| 66 | |||
| 67 | # Ensure that updating the wasm binary from this commit will result in a viable build. | ||
| 68 | stage3-release/bin/zig build update-zig1 | ||
| 69 | |||
| 70 | rm -rf ../build-new | ||
| 71 | mkdir ../build-new | ||
| 72 | cd ../build-new | ||
| 73 | |||
| 74 | export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache" | ||
| 75 | export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache" | ||
| 76 | export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" | ||
| 77 | export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" | ||
| 78 | |||
| 79 | cmake .. \ | ||
| 80 | -DCMAKE_PREFIX_PATH="$PREFIX" \ | ||
| 81 | -DCMAKE_BUILD_TYPE=Release \ | ||
| 82 | -DZIG_TARGET_TRIPLE="$TARGET" \ | ||
| 83 | -DZIG_TARGET_MCPU="$MCPU" \ | ||
| 84 | -DZIG_STATIC=ON \ | ||
| 85 | -DZIG_NO_LIB=ON \ | ||
| 86 | -GNinja | ||
| 87 | |||
| 88 | unset CC | ||
| 89 | unset CXX | ||
| 90 | |||
| 91 | ninja install | ||
| 92 | |||
| 93 | stage3/bin/zig test ../test/behavior.zig | ||
| 94 | stage3/bin/zig build -p stage4 \ | ||
| 95 | -Dstatic-llvm \ | ||
| 96 | -Dtarget=native-native-musl \ | ||
| 97 | -Dno-lib \ | ||
| 98 | --search-prefix "$PREFIX" \ | ||
| 99 | --zig-lib-dir "$PWD/../lib" | ||
| 100 | stage4/bin/zig test ../test/behavior.zig | ||
ci/aarch64-macos-debug.sh deleted-58| ... | @@ -1,58 +0,0 @@ | ||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | set -x | ||
| 4 | set -e | ||
| 5 | |||
| 6 | # Script assumes the presence of the following: | ||
| 7 | # s3cmd | ||
| 8 | |||
| 9 | ZIGDIR="$PWD" | ||
| 10 | TARGET="$ARCH-macos-none" | ||
| 11 | MCPU="baseline" | ||
| 12 | CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.13.0-dev.130+98a30acad" | ||
| 13 | PREFIX="$HOME/$CACHE_BASENAME" | ||
| 14 | ZIG="$PREFIX/bin/zig" | ||
| 15 | |||
| 16 | if [ ! -d "$PREFIX" ]; then | ||
| 17 | cd $HOME | ||
| 18 | curl -L -O "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz" | ||
| 19 | tar xf "$CACHE_BASENAME.tar.xz" | ||
| 20 | fi | ||
| 21 | |||
| 22 | cd $ZIGDIR | ||
| 23 | |||
| 24 | # Make the `zig version` number consistent. | ||
| 25 | # This will affect the cmake command below. | ||
| 26 | git fetch --unshallow || true | ||
| 27 | git fetch --tags | ||
| 28 | |||
| 29 | rm -rf build-debug | ||
| 30 | mkdir build-debug | ||
| 31 | cd build-debug | ||
| 32 | |||
| 33 | # Override the cache directories because they won't actually help other CI runs | ||
| 34 | # which will be testing alternate versions of zig, and ultimately would just | ||
| 35 | # fill up space on the hard drive for no reason. | ||
| 36 | export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache" | ||
| 37 | export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache" | ||
| 38 | |||
| 39 | PATH="$HOME/local/bin:$PATH" cmake .. \ | ||
| 40 | -DCMAKE_INSTALL_PREFIX="stage3-debug" \ | ||
| 41 | -DCMAKE_PREFIX_PATH="$PREFIX" \ | ||
| 42 | -DCMAKE_BUILD_TYPE=Debug \ | ||
| 43 | -DCMAKE_C_COMPILER="$ZIG;cc;-target;$TARGET;-mcpu=$MCPU" \ | ||
| 44 | -DCMAKE_CXX_COMPILER="$ZIG;c++;-target;$TARGET;-mcpu=$MCPU" \ | ||
| 45 | -DZIG_TARGET_TRIPLE="$TARGET" \ | ||
| 46 | -DZIG_TARGET_MCPU="$MCPU" \ | ||
| 47 | -DZIG_STATIC=ON \ | ||
| 48 | -DZIG_NO_LIB=ON \ | ||
| 49 | -GNinja | ||
| 50 | |||
| 51 | $HOME/local/bin/ninja install | ||
| 52 | |||
| 53 | stage3-debug/bin/zig build test docs \ | ||
| 54 | --zig-lib-dir "$PWD/../lib" \ | ||
| 55 | -Denable-macos-sdk \ | ||
| 56 | -Dstatic-llvm \ | ||
| 57 | -Dskip-non-native \ | ||
| 58 | --search-prefix "$PREFIX" | ||
ci/aarch64-macos-release.sh deleted-74| ... | @@ -1,74 +0,0 @@ | ||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | set -x | ||
| 4 | set -e | ||
| 5 | |||
| 6 | # Script assumes the presence of the following: | ||
| 7 | # s3cmd | ||
| 8 | |||
| 9 | ZIGDIR="$PWD" | ||
| 10 | TARGET="$ARCH-macos-none" | ||
| 11 | MCPU="baseline" | ||
| 12 | CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.13.0-dev.130+98a30acad" | ||
| 13 | PREFIX="$HOME/$CACHE_BASENAME" | ||
| 14 | ZIG="$PREFIX/bin/zig" | ||
| 15 | |||
| 16 | if [ ! -d "$PREFIX" ]; then | ||
| 17 | cd $HOME | ||
| 18 | curl -L -O "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz" | ||
| 19 | tar xf "$CACHE_BASENAME.tar.xz" | ||
| 20 | fi | ||
| 21 | |||
| 22 | cd $ZIGDIR | ||
| 23 | |||
| 24 | # Make the `zig version` number consistent. | ||
| 25 | # This will affect the cmake command below. | ||
| 26 | git fetch --unshallow || true | ||
| 27 | git fetch --tags | ||
| 28 | |||
| 29 | rm -rf build-release | ||
| 30 | mkdir build-release | ||
| 31 | cd build-release | ||
| 32 | |||
| 33 | # Override the cache directories because they won't actually help other CI runs | ||
| 34 | # which will be testing alternate versions of zig, and ultimately would just | ||
| 35 | # fill up space on the hard drive for no reason. | ||
| 36 | export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache" | ||
| 37 | export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache" | ||
| 38 | |||
| 39 | PATH="$HOME/local/bin:$PATH" cmake .. \ | ||
| 40 | -DCMAKE_INSTALL_PREFIX="stage3-release" \ | ||
| 41 | -DCMAKE_PREFIX_PATH="$PREFIX" \ | ||
| 42 | -DCMAKE_BUILD_TYPE=Release \ | ||
| 43 | -DCMAKE_C_COMPILER="$ZIG;cc;-target;$TARGET;-mcpu=$MCPU" \ | ||
| 44 | -DCMAKE_CXX_COMPILER="$ZIG;c++;-target;$TARGET;-mcpu=$MCPU" \ | ||
| 45 | -DZIG_TARGET_TRIPLE="$TARGET" \ | ||
| 46 | -DZIG_TARGET_MCPU="$MCPU" \ | ||
| 47 | -DZIG_STATIC=ON \ | ||
| 48 | -DZIG_NO_LIB=ON \ | ||
| 49 | -GNinja | ||
| 50 | |||
| 51 | $HOME/local/bin/ninja install | ||
| 52 | |||
| 53 | stage3-release/bin/zig build test docs \ | ||
| 54 | --zig-lib-dir "$PWD/../lib" \ | ||
| 55 | -Denable-macos-sdk \ | ||
| 56 | -Dstatic-llvm \ | ||
| 57 | -Dskip-non-native \ | ||
| 58 | --search-prefix "$PREFIX" | ||
| 59 | |||
| 60 | # Ensure that stage3 and stage4 are byte-for-byte identical. | ||
| 61 | stage3-release/bin/zig build \ | ||
| 62 | --prefix stage4-release \ | ||
| 63 | -Denable-llvm \ | ||
| 64 | -Dno-lib \ | ||
| 65 | -Doptimize=ReleaseFast \ | ||
| 66 | -Dstrip \ | ||
| 67 | -Dtarget=$TARGET \ | ||
| 68 | -Duse-zig-libcxx \ | ||
| 69 | -Dversion-string="$(stage3-release/bin/zig version)" | ||
| 70 | |||
| 71 | # diff returns an error code if the files differ. | ||
| 72 | echo "If the following command fails, it means nondeterminism has been" | ||
| 73 | echo "introduced, making stage3 and stage4 no longer byte-for-byte identical." | ||
| 74 | diff stage3-release/bin/zig stage4-release/bin/zig | ||
ci/aarch64-windows.ps1 deleted-71| ... | @@ -1,71 +0,0 @@ | ||
| 1 | $TARGET = "$($Env:ARCH)-windows-gnu" | ||
| 2 | $ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.13.0-dev.130+98a30acad" | ||
| 3 | $MCPU = "baseline" | ||
| 4 | $ZIG_LLVM_CLANG_LLD_URL = "https://ziglang.org/deps/$ZIG_LLVM_CLANG_LLD_NAME.zip" | ||
| 5 | $PREFIX_PATH = "$(Get-Location)\..\$ZIG_LLVM_CLANG_LLD_NAME" | ||
| 6 | $ZIG = "$PREFIX_PATH\bin\zig.exe" | ||
| 7 | $ZIG_LIB_DIR = "$(Get-Location)\lib" | ||
| 8 | |||
| 9 | if (!(Test-Path "..\$ZIG_LLVM_CLANG_LLD_NAME.zip")) { | ||
| 10 | Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL" | ||
| 11 | Invoke-WebRequest -Uri "$ZIG_LLVM_CLANG_LLD_URL" -OutFile "..\$ZIG_LLVM_CLANG_LLD_NAME.zip" | ||
| 12 | |||
| 13 | Write-Output "Extracting..." | ||
| 14 | Add-Type -AssemblyName System.IO.Compression.FileSystem ; | ||
| 15 | [System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD\..\$ZIG_LLVM_CLANG_LLD_NAME.zip", "$PWD\..") | ||
| 16 | } | ||
| 17 | |||
| 18 | function CheckLastExitCode { | ||
| 19 | if (!$?) { | ||
| 20 | exit 1 | ||
| 21 | } | ||
| 22 | return 0 | ||
| 23 | } | ||
| 24 | |||
| 25 | # Make the `zig version` number consistent. | ||
| 26 | # This will affect the `zig build` command below which uses `git describe`. | ||
| 27 | git fetch --tags | ||
| 28 | |||
| 29 | if ((git rev-parse --is-shallow-repository) -eq "true") { | ||
| 30 | git fetch --unshallow # `git describe` won't work on a shallow repo | ||
| 31 | } | ||
| 32 | |||
| 33 | Write-Output "Building from source..." | ||
| 34 | Remove-Item -Path 'build-release' -Recurse -Force -ErrorAction Ignore | ||
| 35 | New-Item -Path 'build-release' -ItemType Directory | ||
| 36 | Set-Location -Path '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 | $Env:ZIG_GLOBAL_CACHE_DIR="$(Get-Location)\zig-global-cache" | ||
| 42 | $Env:ZIG_LOCAL_CACHE_DIR="$(Get-Location)\zig-local-cache" | ||
| 43 | |||
| 44 | # CMake gives a syntax error when file paths with backward slashes are used. | ||
| 45 | # Here, we use forward slashes only to work around this. | ||
| 46 | & cmake .. ` | ||
| 47 | -GNinja ` | ||
| 48 | -DCMAKE_INSTALL_PREFIX="stage3-release" ` | ||
| 49 | -DCMAKE_PREFIX_PATH="$($PREFIX_PATH -Replace "\\", "/")" ` | ||
| 50 | -DCMAKE_BUILD_TYPE=Release ` | ||
| 51 | -DCMAKE_C_COMPILER="$($ZIG -Replace "\\", "/");cc;-target;$TARGET;-mcpu=$MCPU" ` | ||
| 52 | -DCMAKE_CXX_COMPILER="$($ZIG -Replace "\\", "/");c++;-target;$TARGET;-mcpu=$MCPU" ` | ||
| 53 | -DCMAKE_AR="$ZIG" ` | ||
| 54 | -DZIG_AR_WORKAROUND=ON ` | ||
| 55 | -DZIG_TARGET_TRIPLE="$TARGET" ` | ||
| 56 | -DZIG_TARGET_MCPU="$MCPU" ` | ||
| 57 | -DZIG_STATIC=ON ` | ||
| 58 | -DZIG_NO_LIB=ON | ||
| 59 | CheckLastExitCode | ||
| 60 | |||
| 61 | ninja install | ||
| 62 | CheckLastExitCode | ||
| 63 | |||
| 64 | Write-Output "Main test suite..." | ||
| 65 | & "stage3-release\bin\zig.exe" build test docs ` | ||
| 66 | --zig-lib-dir "$ZIG_LIB_DIR" ` | ||
| 67 | --search-prefix "$PREFIX_PATH" ` | ||
| 68 | -Dstatic-llvm ` | ||
| 69 | -Dskip-non-native ` | ||
| 70 | -Denable-symlinks-windows | ||
| 71 | CheckLastExitCode | ||
ci/build.zig created+665| ... | @@ -0,0 +1,665 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | |||
| 3 | pub fn build(b: *std.Build) void { | ||
| 4 | const host_target = b.standardTargetOptions(.{ | ||
| 5 | .whitelist = &.{ | ||
| 6 | .{ | ||
| 7 | .cpu_arch = .x86_64, | ||
| 8 | .cpu_model = .baseline, | ||
| 9 | .os_tag = .linux, | ||
| 10 | .abi = .musl, | ||
| 11 | }, | ||
| 12 | .{ | ||
| 13 | .cpu_arch = .aarch64, | ||
| 14 | .cpu_model = .baseline, | ||
| 15 | .os_tag = .linux, | ||
| 16 | .abi = .musl, | ||
| 17 | }, | ||
| 18 | .{ | ||
| 19 | .cpu_arch = .aarch64, | ||
| 20 | .cpu_model = .baseline, | ||
| 21 | .os_tag = .macos, | ||
| 22 | .abi = .none, | ||
| 23 | }, | ||
| 24 | .{ | ||
| 25 | .cpu_arch = .x86_64, | ||
| 26 | .cpu_model = .baseline, | ||
| 27 | .os_tag = .windows, | ||
| 28 | .abi = .gnu, | ||
| 29 | }, | ||
| 30 | .{ | ||
| 31 | .cpu_arch = .aarch64, | ||
| 32 | .cpu_model = .baseline, | ||
| 33 | .os_tag = .windows, | ||
| 34 | .abi = .gnu, | ||
| 35 | }, | ||
| 36 | }, | ||
| 37 | .default_target = .{ | ||
| 38 | .cpu_arch = b.graph.host.result.cpu.arch, | ||
| 39 | .cpu_model = .baseline, | ||
| 40 | .os_tag = b.graph.host.result.os.tag, | ||
| 41 | .abi = if (b.graph.host.result.os.tag == .windows) | ||
| 42 | .gnu | ||
| 43 | else if (b.graph.host.result.isDarwin()) | ||
| 44 | .none | ||
| 45 | else | ||
| 46 | .musl, | ||
| 47 | }, | ||
| 48 | }); | ||
| 49 | const host_triple = host_target.result.linuxTriple(b.allocator) catch @panic("OOM"); | ||
| 50 | const host_cpu = host_target.query.serializeCpuAlloc(b.allocator) catch @panic("OOM"); | ||
| 51 | const host_exe_file_ext = host_target.result.exeFileExt(); | ||
| 52 | const build_type = b.option(enum { None, Debug, Release, RelWithDebInfo, MinSizeRel }, "build-type", "CMake build type") orelse .Debug; | ||
| 53 | const tool_optimize = b.option( | ||
| 54 | std.builtin.OptimizeMode, | ||
| 55 | "tool-optimize", | ||
| 56 | "Prioritize performance, safety, or binary size for build tools", | ||
| 57 | ) orelse .ReleaseSafe; | ||
| 58 | |||
| 59 | const binaryen_lazy_dep = if (host_target.result.cpu.arch != .aarch64 or host_target.result.os.tag != .windows) | ||
| 60 | b.lazyDependency(b.fmt("binaryen-{s}", .{host_triple}), .{}) | ||
| 61 | else | ||
| 62 | null; | ||
| 63 | const cmake_lazy_dep = b.lazyDependency(b.fmt("cmake-{s}", .{host_triple}), .{}); | ||
| 64 | const ninja_lazy_dep = b.lazyDependency(b.fmt("ninja-{s}", .{host_triple}), .{}); | ||
| 65 | const qemu_lazy_dep = if (host_target.result.cpu.arch == .x86_64 and host_target.result.os.tag == .linux) | ||
| 66 | b.lazyDependency(b.fmt("qemu-{s}", .{host_triple}), .{}) | ||
| 67 | else | ||
| 68 | null; | ||
| 69 | const tidy_lazy_dep = b.lazyDependency(b.fmt("tidy-{s}", .{host_triple}), .{}); | ||
| 70 | const wasmtime_lazy_dep = if (host_target.result.cpu.arch != .aarch64 or host_target.result.os.tag != .windows) | ||
| 71 | b.lazyDependency(b.fmt("wasmtime-{s}", .{host_triple}), .{}) | ||
| 72 | else | ||
| 73 | null; | ||
| 74 | const zig_llvm_lld_clang_lazy_dep = | ||
| 75 | b.lazyDependency(b.fmt("zig+llvm+lld+clang-{s}", .{host_triple}), .{}); | ||
| 76 | |||
| 77 | const cmake_dep = cmake_lazy_dep orelse return; | ||
| 78 | const ninja_dep = ninja_lazy_dep orelse return; | ||
| 79 | const zig_llvm_lld_clang_dep = zig_llvm_lld_clang_lazy_dep orelse return; | ||
| 80 | |||
| 81 | const cmake_exe = cmake_dep.path(b.fmt("{s}bin/cmake{s}", .{ | ||
| 82 | if (host_target.result.isDarwin()) "CMake.app/Contents/" else "", | ||
| 83 | host_exe_file_ext, | ||
| 84 | })); | ||
| 85 | const ninja_exe = ninja_dep.path(b.fmt("ninja{s}", .{host_exe_file_ext})); | ||
| 86 | |||
| 87 | const build_file = b.path("../build.zig"); | ||
| 88 | const local_cache_dir = b.path(".zig-local-cache"); | ||
| 89 | const global_cache_dir = b.path(".zig-global-cache"); | ||
| 90 | |||
| 91 | const clean_step = b.step("clean", "Cleanup previous CI runs"); | ||
| 92 | clean_step.dependOn(&b.addRemoveDirTree(b.cache_root.path orelse ".").step); | ||
| 93 | clean_step.dependOn(&b.addRemoveDirTree(b.pathFromRoot("../.zig-cache")).step); | ||
| 94 | clean_step.dependOn(&b.addRemoveDirTree(local_cache_dir.getPath(b)).step); | ||
| 95 | clean_step.dependOn(&b.addRemoveDirTree(global_cache_dir.getPath(b)).step); | ||
| 96 | |||
| 97 | const run_exe = b.addExecutable(.{ | ||
| 98 | .name = "run", | ||
| 99 | .root_source_file = b.path("run.zig"), | ||
| 100 | .target = host_target, | ||
| 101 | .optimize = tool_optimize, | ||
| 102 | .strip = false, | ||
| 103 | }); | ||
| 104 | run_exe.step.max_rss = 281_214_976; | ||
| 105 | |||
| 106 | const run_chmod_step = if (host_target.result.isDarwin()) steps: { | ||
| 107 | const chmod_exe = b.addExecutable(.{ | ||
| 108 | .name = "chmod", | ||
| 109 | .root_source_file = b.path("chmod.zig"), | ||
| 110 | .target = host_target, | ||
| 111 | .optimize = tool_optimize, | ||
| 112 | .strip = false, | ||
| 113 | }); | ||
| 114 | chmod_exe.step.max_rss = 267_157_504; | ||
| 115 | |||
| 116 | const run_chmod = b.addRunArtifact(chmod_exe); | ||
| 117 | run_chmod.step.max_rss = 1_212_416; | ||
| 118 | if (binaryen_lazy_dep) |binaryen_dep| for ([_][]const u8{ | ||
| 119 | "binaryen-unittests", | ||
| 120 | "wasm2js", | ||
| 121 | "wasm-as", | ||
| 122 | "wasm-ctor-eval", | ||
| 123 | "wasm-dis", | ||
| 124 | "wasm-emscripten-finalize", | ||
| 125 | "wasm-fuzz-lattices", | ||
| 126 | "wasm-fuzz-types", | ||
| 127 | "wasm-merge", | ||
| 128 | "wasm-metadce", | ||
| 129 | "wasm-opt", | ||
| 130 | "wasm-reduce", | ||
| 131 | "wasm-shell", | ||
| 132 | "wasm-split", | ||
| 133 | }) |exe| run_chmod.addFileArg(binaryen_dep.path(b.fmt("bin/{s}{s}", .{ exe, host_exe_file_ext }))); | ||
| 134 | run_chmod.addFileArg(cmake_exe); | ||
| 135 | run_chmod.addFileArg(ninja_exe); | ||
| 136 | if (qemu_lazy_dep) |qemu_dep| for ([_][]const u8{ | ||
| 137 | "cris", | ||
| 138 | "mips64el", | ||
| 139 | "ppc64", | ||
| 140 | "loongarch64", | ||
| 141 | "sparc", | ||
| 142 | "aarch64", | ||
| 143 | "sparc64", | ||
| 144 | "alpha", | ||
| 145 | "sparc32plus", | ||
| 146 | "sh4", | ||
| 147 | "hexagon", | ||
| 148 | "xtensaeb", | ||
| 149 | "riscv64", | ||
| 150 | "aarch64_be", | ||
| 151 | "i386", | ||
| 152 | "armeb", | ||
| 153 | "mips", | ||
| 154 | "s390x", | ||
| 155 | "mips64", | ||
| 156 | "ppc64le", | ||
| 157 | "mipsel", | ||
| 158 | "x86_64", | ||
| 159 | "arm", | ||
| 160 | "hppa", | ||
| 161 | "ppc", | ||
| 162 | "or1k", | ||
| 163 | "xtensa", | ||
| 164 | "microblaze", | ||
| 165 | "riscv32", | ||
| 166 | "m68k", | ||
| 167 | "sh4eb", | ||
| 168 | "mipsn32el", | ||
| 169 | "nios2", | ||
| 170 | "microblazeel", | ||
| 171 | "mipsn32", | ||
| 172 | }) |qemu_target| run_chmod.addFileArg(qemu_dep.path(b.fmt("bin/qemu-{s}{s}", .{ qemu_target, host_exe_file_ext }))); | ||
| 173 | if (tidy_lazy_dep) |tidy_dep| run_chmod.addFileArg(tidy_dep.path(b.fmt("bin/tidy{s}", .{host_exe_file_ext}))); | ||
| 174 | if (wasmtime_lazy_dep) |wasmtime_dep| run_chmod.addFileArg(wasmtime_dep.path(b.fmt("wasmtime{s}", .{host_exe_file_ext}))); | ||
| 175 | run_chmod.addFileArg(zig_llvm_lld_clang_dep.path(b.fmt("bin/zig{s}", .{host_exe_file_ext}))); | ||
| 176 | |||
| 177 | break :steps &run_chmod.step; | ||
| 178 | } else null; | ||
| 179 | |||
| 180 | const build_cc_stage2_step = if (b.option( | ||
| 181 | []const u8, | ||
| 182 | "cc", | ||
| 183 | "System C compiler to use for cc bootstrap", | ||
| 184 | )) |cc| steps: { | ||
| 185 | const cc_bootstrap_step = b.step("cc-bootstrap", "build cc bootstrap"); | ||
| 186 | const test_cc_bootstrap_step = b.step("test-cc-bootstrap", "test cc bootstrap"); | ||
| 187 | |||
| 188 | const build_bootstrap = b.addSystemCommand(&.{ cc, "-o" }); | ||
| 189 | build_bootstrap.step.max_rss = 94_011_392; | ||
| 190 | const bootstrap_exe = build_bootstrap.addOutputFileArg("bootstrap"); | ||
| 191 | build_bootstrap.addArgs(&.{ "-MD", "-MF" }); | ||
| 192 | _ = build_bootstrap.addDepFileOutputArg("bootstrap.d"); | ||
| 193 | build_bootstrap.addFileArg(b.path("../bootstrap.c")); | ||
| 194 | build_bootstrap.setCwd(b.path("..")); | ||
| 195 | |||
| 196 | const build_stage2 = std.Build.Step.Run.create(b, "build cc bootstrap"); | ||
| 197 | build_stage2.step.max_rss = 5_953_224_704; | ||
| 198 | build_stage2.addArtifactArg(run_exe); | ||
| 199 | build_stage2.addArgs(&.{ | ||
| 200 | "$0", | ||
| 201 | "--delete", | ||
| 202 | "zig-wasm2c", | ||
| 203 | "zig1.c", | ||
| 204 | "zig1", | ||
| 205 | "config.zig", | ||
| 206 | "zig2.c", | ||
| 207 | "compiler_rt.c", | ||
| 208 | "--rename", | ||
| 209 | "zig2", | ||
| 210 | "$1", | ||
| 211 | "--", | ||
| 212 | }); | ||
| 213 | build_stage2.addFileArg(bootstrap_exe); | ||
| 214 | const stage2_exe = build_stage2.addOutputFileArg("zig2"); | ||
| 215 | build_stage2.setEnvironmentVariable("CC", cc); | ||
| 216 | build_stage2.setCwd(b.path("..")); | ||
| 217 | |||
| 218 | const build_stage3 = std.Build.Step.Run.create(b, "build cc bootstrap"); | ||
| 219 | build_stage3.step.max_rss = 736_362_496; | ||
| 220 | build_stage3.addFileArg(stage2_exe); | ||
| 221 | build_stage3.addArgs(&.{ | ||
| 222 | "build", | ||
| 223 | "--maxrss", | ||
| 224 | b.fmt("{}", .{@max(build_stage3.step.max_rss, 7_000_000_000)}), | ||
| 225 | "--build-file", | ||
| 226 | }); | ||
| 227 | build_stage3.addFileArg(build_file); | ||
| 228 | build_stage3.addArg("--prefix"); | ||
| 229 | const stage3_out = build_stage3.addOutputDirectoryArg("stage3"); | ||
| 230 | build_stage3.addArg("--cache-dir"); | ||
| 231 | build_stage3.addDirectoryArg(local_cache_dir); | ||
| 232 | build_stage3.addArg("--global-cache-dir"); | ||
| 233 | build_stage3.addDirectoryArg(global_cache_dir); | ||
| 234 | build_stage3.addArg("-Dno-lib"); | ||
| 235 | |||
| 236 | cc_bootstrap_step.dependOn(&b.addInstallDirectory(.{ | ||
| 237 | .source_dir = stage3_out, | ||
| 238 | .install_dir = .prefix, | ||
| 239 | .install_subdir = "cc", | ||
| 240 | }).step); | ||
| 241 | const stage3_exe = stage3_out.path(b, b.fmt("bin/zig{s}", .{host_exe_file_ext})); | ||
| 242 | |||
| 243 | const run_tests = std.Build.Step.Run.create(b, "test cc bootstrap (stage3)"); | ||
| 244 | run_tests.step.max_rss = 451_231_744; | ||
| 245 | run_tests.addFileArg(stage3_exe); | ||
| 246 | run_tests.addArg("test"); | ||
| 247 | run_tests.addFileArg(b.path("../test/behavior.zig")); | ||
| 248 | test_cc_bootstrap_step.dependOn(&run_tests.step); | ||
| 249 | |||
| 250 | break :steps &build_stage2.step; | ||
| 251 | } else null; | ||
| 252 | |||
| 253 | { | ||
| 254 | const cmake_bootstrap_step = b.step("cmake-bootstrap", "build cmake bootstrap"); | ||
| 255 | const test_cmake_bootstrap_step = b.step("test-cmake-bootstrap", "test cmake bootstrap"); | ||
| 256 | |||
| 257 | const build_stage3 = std.Build.Step.Run.create(b, "build cmake bootstrap"); | ||
| 258 | build_stage3.step.max_rss = 10_620_571_648; | ||
| 259 | build_stage3.addArtifactArg(run_exe); | ||
| 260 | build_stage3.addArgs(&.{ | ||
| 261 | "$4", | ||
| 262 | "-GNinja", | ||
| 263 | "-S..", | ||
| 264 | "-B$6", | ||
| 265 | "-DCMAKE_MAKE_PROGRAM=$5", | ||
| 266 | "-DCMAKE_BUILD_TYPE=$2", | ||
| 267 | "-DCMAKE_PREFIX_PATH=$7", | ||
| 268 | "-DCMAKE_C_COMPILER=$7/bin/zig$3;cc;-target;$0;-mcpu=$1", | ||
| 269 | "-DCMAKE_CXX_COMPILER=$7/bin/zig$3;c++;-target;$0;-mcpu=$1", | ||
| 270 | "-DCMAKE_AR=$7/bin/zig$3", | ||
| 271 | "-DZIG_AR_WORKAROUND=ON", | ||
| 272 | "-DZIG_TARGET_TRIPLE=$0", | ||
| 273 | "-DZIG_TARGET_MCPU=$1", | ||
| 274 | "-DZIG_STATIC=ON", | ||
| 275 | "-DZIG_STATIC_CURSES=OFF", | ||
| 276 | "-DZIG_NO_LIB=ON", | ||
| 277 | "--then", | ||
| 278 | "$5", | ||
| 279 | "-C", | ||
| 280 | "$6", | ||
| 281 | "install", | ||
| 282 | "--", | ||
| 283 | host_triple, | ||
| 284 | host_cpu, | ||
| 285 | @tagName(build_type), | ||
| 286 | host_exe_file_ext, | ||
| 287 | }); | ||
| 288 | build_stage3.addFileArg(cmake_exe); | ||
| 289 | build_stage3.addFileArg(ninja_exe); | ||
| 290 | const stage3_out = build_stage3.addOutputDirectoryArg("build").path(b, "stage3"); | ||
| 291 | build_stage3.addDirectoryArg(zig_llvm_lld_clang_dep.path("")); | ||
| 292 | build_stage3.addFileInput(b.path("../stage1/zig1.wasm")); | ||
| 293 | build_stage3.addFileInput(b.path("../stage1/zig.h")); | ||
| 294 | if (run_chmod_step) |step| build_stage3.step.dependOn(step); | ||
| 295 | |||
| 296 | cmake_bootstrap_step.dependOn(&b.addInstallDirectory(.{ | ||
| 297 | .source_dir = stage3_out, | ||
| 298 | .install_dir = .prefix, | ||
| 299 | .install_subdir = "cmake", | ||
| 300 | }).step); | ||
| 301 | const stage3_exe = stage3_out.path(b, b.fmt("bin/zig{s}", .{host_exe_file_ext})); | ||
| 302 | |||
| 303 | const run_tests = std.Build.Step.Run.create(b, "test cmake bootstrap (stage3)"); | ||
| 304 | run_tests.step.max_rss = 12_676_628_480; | ||
| 305 | run_tests.addArtifactArg(run_exe); | ||
| 306 | run_tests.addArgs(&.{ | ||
| 307 | "$0", | ||
| 308 | "build", | ||
| 309 | "$--maxrss", | ||
| 310 | b.fmt("{}", .{run_tests.step.max_rss}), | ||
| 311 | "$--build-file", | ||
| 312 | "$1", | ||
| 313 | "$--prefix", | ||
| 314 | "$2", | ||
| 315 | "$--cache-dir", | ||
| 316 | "$3", | ||
| 317 | "$--global-cache-dir", | ||
| 318 | "$4", | ||
| 319 | "test-fmt", | ||
| 320 | "test", | ||
| 321 | "docs", | ||
| 322 | "-Dstatic-llvm", | ||
| 323 | "$--search-prefix", | ||
| 324 | "$5", | ||
| 325 | }); | ||
| 326 | if (host_target.result.isDarwin()) run_tests.addArg("-Denable-macos-sdk"); | ||
| 327 | if (host_target.result.os.tag == .windows) run_tests.addArgs(&.{"-Denable-symlinks-windows"}); | ||
| 328 | if (b.option(bool, "skip-non-native", "Skip non-native tests") orelse false) | ||
| 329 | run_tests.addArg("-Dskip-non-native"); | ||
| 330 | if (qemu_lazy_dep) |_| run_tests.addArg("-fqemu"); | ||
| 331 | if (tidy_lazy_dep) |_| run_tests.addArg("-Denable-tidy"); | ||
| 332 | if (wasmtime_lazy_dep) |_| run_tests.addArg("-fwasmtime"); | ||
| 333 | run_tests.addArg("--path"); | ||
| 334 | { | ||
| 335 | var index: usize = 6; | ||
| 336 | for ([_]?*std.Build.Dependency{ | ||
| 337 | qemu_lazy_dep, | ||
| 338 | tidy_lazy_dep, | ||
| 339 | wasmtime_lazy_dep, | ||
| 340 | }) |maybe_dep| if (maybe_dep) |_| { | ||
| 341 | run_tests.addArg(b.fmt("${}", .{index})); | ||
| 342 | index += 1; | ||
| 343 | }; | ||
| 344 | } | ||
| 345 | run_tests.addArg("--"); | ||
| 346 | run_tests.addFileArg(stage3_exe); | ||
| 347 | run_tests.addFileArg(build_file); | ||
| 348 | _ = run_tests.addOutputDirectoryArg("tests"); | ||
| 349 | run_tests.addDirectoryArg(local_cache_dir); | ||
| 350 | run_tests.addDirectoryArg(global_cache_dir); | ||
| 351 | run_tests.addDirectoryArg(zig_llvm_lld_clang_dep.path("")); | ||
| 352 | if (qemu_lazy_dep) |qemu_dep| run_tests.addDirectoryArg(qemu_dep.path("bin")); | ||
| 353 | if (tidy_lazy_dep) |tidy_dep| run_tests.addDirectoryArg(tidy_dep.path("bin")); | ||
| 354 | if (wasmtime_lazy_dep) |wasmtime_dep| run_tests.addDirectoryArg(wasmtime_dep.path("")); | ||
| 355 | if (run_chmod_step) |step| run_tests.step.dependOn(step); | ||
| 356 | test_cmake_bootstrap_step.dependOn(&run_tests.step); | ||
| 357 | |||
| 358 | for (b.option([]const []const u8, "extra-target", "Extra targets to build") orelse &.{}) |build_target| { | ||
| 359 | const build_stage4 = std.Build.Step.Run.create(b, "build"); | ||
| 360 | build_stage4.step.max_rss = 4_483_489_792; | ||
| 361 | build_stage4.addFileArg(stage3_exe); | ||
| 362 | build_stage4.addArgs(&.{ | ||
| 363 | "build", | ||
| 364 | "--maxrss", | ||
| 365 | b.fmt("{}", .{@max(build_stage4.step.max_rss, 7_000_000_000)}), | ||
| 366 | "--build-file", | ||
| 367 | }); | ||
| 368 | build_stage4.addFileArg(build_file); | ||
| 369 | build_stage4.addArg("--prefix"); | ||
| 370 | _ = build_stage4.addOutputDirectoryArg(b.fmt("stage4-{s}", .{build_target})); | ||
| 371 | build_stage4.addArg("--cache-dir"); | ||
| 372 | build_stage4.addDirectoryArg(local_cache_dir); | ||
| 373 | build_stage4.addArg("--global-cache-dir"); | ||
| 374 | build_stage4.addDirectoryArg(global_cache_dir); | ||
| 375 | build_stage4.addArgs(&.{ b.fmt("-Dtarget={s}", .{build_target}), "-Dno-lib" }); | ||
| 376 | test_cmake_bootstrap_step.dependOn(&build_stage4.step); | ||
| 377 | } | ||
| 378 | |||
| 379 | switch (build_type) { | ||
| 380 | .None, .Debug, .RelWithDebInfo, .MinSizeRel => {}, | ||
| 381 | .Release => { | ||
| 382 | const reproducible_step = b.step("reproducible", "Ensure that stage3 and stage4 are byte-for-byte identical"); | ||
| 383 | |||
| 384 | const run_stage3_version = std.Build.Step.Run.create(b, "get stage3 version"); | ||
| 385 | run_stage3_version.step.max_rss = 40_452_096; | ||
| 386 | run_stage3_version.addFileArg(stage3_exe); | ||
| 387 | run_stage3_version.addArg("version"); | ||
| 388 | const stage3_version = run_stage3_version.captureStdOut(); | ||
| 389 | |||
| 390 | const build_stage4 = b.addRunArtifact(run_exe); | ||
| 391 | build_stage4.step.max_rss = 4_361_846_784; | ||
| 392 | build_stage4.addArgs(&.{ | ||
| 393 | "$2", | ||
| 394 | "build", | ||
| 395 | "$--maxrss", | ||
| 396 | b.fmt("{}", .{@max(build_stage4.step.max_rss, 7_000_000_000)}), | ||
| 397 | "$--build-file", | ||
| 398 | "$3", | ||
| 399 | "$--prefix", | ||
| 400 | "$4", | ||
| 401 | "$--cache-dir", | ||
| 402 | "$5", | ||
| 403 | "$--global-cache-dir", | ||
| 404 | "$6", | ||
| 405 | "-Denable-llvm", | ||
| 406 | "-Dno-lib", | ||
| 407 | "-Doptimize=ReleaseFast", | ||
| 408 | "-Dstrip", | ||
| 409 | "-Dtarget=$0", | ||
| 410 | "-Dcpu=$1", | ||
| 411 | "-Duse-zig-libcxx", | ||
| 412 | "-Dversion-string=@7", | ||
| 413 | "--", | ||
| 414 | host_triple, | ||
| 415 | host_cpu, | ||
| 416 | }); | ||
| 417 | build_stage4.addFileArg(stage3_exe); | ||
| 418 | build_stage4.addFileArg(build_file); | ||
| 419 | const stage4_prefix = build_stage4.addOutputDirectoryArg("stage4"); | ||
| 420 | build_stage4.addDirectoryArg(local_cache_dir); | ||
| 421 | build_stage4.addDirectoryArg(global_cache_dir); | ||
| 422 | build_stage4.addFileArg(stage3_version); | ||
| 423 | |||
| 424 | const cmp_exe = b.addExecutable(.{ | ||
| 425 | .name = "cmp", | ||
| 426 | .root_source_file = b.path("cmp.zig"), | ||
| 427 | .target = host_target, | ||
| 428 | .optimize = tool_optimize, | ||
| 429 | .strip = false, | ||
| 430 | }); | ||
| 431 | cmp_exe.step.max_rss = 267_403_264; | ||
| 432 | |||
| 433 | const run_cmp = std.Build.Step.Run.create(b, "Check stage3 and stage4 are byte-for-byte identical"); | ||
| 434 | run_cmp.step.max_rss = 8_495_104; | ||
| 435 | run_cmp.addArtifactArg(cmp_exe); | ||
| 436 | run_cmp.addFileArg(stage3_exe); | ||
| 437 | run_cmp.addFileArg(stage4_prefix.path(b, b.fmt("bin/zig{s}", .{host_exe_file_ext}))); | ||
| 438 | reproducible_step.dependOn(&run_cmp.step); | ||
| 439 | }, | ||
| 440 | } | ||
| 441 | |||
| 442 | if (binaryen_lazy_dep) |binaryen_dep| { | ||
| 443 | const update_stage1_step = b.step("update-stage1", "Test bootstrap after updating the stage1 wasm binary"); | ||
| 444 | |||
| 445 | const update_zig1 = std.Build.Step.Run.create(b, "update zig1"); | ||
| 446 | update_zig1.step.max_rss = 1_815_281_664; | ||
| 447 | update_zig1.addArtifactArg(run_exe); | ||
| 448 | update_zig1.addArgs(&.{ | ||
| 449 | "$0", | ||
| 450 | "build", | ||
| 451 | "$--maxrss", | ||
| 452 | b.fmt("{}", .{@max(update_zig1.step.max_rss, 7_000_000_000)}), | ||
| 453 | "$--build-file", | ||
| 454 | "$1", | ||
| 455 | "$--cache-dir", | ||
| 456 | "$2", | ||
| 457 | "$--global-cache-dir", | ||
| 458 | "$3", | ||
| 459 | "update-zig1", | ||
| 460 | "--path", | ||
| 461 | "$4", | ||
| 462 | "--", | ||
| 463 | }); | ||
| 464 | update_zig1.addFileArg(stage3_exe); | ||
| 465 | update_zig1.addFileArg(build_file); | ||
| 466 | update_zig1.addDirectoryArg(local_cache_dir); | ||
| 467 | update_zig1.addDirectoryArg(global_cache_dir); | ||
| 468 | update_zig1.addDirectoryArg(binaryen_dep.path("bin")); | ||
| 469 | if (run_chmod_step) |step| update_zig1.step.dependOn(step); | ||
| 470 | // Clobbering stage1 depends on all steps that use the original stage1 | ||
| 471 | if (build_cc_stage2_step) |step| update_zig1.step.dependOn(step); | ||
| 472 | update_zig1.step.dependOn(&build_stage3.step); | ||
| 473 | |||
| 474 | const build_updated_stage3 = std.Build.Step.Run.create(b, "build updated cmake bootstrap"); | ||
| 475 | build_updated_stage3.step.max_rss = 10_600_501_248; | ||
| 476 | build_updated_stage3.addArtifactArg(run_exe); | ||
| 477 | build_updated_stage3.addArgs(&.{ | ||
| 478 | "$4", | ||
| 479 | "-GNinja", | ||
| 480 | "-S..", | ||
| 481 | "-B$6", | ||
| 482 | "-DCMAKE_MAKE_PROGRAM=$5", | ||
| 483 | "-DCMAKE_BUILD_TYPE=$2", | ||
| 484 | "-DCMAKE_PREFIX_PATH=$7", | ||
| 485 | "-DCMAKE_C_COMPILER=$7/bin/zig$3;cc;-target;$0;-mcpu=$1", | ||
| 486 | "-DCMAKE_CXX_COMPILER=$7/bin/zig$3;c++;-target;$0;-mcpu=$1", | ||
| 487 | "-DCMAKE_AR=$7/bin/zig$3", | ||
| 488 | "-DZIG_AR_WORKAROUND=ON", | ||
| 489 | "-DZIG_TARGET_TRIPLE=$0", | ||
| 490 | "-DZIG_TARGET_MCPU=$1", | ||
| 491 | "-DZIG_STATIC=ON", | ||
| 492 | "-DZIG_STATIC_CURSES=OFF", | ||
| 493 | "-DZIG_NO_LIB=ON", | ||
| 494 | "--then", | ||
| 495 | "$5", | ||
| 496 | "-C", | ||
| 497 | "$6", | ||
| 498 | "install", | ||
| 499 | "--", | ||
| 500 | host_triple, | ||
| 501 | host_cpu, | ||
| 502 | @tagName(build_type), | ||
| 503 | host_exe_file_ext, | ||
| 504 | }); | ||
| 505 | build_updated_stage3.addFileArg(cmake_exe); | ||
| 506 | build_updated_stage3.addFileArg(ninja_exe); | ||
| 507 | const updated_stage3_exe = build_updated_stage3.addOutputDirectoryArg("build") | ||
| 508 | .path(b, b.fmt("stage3/bin/zig{s}", .{host_exe_file_ext})); | ||
| 509 | build_updated_stage3.addDirectoryArg(zig_llvm_lld_clang_dep.path("")); | ||
| 510 | build_updated_stage3.addFileInput(b.path("../stage1/zig1.wasm")); | ||
| 511 | build_updated_stage3.addFileInput(b.path("../stage1/zig.h")); | ||
| 512 | if (run_chmod_step) |step| build_updated_stage3.step.dependOn(step); | ||
| 513 | build_updated_stage3.step.dependOn(&update_zig1.step); | ||
| 514 | |||
| 515 | const build_updated_stage4 = b.addRunArtifact(run_exe); | ||
| 516 | build_updated_stage4.step.max_rss = 4_499_849_216; | ||
| 517 | build_updated_stage4.addArgs(&.{ | ||
| 518 | "$2", | ||
| 519 | "build", | ||
| 520 | "$--maxrss", | ||
| 521 | b.fmt("{}", .{@max(build_updated_stage4.step.max_rss, 7_000_000_000)}), | ||
| 522 | "$--build-file", | ||
| 523 | "$3", | ||
| 524 | "$--prefix", | ||
| 525 | "$4", | ||
| 526 | "$--cache-dir", | ||
| 527 | "$5", | ||
| 528 | "$--global-cache-dir", | ||
| 529 | "$6", | ||
| 530 | "-Denable-llvm", | ||
| 531 | "-Dno-lib", | ||
| 532 | "-Doptimize=ReleaseFast", | ||
| 533 | "-Dstrip", | ||
| 534 | "-Dtarget=$0", | ||
| 535 | "-Dcpu=$1", | ||
| 536 | "-Duse-zig-libcxx", | ||
| 537 | "--", | ||
| 538 | host_triple, | ||
| 539 | host_cpu, | ||
| 540 | }); | ||
| 541 | build_updated_stage4.addFileArg(updated_stage3_exe); | ||
| 542 | build_updated_stage4.addFileArg(build_file); | ||
| 543 | const updated_stage4_prefix = build_updated_stage4.addOutputDirectoryArg("stage4"); | ||
| 544 | build_updated_stage4.addDirectoryArg(local_cache_dir); | ||
| 545 | build_updated_stage4.addDirectoryArg(global_cache_dir); | ||
| 546 | |||
| 547 | const run_tests_with_updated_stage4 = std.Build.Step.Run.create(b, "test updated cmake bootstrap (stage3)"); | ||
| 548 | run_tests_with_updated_stage4.step.max_rss = 696_287_232; | ||
| 549 | run_tests_with_updated_stage4.addFileArg(updated_stage4_prefix.path(b, b.fmt("bin/zig{s}", .{host_exe_file_ext}))); | ||
| 550 | run_tests_with_updated_stage4.addArg("test"); | ||
| 551 | run_tests_with_updated_stage4.addFileArg(b.path("../test/behavior.zig")); | ||
| 552 | update_stage1_step.dependOn(&run_tests_with_updated_stage4.step); | ||
| 553 | } | ||
| 554 | |||
| 555 | msvc: { | ||
| 556 | const msvc_target = target: { | ||
| 557 | var target = host_target.result; | ||
| 558 | target.abi = .msvc; | ||
| 559 | break :target target; | ||
| 560 | }; | ||
| 561 | const libc = std.zig.LibCDirs.detect( | ||
| 562 | b.allocator, | ||
| 563 | b.pathFromRoot("../lib"), | ||
| 564 | msvc_target, | ||
| 565 | true, | ||
| 566 | true, | ||
| 567 | null, | ||
| 568 | ) catch |err| switch (err) { | ||
| 569 | error.WindowsSdkNotFound => break :msvc, | ||
| 570 | else => |e| @panic(@errorName(e)), | ||
| 571 | }; | ||
| 572 | const msvc_arch = switch (host_target.result.cpu.arch) { | ||
| 573 | .x86 => "x86", | ||
| 574 | .x86_64 => "x64", | ||
| 575 | .arm, .armeb, .thumb, .thumbeb => "arm", | ||
| 576 | .aarch64 => "arm64", | ||
| 577 | else => break :msvc, | ||
| 578 | }; | ||
| 579 | const cl_exe = b.pathResolve(&.{ | ||
| 580 | (libc.libc_installation orelse break :msvc).msvc_lib_dir orelse break :msvc, | ||
| 581 | "..", | ||
| 582 | "..", | ||
| 583 | "bin", | ||
| 584 | b.fmt("Host{s}", .{msvc_arch}), | ||
| 585 | msvc_arch, | ||
| 586 | b.fmt("cl{s}", .{host_exe_file_ext}), | ||
| 587 | }); | ||
| 588 | const msvc_triple = msvc_target.linuxTriple(b.allocator) catch @panic("OOM"); | ||
| 589 | |||
| 590 | const msvc_step = b.step("msvc", "Run the behavior tests compiled with MSVC"); | ||
| 591 | |||
| 592 | const build_msvc_behavior_tests = std.Build.Step.Run.create(b, "build msvc behavior tests"); | ||
| 593 | build_msvc_behavior_tests.step.max_rss = 213_237_760; | ||
| 594 | build_msvc_behavior_tests.addFileArg(stage3_exe); | ||
| 595 | build_msvc_behavior_tests.addArgs(&.{ | ||
| 596 | "test", | ||
| 597 | "-ofmt=c", | ||
| 598 | "--test-no-exec", | ||
| 599 | "-target", | ||
| 600 | msvc_triple, | ||
| 601 | "-lc", | ||
| 602 | }); | ||
| 603 | build_msvc_behavior_tests.addFileArg(b.path("../test/behavior.zig")); | ||
| 604 | const behavior_msvc_source = | ||
| 605 | build_msvc_behavior_tests.addPrefixedOutputFileArg("-femit-bin=", "behavior-msvc.c"); | ||
| 606 | |||
| 607 | const build_msvc_compiler_rt = std.Build.Step.Run.create(b, "build msvc compiler-rt"); | ||
| 608 | build_msvc_compiler_rt.step.max_rss = 217_788_416; | ||
| 609 | build_msvc_compiler_rt.addFileArg(stage3_exe); | ||
| 610 | build_msvc_compiler_rt.addArgs(&.{ | ||
| 611 | "build-obj", | ||
| 612 | "-ofmt=c", | ||
| 613 | "-OReleaseSmall", | ||
| 614 | "--name", | ||
| 615 | "compiler_rt", | ||
| 616 | "-target", | ||
| 617 | msvc_triple, | ||
| 618 | "-lc", | ||
| 619 | }); | ||
| 620 | build_msvc_compiler_rt.addFileArg(b.path("../lib/compiler_rt.zig")); | ||
| 621 | const compiler_rt_msvc_source = | ||
| 622 | build_msvc_compiler_rt.addPrefixedOutputFileArg("-femit-bin=", "compiler_rt-msvc.c"); | ||
| 623 | |||
| 624 | const build_msvc_tests = std.Build.Step.Run.create(b, "build msvc tests"); | ||
| 625 | build_msvc_tests.step.max_rss = 599_506_944; | ||
| 626 | build_msvc_tests.addArgs(&.{ cl_exe, "/W3", "/Z7" }); | ||
| 627 | build_msvc_tests.addPrefixedDirectoryArg("/I", b.path("../lib")); | ||
| 628 | build_msvc_tests.addFileArg(behavior_msvc_source); | ||
| 629 | build_msvc_tests.addFileArg(compiler_rt_msvc_source); | ||
| 630 | const msvc_tests_exe = build_msvc_tests.addPrefixedOutputFileArg( | ||
| 631 | "/Fe:", | ||
| 632 | b.fmt("behavior-msvc{s}", .{host_exe_file_ext}), | ||
| 633 | ); | ||
| 634 | // Link args must appear after all other args. | ||
| 635 | build_msvc_tests.addArgs(&.{ | ||
| 636 | "/link", | ||
| 637 | "/nologo", | ||
| 638 | "/debug", | ||
| 639 | "/subsystem:console", | ||
| 640 | "kernel32.lib", | ||
| 641 | "ntdll.lib", | ||
| 642 | "libcmt.lib", | ||
| 643 | }); | ||
| 644 | build_msvc_tests.setEnvironmentVariable("INCLUDE", std.mem.join( | ||
| 645 | b.allocator, | ||
| 646 | &.{std.fs.path.delimiter}, | ||
| 647 | libc.libc_include_dir_list, | ||
| 648 | ) catch @panic("OOM")); | ||
| 649 | build_msvc_tests.setEnvironmentVariable("LIB", std.mem.join( | ||
| 650 | b.allocator, | ||
| 651 | &.{std.fs.path.delimiter}, | ||
| 652 | &.{ | ||
| 653 | libc.libc_installation.?.msvc_lib_dir.?, | ||
| 654 | libc.libc_installation.?.crt_dir.?, | ||
| 655 | libc.libc_installation.?.kernel32_lib_dir.?, | ||
| 656 | }, | ||
| 657 | ) catch @panic("OOM")); | ||
| 658 | |||
| 659 | const run_msvc_tests = std.Build.Step.Run.create(b, "run msvc tests"); | ||
| 660 | run_msvc_tests.step.max_rss = 6_574_080; | ||
| 661 | run_msvc_tests.addFileArg(msvc_tests_exe); | ||
| 662 | msvc_step.dependOn(&run_msvc_tests.step); | ||
| 663 | } | ||
| 664 | } | ||
| 665 | } | ||
ci/build.zig.zon created+188| ... | @@ -0,0 +1,188 @@ | ||
| 1 | .{ | ||
| 2 | .name = "zig/ci", | ||
| 3 | .version = "0.0.0", | ||
| 4 | .paths = .{""}, | ||
| 5 | .dependencies = .{ | ||
| 6 | .@"binaryen-x86_64-linux-musl" = .{ | ||
| 7 | .hash = "12207d5dd577b7cc822cc007bdc06411fac7f536243afff77f6a181df1987f99b610", | ||
| 8 | .url = "https://github.com/WebAssembly/binaryen/releases/download/version_117/binaryen-version_117-x86_64-linux.tar.gz", | ||
| 9 | .lazy = true, | ||
| 10 | }, | ||
| 11 | .@"binaryen-aarch64-linux-musl" = .{ | ||
| 12 | .hash = "12207fa9d8edc6d3cb3e56ad5df7ed6205bea4a0712946d1115689ec4e8b6c6013c7", | ||
| 13 | .url = "https://github.com/WebAssembly/binaryen/releases/download/version_117/binaryen-version_117-aarch64-linux.tar.gz", | ||
| 14 | .lazy = true, | ||
| 15 | }, | ||
| 16 | .@"binaryen-x86_64-macos-none" = .{ | ||
| 17 | .hash = "12207e36613e24971953f70ee13654f5b91a279f95f71c930702ba913878b19a91d3", | ||
| 18 | .url = "https://github.com/WebAssembly/binaryen/releases/download/version_117/binaryen-version_117-x86_64-macos.tar.gz", | ||
| 19 | .lazy = true, | ||
| 20 | }, | ||
| 21 | .@"binaryen-aarch64-macos-none" = .{ | ||
| 22 | .hash = "122042c3690f6a477febcb4c68568c03bd3409c517e0d9037e06010fff003a4efcc0", | ||
| 23 | .url = "https://github.com/WebAssembly/binaryen/releases/download/version_117/binaryen-version_117-arm64-macos.tar.gz", | ||
| 24 | .lazy = true, | ||
| 25 | }, | ||
| 26 | .@"binaryen-x86_64-windows-gnu" = .{ | ||
| 27 | .hash = "122046d1b9b8e32c6198520178862b2079ffd2021a03a1f5f8dd6f5b474672dd0217", | ||
| 28 | .url = "https://github.com/WebAssembly/binaryen/releases/download/version_117/binaryen-version_117-x86_64-windows.tar.gz", | ||
| 29 | .lazy = true, | ||
| 30 | }, | ||
| 31 | |||
| 32 | .@"cmake-x86_64-linux-musl" = .{ | ||
| 33 | .hash = "1220e08f2db1f68d20caeb41d923d1e468ef53e0973d02c1a00c2d517b011e121c40", | ||
| 34 | .url = "https://github.com/Kitware/CMake/releases/download/v3.29.2/cmake-3.29.2-linux-x86_64.tar.gz", | ||
| 35 | .lazy = true, | ||
| 36 | }, | ||
| 37 | .@"cmake-aarch64-linux-musl" = .{ | ||
| 38 | .hash = "1220a16a663bb2be43a236cb945bac8957be27c6edac8f630e81123fc99f7b2b2de9", | ||
| 39 | .url = "https://github.com/Kitware/CMake/releases/download/v3.29.2/cmake-3.29.2-linux-aarch64.tar.gz", | ||
| 40 | .lazy = true, | ||
| 41 | }, | ||
| 42 | .@"cmake-x86_64-macos-none" = .{ | ||
| 43 | .hash = "1220d158a5c05cfa2f20d339ec5503c79e96d61a21fe81fd6710c815f2cdcf6e3da0", | ||
| 44 | .url = "https://github.com/Kitware/CMake/releases/download/v3.29.2/cmake-3.29.2-macos-universal.tar.gz", | ||
| 45 | .lazy = true, | ||
| 46 | }, | ||
| 47 | .@"cmake-aarch64-macos-none" = .{ | ||
| 48 | .hash = "1220d158a5c05cfa2f20d339ec5503c79e96d61a21fe81fd6710c815f2cdcf6e3da0", | ||
| 49 | .url = "https://github.com/Kitware/CMake/releases/download/v3.29.2/cmake-3.29.2-macos-universal.tar.gz", | ||
| 50 | .lazy = true, | ||
| 51 | }, | ||
| 52 | .@"cmake-x86_64-windows-gnu" = .{ | ||
| 53 | .hash = "12204ff75c21a274e8d4803b77d4699d37f42974d039e398b28cdea7ea2cc1fa3376", | ||
| 54 | .url = "https://github.com/Kitware/CMake/releases/download/v3.29.2/cmake-3.29.2-windows-x86_64.zip", | ||
| 55 | .lazy = true, | ||
| 56 | }, | ||
| 57 | .@"cmake-aarch64-windows-gnu" = .{ | ||
| 58 | .hash = "12201d1c55e49eecfcbcf0347af9edc4396c2f3a12ab682f3da61d6f310b617753a2", | ||
| 59 | .url = "https://github.com/Kitware/CMake/releases/download/v3.29.2/cmake-3.29.2-windows-arm64.zip", | ||
| 60 | .lazy = true, | ||
| 61 | }, | ||
| 62 | |||
| 63 | .@"ninja-x86_64-linux-musl" = .{ | ||
| 64 | .hash = "12206a681b6a380e8b380120f8c4e6688bc67b587b01091b019d722f74dca33ad012", | ||
| 65 | .url = "https://github.com/ninja-build/ninja/releases/download/v1.12.0/ninja-linux.zip", | ||
| 66 | .lazy = true, | ||
| 67 | }, | ||
| 68 | .@"ninja-aarch64-linux-musl" = .{ | ||
| 69 | .hash = "1220480757926ac5ade22fc2a4b39bde33e03480eb0d5e7087474ca4b81b8426e6b6", | ||
| 70 | .url = "https://github.com/ninja-build/ninja/releases/download/v1.12.0/ninja-linux-aarch64.zip", | ||
| 71 | .lazy = true, | ||
| 72 | }, | ||
| 73 | .@"ninja-x86_64-macos-none" = .{ | ||
| 74 | .hash = "1220978a9f52d9dff7614814ec52381aa709ea63a333249549c02f0b917c65733f5a", | ||
| 75 | .url = "https://github.com/ninja-build/ninja/releases/download/v1.12.0/ninja-mac.zip", | ||
| 76 | .lazy = true, | ||
| 77 | }, | ||
| 78 | .@"ninja-aarch64-macos-none" = .{ | ||
| 79 | .hash = "1220978a9f52d9dff7614814ec52381aa709ea63a333249549c02f0b917c65733f5a", | ||
| 80 | .url = "https://github.com/ninja-build/ninja/releases/download/v1.12.0/ninja-mac.zip", | ||
| 81 | .lazy = true, | ||
| 82 | }, | ||
| 83 | .@"ninja-x86_64-windows-gnu" = .{ | ||
| 84 | .hash = "1220543c9071fd6d5f16d2d5a64473cf252266b2928f9947c3b87a87de6d983724df", | ||
| 85 | .url = "https://github.com/ninja-build/ninja/releases/download/v1.12.0/ninja-win.zip", | ||
| 86 | .lazy = true, | ||
| 87 | }, | ||
| 88 | .@"ninja-aarch64-windows-gnu" = .{ | ||
| 89 | .hash = "12207d071c13ee8539a3445ea198243c12c917492411c3e7dfd8b54ff1714d759a73", | ||
| 90 | .url = "https://github.com/ninja-build/ninja/releases/download/v1.12.0/ninja-winarm64.zip", | ||
| 91 | .lazy = true, | ||
| 92 | }, | ||
| 93 | |||
| 94 | .@"qemu-x86_64-linux-musl" = .{ | ||
| 95 | .hash = "122077e46a30ef6fee9b98aedc50bc613a5d37c038d2ac823445951d1cd8bbc0e162", | ||
| 96 | .url = "https://ziglang.org/deps/qemu-linux-x86_64-8.2.1.tar.xz", | ||
| 97 | .lazy = true, | ||
| 98 | }, | ||
| 99 | |||
| 100 | .@"tidy-x86_64-linux-musl" = .{ | ||
| 101 | .hash = "1220b07c11837da15ae5f44201327cf3a1d554c650b384429f48d8234be8942ddc9d", | ||
| 102 | .url = "https://github.com/jacobly0/zig-tidy/releases/download/5.8.0/tidy-5.8.0-x86_64-linux-musl.tar.xz", | ||
| 103 | .lazy = true, | ||
| 104 | }, | ||
| 105 | .@"tidy-aarch64-linux-musl" = .{ | ||
| 106 | .hash = "122006a2ede0400f00789abe48e47861e5bbab7f8ca16789db4bd9e351299c4ac590", | ||
| 107 | .url = "https://github.com/jacobly0/zig-tidy/releases/download/5.8.0/tidy-5.8.0-aarch64-linux-musl.tar.xz", | ||
| 108 | .lazy = true, | ||
| 109 | }, | ||
| 110 | .@"tidy-x86_64-macos-none" = .{ | ||
| 111 | .hash = "1220f18256987f627618a21fde39f3cda13ac7bd6f01f35c9ccbb9e07ea81ca77cfc", | ||
| 112 | .url = "https://github.com/jacobly0/zig-tidy/releases/download/5.8.0/tidy-5.8.0-x86_64-macos-none.tar.xz", | ||
| 113 | .lazy = true, | ||
| 114 | }, | ||
| 115 | .@"tidy-aarch64-macos-none" = .{ | ||
| 116 | .hash = "1220a8ee39addf48e3be546616fe14853e3db1cb49522bd90a24bade371330176826", | ||
| 117 | .url = "https://github.com/jacobly0/zig-tidy/releases/download/5.8.0/tidy-5.8.0-aarch64-macos-none.tar.xz", | ||
| 118 | .lazy = true, | ||
| 119 | }, | ||
| 120 | .@"tidy-x86_64-windows-gnu" = .{ | ||
| 121 | .hash = "12205c2cb107a59e552947a51a302296912bd097fcf1414e9a7521ce8ededb915574", | ||
| 122 | .url = "https://github.com/jacobly0/zig-tidy/releases/download/5.8.0/tidy-5.8.0-x86_64-windows-gnu.zip", | ||
| 123 | .lazy = true, | ||
| 124 | }, | ||
| 125 | .@"tidy-aarch64-windows-gnu" = .{ | ||
| 126 | .hash = "1220dce14dc654e391c06c7e1d5b078355195286350cb8cab8e1f21f3a08df716736", | ||
| 127 | .url = "https://github.com/jacobly0/zig-tidy/releases/download/5.8.0/tidy-5.8.0-aarch64-windows-gnu.zip", | ||
| 128 | .lazy = true, | ||
| 129 | }, | ||
| 130 | |||
| 131 | .@"wasmtime-x86_64-linux-musl" = .{ | ||
| 132 | .hash = "122062e8c3f052636b68b60f096eab11618a010ee67e5ec772d5c41362e471c30607", | ||
| 133 | .url = "https://github.com/bytecodealliance/wasmtime/releases/download/v13.0.1/wasmtime-v13.0.1-x86_64-linux.tar.xz", | ||
| 134 | .lazy = true, | ||
| 135 | }, | ||
| 136 | .@"wasmtime-aarch64-linux-musl" = .{ | ||
| 137 | .hash = "122069362558cae6da16d5de27a23b793bcd604bbbeb908ee8af25a1f9e48ce0d87b", | ||
| 138 | .url = "https://github.com/bytecodealliance/wasmtime/releases/download/v13.0.1/wasmtime-v13.0.1-aarch64-linux.tar.xz", | ||
| 139 | .lazy = true, | ||
| 140 | }, | ||
| 141 | .@"wasmtime-x86_64-macos-none" = .{ | ||
| 142 | .hash = "12205fbb7d93b7e41f74565b1b8df5862834d5b8e1676ad9d5814127f8ea79c6d923", | ||
| 143 | .url = "https://github.com/bytecodealliance/wasmtime/releases/download/v13.0.1/wasmtime-v13.0.1-x86_64-macos.tar.xz", | ||
| 144 | .lazy = true, | ||
| 145 | }, | ||
| 146 | .@"wasmtime-aarch64-macos-none" = .{ | ||
| 147 | .hash = "122021a51bda85da636583101f1815432b4b421d1506db459640af13fe28795ad5a0", | ||
| 148 | .url = "https://github.com/bytecodealliance/wasmtime/releases/download/v13.0.1/wasmtime-v13.0.1-aarch64-macos.tar.xz", | ||
| 149 | .lazy = true, | ||
| 150 | }, | ||
| 151 | .@"wasmtime-x86_64-windows-gnu" = .{ | ||
| 152 | .hash = "12206dd597841bb2e048996c650ae66b621c25c0e59d2555b4abf242d4b6deb16151", | ||
| 153 | .url = "https://github.com/bytecodealliance/wasmtime/releases/download/v13.0.1/wasmtime-v13.0.1-x86_64-windows.zip", | ||
| 154 | .lazy = true, | ||
| 155 | }, | ||
| 156 | |||
| 157 | .@"zig+llvm+lld+clang-x86_64-linux-musl" = .{ | ||
| 158 | .hash = "12202441821c4e916ab128580655d8189610ca66c85fcc2545629c509e211cc88f8f", | ||
| 159 | .url = "https://ziglang.org/deps/zig+llvm+lld+clang-x86_64-linux-musl-0.13.0-dev.130+98a30acad.tar.xz", | ||
| 160 | .lazy = true, | ||
| 161 | }, | ||
| 162 | .@"zig+llvm+lld+clang-aarch64-linux-musl" = .{ | ||
| 163 | .hash = "122007c945ba64a5103b6ee10455c7e6b89d8d5de5887034df5b9d1b5c1dc8a0a4c1", | ||
| 164 | .url = "https://ziglang.org/deps/zig+llvm+lld+clang-aarch64-linux-musl-0.13.0-dev.130+98a30acad.tar.xz", | ||
| 165 | .lazy = true, | ||
| 166 | }, | ||
| 167 | .@"zig+llvm+lld+clang-x86_64-macos-none" = .{ | ||
| 168 | .hash = "1220451d009ecda5092b59835ba65ea5d5ca04046436aab6f2fd113c00c7e794b860", | ||
| 169 | .url = "https://ziglang.org/deps/zig+llvm+lld+clang-x86_64-macos-none-0.13.0-dev.130+98a30acad.tar.xz", | ||
| 170 | .lazy = true, | ||
| 171 | }, | ||
| 172 | .@"zig+llvm+lld+clang-aarch64-macos-none" = .{ | ||
| 173 | .hash = "1220c6e8b6fd8eb397a8e54139ae0baec6583a7f72e509623437ff255ebc278822a1", | ||
| 174 | .url = "https://ziglang.org/deps/zig+llvm+lld+clang-aarch64-macos-none-0.13.0-dev.130+98a30acad.tar.xz", | ||
| 175 | .lazy = true, | ||
| 176 | }, | ||
| 177 | .@"zig+llvm+lld+clang-x86_64-windows-gnu" = .{ | ||
| 178 | .hash = "12204a122b74c73de3b84d0626b99a5e355a037fc7b1c8ffa14c9d7bdc2e9a40d3d3", | ||
| 179 | .url = "https://ziglang.org/deps/zig+llvm+lld+clang-x86_64-windows-gnu-0.13.0-dev.130+98a30acad.zip", | ||
| 180 | .lazy = true, | ||
| 181 | }, | ||
| 182 | .@"zig+llvm+lld+clang-aarch64-windows-gnu" = .{ | ||
| 183 | .hash = "1220f756f38997a4f89d620aa77a2db21463ed7cc2dff5574e835894bb1969dfca95", | ||
| 184 | .url = "https://ziglang.org/deps/zig+llvm+lld+clang-aarch64-windows-gnu-0.13.0-dev.130+98a30acad.zip", | ||
| 185 | .lazy = true, | ||
| 186 | }, | ||
| 187 | }, | ||
| 188 | } | ||
ci/chmod.zig created+32| ... | @@ -0,0 +1,32 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | |||
| 3 | pub fn main() !void { | ||
| 4 | var args_it = try std.process.argsWithAllocator(std.heap.page_allocator); | ||
| 5 | defer args_it.deinit(); | ||
| 6 | _ = args_it.skip(); | ||
| 7 | while (args_it.next()) |path| { | ||
| 8 | const file = std.fs.cwd().openFile(path, .{}) catch |err| switch (err) { | ||
| 9 | error.FileNotFound, error.NotDir => continue, | ||
| 10 | else => |e| return e, | ||
| 11 | }; | ||
| 12 | defer file.close(); | ||
| 13 | var got_access_denied = false; | ||
| 14 | while (true) { | ||
| 15 | const old_mode = try file.mode(); | ||
| 16 | const new_mode = old_mode | (std.posix.S.IXUSR | std.posix.S.IXGRP | std.posix.S.IXOTH); | ||
| 17 | if (new_mode != old_mode) file.chmod(new_mode) catch |err| switch (err) { | ||
| 18 | // This can happen on macOS during a race condition where another process adds the | ||
| 19 | // executable bits and executes the file between this process reading the old mode | ||
| 20 | // and setting the new mode. In the case, getting the mode again will return the | ||
| 21 | // newly set executable bits and so this code will not be reached the second time. | ||
| 22 | error.AccessDenied => |e| { | ||
| 23 | if (got_access_denied) return e; | ||
| 24 | got_access_denied = true; | ||
| 25 | continue; | ||
| 26 | }, | ||
| 27 | else => |e| return e, | ||
| 28 | }; | ||
| 29 | break; | ||
| 30 | } | ||
| 31 | } | ||
| 32 | } | ||
ci/cmp.zig created+28| ... | @@ -0,0 +1,28 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | |||
| 3 | pub fn main() !void { | ||
| 4 | var args = try std.process.argsWithAllocator(std.heap.page_allocator); | ||
| 5 | _ = args.skip(); | ||
| 6 | const first_path = args.next().?; | ||
| 7 | const first_file = try std.fs.cwd().openFile(first_path, .{}); | ||
| 8 | const second_path = args.next().?; | ||
| 9 | const second_file = try std.fs.cwd().openFile(second_path, .{}); | ||
| 10 | |||
| 11 | var first_buffer: [1 << 18]u8 = undefined; | ||
| 12 | var second_buffer: [1 << 18]u8 = undefined; | ||
| 13 | var offset: u64 = 0; | ||
| 14 | while (true) { | ||
| 15 | const first_data = first_buffer[0..try first_file.reader().readAll(&first_buffer)]; | ||
| 16 | const second_data = second_buffer[0..try second_file.reader().readAll(&second_buffer)]; | ||
| 17 | if (std.mem.indexOfDiff(u8, first_data, second_data)) |diff_index| { | ||
| 18 | try std.io.getStdErr().writer().print("{s} {s} differ: byte {d}\n", .{ | ||
| 19 | first_path, | ||
| 20 | second_path, | ||
| 21 | offset + diff_index + 1, | ||
| 22 | }); | ||
| 23 | std.process.exit(1); | ||
| 24 | } | ||
| 25 | offset += first_data.len; | ||
| 26 | if (first_data.len < first_buffer.len) break; | ||
| 27 | } | ||
| 28 | } | ||
ci/run.zig created+126| ... | @@ -0,0 +1,126 @@ | ||
| 1 | //! ./runner command0 [arg0 arg1 ...] [--then command1 arg0 arg1 ...] [--path path0 path1 ...] [--cwd cwd] [--delete file0 file1 ...] [--rename old0 new0 [old1 new1 ...]] -- [replacement0 replacement1 ... replacement9] | ||
| 2 | //! Replaces $0 through $9 in all non-option arguments with replacement0 through replacement9, | ||
| 3 | //! which have native path separators replaced with posix path separators. | ||
| 4 | //! Replaces @0 through @9 in all non-option arguments with the contents of the file | ||
| 5 | //! replacement0 through replacement9. | ||
| 6 | //! Then, executes the command before any option arguments with extra paths after --path and at optional cwd after --cwd. | ||
| 7 | //! Then, executes the command after --then with extra paths after --path and at optional cwd after --cwd. | ||
| 8 | //! Then, optionally deletes files after --delete. | ||
| 9 | //! Then, optionally renomes pairs of files after --rename. | ||
| 10 | |||
| 11 | const std = @import("std"); | ||
| 12 | |||
| 13 | pub fn main() !void { | ||
| 14 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); | ||
| 15 | const allocator = arena.allocator(); | ||
| 16 | |||
| 17 | const args = try std.process.argsAlloc(allocator); | ||
| 18 | var first: [][]u8 = &.{}; | ||
| 19 | var then: [][]u8 = &.{}; | ||
| 20 | var cwd: [][]u8 = &.{}; | ||
| 21 | var path: [][]u8 = &.{}; | ||
| 22 | var delete: [][]u8 = &.{}; | ||
| 23 | var rename: [][]u8 = &.{}; | ||
| 24 | var replacements: [][]u8 = &.{}; | ||
| 25 | |||
| 26 | var prev_separator_index: usize = 0; | ||
| 27 | var separator_index: usize = 1; | ||
| 28 | while (separator_index < args.len) : (separator_index += 1) { | ||
| 29 | if (!std.mem.startsWith(u8, args[separator_index], "--")) continue; | ||
| 30 | const separated_args = args[prev_separator_index + 1 .. separator_index]; | ||
| 31 | if (prev_separator_index == 0) | ||
| 32 | first = separated_args | ||
| 33 | else if (std.mem.eql(u8, args[prev_separator_index], "--then")) | ||
| 34 | then = separated_args | ||
| 35 | else if (std.mem.eql(u8, args[prev_separator_index], "--cwd")) | ||
| 36 | cwd = separated_args | ||
| 37 | else if (std.mem.eql(u8, args[prev_separator_index], "--path")) | ||
| 38 | path = separated_args | ||
| 39 | else if (std.mem.eql(u8, args[prev_separator_index], "--delete")) | ||
| 40 | delete = separated_args | ||
| 41 | else if (std.mem.eql(u8, args[prev_separator_index], "--rename")) | ||
| 42 | rename = separated_args | ||
| 43 | else | ||
| 44 | std.debug.panic("unexpected '{s}'", .{args[prev_separator_index]}); | ||
| 45 | if (args[separator_index].len == 2) { | ||
| 46 | replacements = args[separator_index + 1 ..]; | ||
| 47 | break; | ||
| 48 | } | ||
| 49 | prev_separator_index = separator_index; | ||
| 50 | } else std.debug.panic("expected '--'", .{}); | ||
| 51 | |||
| 52 | if (first.len == 0) std.debug.panic("expected arguments", .{}); | ||
| 53 | if (cwd.len > 1) std.debug.panic("expected at most 1 cwd argument", .{}); | ||
| 54 | if (rename.len % 2 != 0) std.debug.panic("expected even rename arguments", .{}); | ||
| 55 | |||
| 56 | for (replacements) |replacement| std.mem.replaceScalar( | ||
| 57 | u8, | ||
| 58 | replacement, | ||
| 59 | std.fs.path.sep, | ||
| 60 | std.fs.path.sep_posix, | ||
| 61 | ); | ||
| 62 | for ([_][][]u8{ first, then, cwd, path, delete, rename }) |patterns| for (patterns) |*pattern| { | ||
| 63 | var replaced = std.ArrayList(u8).init(allocator); | ||
| 64 | var pos: usize = 0; | ||
| 65 | while (std.mem.indexOfAnyPos(u8, pattern.*, pos, "$@")) |special_pos| { | ||
| 66 | try replaced.appendSlice(pattern.*[pos..special_pos]); | ||
| 67 | const special = pattern.*[special_pos..][0..2]; | ||
| 68 | if (std.fmt.charToDigit(special[1], 10)) |special_index| switch (special[0]) { | ||
| 69 | '$' => try replaced.appendSlice(replacements[special_index]), | ||
| 70 | '@' => { | ||
| 71 | const special_file = try std.fs.cwd().openFile(replacements[special_index], .{}); | ||
| 72 | defer special_file.close(); | ||
| 73 | try special_file.reader().readAllArrayList(&replaced, 1 << 12); | ||
| 74 | replaced.shrinkRetainingCapacity(std.mem.trimRight(u8, replaced.items, &std.ascii.whitespace).len); | ||
| 75 | }, | ||
| 76 | else => unreachable, | ||
| 77 | } else |_| switch (special[0]) { | ||
| 78 | '$' => try replaced.append(special[1]), | ||
| 79 | else => unreachable, | ||
| 80 | } | ||
| 81 | pos = special_pos + 2; | ||
| 82 | } | ||
| 83 | try replaced.appendSlice(pattern.*[pos..]); | ||
| 84 | pattern.* = replaced.items; | ||
| 85 | }; | ||
| 86 | |||
| 87 | var path_buffer = std.ArrayList(u8).init(allocator); | ||
| 88 | for (path) |path_path| { | ||
| 89 | try path_buffer.appendSlice(path_path); | ||
| 90 | try path_buffer.append(std.fs.path.delimiter); | ||
| 91 | } | ||
| 92 | var env = try std.process.getEnvMap(allocator); | ||
| 93 | if (env.getPtr("PATH")) |env_path| { | ||
| 94 | try path_buffer.appendSlice(env_path.*); | ||
| 95 | env_path.* = try path_buffer.toOwnedSlice(); | ||
| 96 | } else if (path_buffer.items.len > 0) try env.putMove( | ||
| 97 | try allocator.dupe(u8, "PATH"), | ||
| 98 | path_buffer.items[0 .. path_buffer.items.len - 1], | ||
| 99 | ); | ||
| 100 | |||
| 101 | var first_child = std.process.Child.init(first, allocator); | ||
| 102 | first_child.env_map = &env; | ||
| 103 | if (cwd.len == 1) first_child.cwd = cwd[0]; | ||
| 104 | switch (try first_child.spawnAndWait()) { | ||
| 105 | .Exited => |status| if (status != 0) std.process.exit(status), | ||
| 106 | else => |term| std.debug.panic("{}", .{term}), | ||
| 107 | } | ||
| 108 | |||
| 109 | if (then.len > 0) { | ||
| 110 | var then_child = std.process.Child.init(then, allocator); | ||
| 111 | then_child.env_map = &env; | ||
| 112 | if (cwd.len == 1) then_child.cwd = cwd[0]; | ||
| 113 | switch (try then_child.spawnAndWait()) { | ||
| 114 | .Exited => |status| if (status != 0) std.process.exit(status), | ||
| 115 | else => |term| std.debug.panic("{}", .{term}), | ||
| 116 | } | ||
| 117 | } | ||
| 118 | |||
| 119 | for (delete) |delete_path| try std.fs.cwd().deleteFile(delete_path); | ||
| 120 | |||
| 121 | var rename_index: usize = 0; | ||
| 122 | while (rename_index < rename.len) : (rename_index += 2) try std.fs.cwd().rename( | ||
| 123 | rename[rename_index + 0], | ||
| 124 | rename[rename_index + 1], | ||
| 125 | ); | ||
| 126 | } | ||
ci/x86_64-linux-debug.sh deleted-108| ... | @@ -1,108 +0,0 @@ | ||
| 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.13.0-dev.130+98a30acad" | ||
| 12 | PREFIX="$HOME/deps/$CACHE_BASENAME" | ||
| 13 | ZIG="$PREFIX/bin/zig" | ||
| 14 | |||
| 15 | export PATH="$HOME/deps/wasmtime-v10.0.2-$ARCH-linux:$HOME/deps/qemu-linux-x86_64-8.2.1/bin:$PATH" | ||
| 16 | |||
| 17 | # Make the `zig version` number consistent. | ||
| 18 | # This will affect the cmake command below. | ||
| 19 | git fetch --unshallow || true | ||
| 20 | git fetch --tags | ||
| 21 | |||
| 22 | # Test building from source without LLVM. | ||
| 23 | git clean -fd | ||
| 24 | rm -rf zig-out | ||
| 25 | cc -o bootstrap bootstrap.c | ||
| 26 | ./bootstrap | ||
| 27 | ./zig2 build -Dno-lib | ||
| 28 | ./zig-out/bin/zig test test/behavior.zig | ||
| 29 | |||
| 30 | export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" | ||
| 31 | export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" | ||
| 32 | |||
| 33 | rm -rf build-debug | ||
| 34 | mkdir build-debug | ||
| 35 | cd build-debug | ||
| 36 | |||
| 37 | # Override the cache directories because they won't actually help other CI runs | ||
| 38 | # which will be testing alternate versions of zig, and ultimately would just | ||
| 39 | # fill up space on the hard drive for no reason. | ||
| 40 | export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache" | ||
| 41 | export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache" | ||
| 42 | |||
| 43 | cmake .. \ | ||
| 44 | -DCMAKE_INSTALL_PREFIX="stage3-debug" \ | ||
| 45 | -DCMAKE_PREFIX_PATH="$PREFIX" \ | ||
| 46 | -DCMAKE_BUILD_TYPE=Debug \ | ||
| 47 | -DZIG_TARGET_TRIPLE="$TARGET" \ | ||
| 48 | -DZIG_TARGET_MCPU="$MCPU" \ | ||
| 49 | -DZIG_STATIC=ON \ | ||
| 50 | -DZIG_NO_LIB=ON \ | ||
| 51 | -GNinja | ||
| 52 | |||
| 53 | # Now cmake will use zig as the C/C++ compiler. We reset the environment variables | ||
| 54 | # so that installation and testing do not get affected by them. | ||
| 55 | unset CC | ||
| 56 | unset CXX | ||
| 57 | |||
| 58 | ninja install | ||
| 59 | |||
| 60 | # simultaneously test building self-hosted without LLVM and with 32-bit arm | ||
| 61 | stage3-debug/bin/zig build \ | ||
| 62 | -Dtarget=arm-linux-musleabihf \ | ||
| 63 | -Dno-lib | ||
| 64 | |||
| 65 | stage3-debug/bin/zig build test docs \ | ||
| 66 | --maxrss 21000000000 \ | ||
| 67 | -fqemu \ | ||
| 68 | -fwasmtime \ | ||
| 69 | -Dstatic-llvm \ | ||
| 70 | -Dtarget=native-native-musl \ | ||
| 71 | --search-prefix "$PREFIX" \ | ||
| 72 | --zig-lib-dir "$PWD/../lib" \ | ||
| 73 | -Denable-tidy | ||
| 74 | |||
| 75 | # Ensure that updating the wasm binary from this commit will result in a viable build. | ||
| 76 | stage3-debug/bin/zig build update-zig1 | ||
| 77 | |||
| 78 | rm -rf ../build-new | ||
| 79 | mkdir ../build-new | ||
| 80 | cd ../build-new | ||
| 81 | |||
| 82 | export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache" | ||
| 83 | export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache" | ||
| 84 | export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" | ||
| 85 | export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" | ||
| 86 | |||
| 87 | cmake .. \ | ||
| 88 | -DCMAKE_PREFIX_PATH="$PREFIX" \ | ||
| 89 | -DCMAKE_BUILD_TYPE=Debug \ | ||
| 90 | -DZIG_TARGET_TRIPLE="$TARGET" \ | ||
| 91 | -DZIG_TARGET_MCPU="$MCPU" \ | ||
| 92 | -DZIG_STATIC=ON \ | ||
| 93 | -DZIG_NO_LIB=ON \ | ||
| 94 | -GNinja | ||
| 95 | |||
| 96 | unset CC | ||
| 97 | unset CXX | ||
| 98 | |||
| 99 | ninja install | ||
| 100 | |||
| 101 | stage3/bin/zig test ../test/behavior.zig | ||
| 102 | stage3/bin/zig build -p stage4 \ | ||
| 103 | -Dstatic-llvm \ | ||
| 104 | -Dtarget=native-native-musl \ | ||
| 105 | -Dno-lib \ | ||
| 106 | --search-prefix "$PREFIX" \ | ||
| 107 | --zig-lib-dir "$PWD/../lib" | ||
| 108 | stage4/bin/zig test ../test/behavior.zig | ||
ci/x86_64-linux-release.sh deleted-124| ... | @@ -1,124 +0,0 @@ | ||
| 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.13.0-dev.130+98a30acad" | ||
| 12 | PREFIX="$HOME/deps/$CACHE_BASENAME" | ||
| 13 | ZIG="$PREFIX/bin/zig" | ||
| 14 | |||
| 15 | export PATH="$HOME/deps/wasmtime-v10.0.2-$ARCH-linux:$HOME/deps/qemu-linux-x86_64-8.2.1/bin:$PATH" | ||
| 16 | |||
| 17 | # Make the `zig version` number consistent. | ||
| 18 | # This will affect the cmake command below. | ||
| 19 | git fetch --unshallow || true | ||
| 20 | git fetch --tags | ||
| 21 | |||
| 22 | # Test building from source without LLVM. | ||
| 23 | git clean -fd | ||
| 24 | rm -rf zig-out | ||
| 25 | cc -o bootstrap bootstrap.c | ||
| 26 | ./bootstrap | ||
| 27 | ./zig2 build -Dno-lib | ||
| 28 | ./zig-out/bin/zig test test/behavior.zig | ||
| 29 | |||
| 30 | export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" | ||
| 31 | export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" | ||
| 32 | |||
| 33 | rm -rf build-release | ||
| 34 | mkdir build-release | ||
| 35 | cd build-release | ||
| 36 | |||
| 37 | # Override the cache directories because they won't actually help other CI runs | ||
| 38 | # which will be testing alternate versions of zig, and ultimately would just | ||
| 39 | # fill up space on the hard drive for no reason. | ||
| 40 | export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache" | ||
| 41 | export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache" | ||
| 42 | |||
| 43 | cmake .. \ | ||
| 44 | -DCMAKE_INSTALL_PREFIX="stage3-release" \ | ||
| 45 | -DCMAKE_PREFIX_PATH="$PREFIX" \ | ||
| 46 | -DCMAKE_BUILD_TYPE=Release \ | ||
| 47 | -DZIG_TARGET_TRIPLE="$TARGET" \ | ||
| 48 | -DZIG_TARGET_MCPU="$MCPU" \ | ||
| 49 | -DZIG_STATIC=ON \ | ||
| 50 | -DZIG_NO_LIB=ON \ | ||
| 51 | -GNinja | ||
| 52 | |||
| 53 | # Now cmake will use zig as the C/C++ compiler. We reset the environment variables | ||
| 54 | # so that installation and testing do not get affected by them. | ||
| 55 | unset CC | ||
| 56 | unset CXX | ||
| 57 | |||
| 58 | ninja install | ||
| 59 | |||
| 60 | # simultaneously test building self-hosted without LLVM and with 32-bit arm | ||
| 61 | stage3-release/bin/zig build \ | ||
| 62 | -Dtarget=arm-linux-musleabihf \ | ||
| 63 | -Dno-lib | ||
| 64 | |||
| 65 | stage3-release/bin/zig build test docs \ | ||
| 66 | --maxrss 21000000000 \ | ||
| 67 | -fqemu \ | ||
| 68 | -fwasmtime \ | ||
| 69 | -Dstatic-llvm \ | ||
| 70 | -Dtarget=native-native-musl \ | ||
| 71 | --search-prefix "$PREFIX" \ | ||
| 72 | --zig-lib-dir "$PWD/../lib" \ | ||
| 73 | -Denable-tidy | ||
| 74 | |||
| 75 | # Ensure that stage3 and stage4 are byte-for-byte identical. | ||
| 76 | stage3-release/bin/zig build \ | ||
| 77 | --prefix stage4-release \ | ||
| 78 | -Denable-llvm \ | ||
| 79 | -Dno-lib \ | ||
| 80 | -Doptimize=ReleaseFast \ | ||
| 81 | -Dstrip \ | ||
| 82 | -Dtarget=$TARGET \ | ||
| 83 | -Duse-zig-libcxx \ | ||
| 84 | -Dversion-string="$(stage3-release/bin/zig version)" | ||
| 85 | |||
| 86 | # diff returns an error code if the files differ. | ||
| 87 | echo "If the following command fails, it means nondeterminism has been" | ||
| 88 | echo "introduced, making stage3 and stage4 no longer byte-for-byte identical." | ||
| 89 | diff stage3-release/bin/zig stage4-release/bin/zig | ||
| 90 | |||
| 91 | # Ensure that updating the wasm binary from this commit will result in a viable build. | ||
| 92 | stage3-release/bin/zig build update-zig1 | ||
| 93 | |||
| 94 | rm -rf ../build-new | ||
| 95 | mkdir ../build-new | ||
| 96 | cd ../build-new | ||
| 97 | |||
| 98 | export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache" | ||
| 99 | export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache" | ||
| 100 | export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" | ||
| 101 | export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" | ||
| 102 | |||
| 103 | cmake .. \ | ||
| 104 | -DCMAKE_PREFIX_PATH="$PREFIX" \ | ||
| 105 | -DCMAKE_BUILD_TYPE=Release \ | ||
| 106 | -DZIG_TARGET_TRIPLE="$TARGET" \ | ||
| 107 | -DZIG_TARGET_MCPU="$MCPU" \ | ||
| 108 | -DZIG_STATIC=ON \ | ||
| 109 | -DZIG_NO_LIB=ON \ | ||
| 110 | -GNinja | ||
| 111 | |||
| 112 | unset CC | ||
| 113 | unset CXX | ||
| 114 | |||
| 115 | ninja install | ||
| 116 | |||
| 117 | stage3/bin/zig test ../test/behavior.zig | ||
| 118 | stage3/bin/zig build -p stage4 \ | ||
| 119 | -Dstatic-llvm \ | ||
| 120 | -Dtarget=native-native-musl \ | ||
| 121 | -Dno-lib \ | ||
| 122 | --search-prefix "$PREFIX" \ | ||
| 123 | --zig-lib-dir "$PWD/../lib" | ||
| 124 | stage4/bin/zig test ../test/behavior.zig | ||
ci/x86_64-macos-release.sh deleted-78| ... | @@ -1,78 +0,0 @@ | ||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | set -x | ||
| 4 | set -e | ||
| 5 | |||
| 6 | ZIGDIR="$PWD" | ||
| 7 | TARGET="$ARCH-macos-none" | ||
| 8 | MCPU="baseline" | ||
| 9 | CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.13.0-dev.130+98a30acad" | ||
| 10 | PREFIX="$HOME/$CACHE_BASENAME" | ||
| 11 | JOBS="-j3" | ||
| 12 | ZIG="$PREFIX/bin/zig" | ||
| 13 | |||
| 14 | if [ ! -d "$PREFIX" ]; then | ||
| 15 | cd $HOME | ||
| 16 | curl -L -O "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz" | ||
| 17 | tar xf "$CACHE_BASENAME.tar.xz" | ||
| 18 | fi | ||
| 19 | |||
| 20 | cd $ZIGDIR | ||
| 21 | |||
| 22 | # Make the `zig version` number consistent. | ||
| 23 | # This will affect the cmake command below. | ||
| 24 | git fetch --unshallow || true | ||
| 25 | git fetch --tags | ||
| 26 | |||
| 27 | # Test building from source without LLVM. | ||
| 28 | git clean -fd | ||
| 29 | rm -rf zig-out | ||
| 30 | cc -o bootstrap bootstrap.c | ||
| 31 | ./bootstrap | ||
| 32 | ./zig2 build -Dno-lib | ||
| 33 | ./zig-out/bin/zig test test/behavior.zig | ||
| 34 | |||
| 35 | rm -rf build | ||
| 36 | mkdir build | ||
| 37 | cd build | ||
| 38 | |||
| 39 | # Override the cache directories because they won't actually help other CI runs | ||
| 40 | # which will be testing alternate versions of zig, and ultimately would just | ||
| 41 | # fill up space on the hard drive for no reason. | ||
| 42 | export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache" | ||
| 43 | export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache" | ||
| 44 | |||
| 45 | cmake .. \ | ||
| 46 | -DCMAKE_PREFIX_PATH="$PREFIX" \ | ||
| 47 | -DCMAKE_BUILD_TYPE=Release \ | ||
| 48 | -DCMAKE_C_COMPILER="$ZIG;cc;-target;$TARGET;-mcpu=$MCPU" \ | ||
| 49 | -DCMAKE_CXX_COMPILER="$ZIG;c++;-target;$TARGET;-mcpu=$MCPU" \ | ||
| 50 | -DZIG_TARGET_TRIPLE="$TARGET" \ | ||
| 51 | -DZIG_TARGET_MCPU="$MCPU" \ | ||
| 52 | -DZIG_STATIC=ON \ | ||
| 53 | -DZIG_NO_LIB=ON | ||
| 54 | |||
| 55 | make $JOBS install | ||
| 56 | |||
| 57 | stage3/bin/zig build test docs \ | ||
| 58 | --zig-lib-dir "$PWD/../lib" \ | ||
| 59 | -Denable-macos-sdk \ | ||
| 60 | -Dstatic-llvm \ | ||
| 61 | -Dskip-non-native \ | ||
| 62 | --search-prefix "$PREFIX" | ||
| 63 | |||
| 64 | # Ensure that stage3 and stage4 are byte-for-byte identical. | ||
| 65 | stage3/bin/zig build \ | ||
| 66 | --prefix stage4 \ | ||
| 67 | -Denable-llvm \ | ||
| 68 | -Dno-lib \ | ||
| 69 | -Doptimize=ReleaseFast \ | ||
| 70 | -Dstrip \ | ||
| 71 | -Dtarget=$TARGET \ | ||
| 72 | -Duse-zig-libcxx \ | ||
| 73 | -Dversion-string="$(stage3/bin/zig version)" | ||
| 74 | |||
| 75 | # diff returns an error code if the files differ. | ||
| 76 | echo "If the following command fails, it means nondeterminism has been" | ||
| 77 | echo "introduced, making stage3 and stage4 no longer byte-for-byte identical." | ||
| 78 | diff stage3/bin/zig stage4/bin/zig | ||
ci/x86_64-windows-debug.ps1 deleted-110| ... | @@ -1,110 +0,0 @@ | ||
| 1 | $TARGET = "$($Env:ARCH)-windows-gnu" | ||
| 2 | $ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.13.0-dev.130+98a30acad" | ||
| 3 | $MCPU = "baseline" | ||
| 4 | $ZIG_LLVM_CLANG_LLD_URL = "https://ziglang.org/deps/$ZIG_LLVM_CLANG_LLD_NAME.zip" | ||
| 5 | $PREFIX_PATH = "$($Env:USERPROFILE)\$ZIG_LLVM_CLANG_LLD_NAME" | ||
| 6 | $ZIG = "$PREFIX_PATH\bin\zig.exe" | ||
| 7 | $ZIG_LIB_DIR = "$(Get-Location)\lib" | ||
| 8 | |||
| 9 | if (!(Test-Path "$PREFIX_PATH.zip")) { | ||
| 10 | Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL" | ||
| 11 | Invoke-WebRequest -Uri "$ZIG_LLVM_CLANG_LLD_URL" -OutFile "$PREFIX_PATH.zip" | ||
| 12 | |||
| 13 | Write-Output "Extracting..." | ||
| 14 | Add-Type -AssemblyName System.IO.Compression.FileSystem ; | ||
| 15 | [System.IO.Compression.ZipFile]::ExtractToDirectory("$PREFIX_PATH.zip", "$PREFIX_PATH\..") | ||
| 16 | } | ||
| 17 | |||
| 18 | function CheckLastExitCode { | ||
| 19 | if (!$?) { | ||
| 20 | exit 1 | ||
| 21 | } | ||
| 22 | return 0 | ||
| 23 | } | ||
| 24 | |||
| 25 | # Make the `zig version` number consistent. | ||
| 26 | # This will affect the `zig build` command below which uses `git describe`. | ||
| 27 | git fetch --tags | ||
| 28 | |||
| 29 | if ((git rev-parse --is-shallow-repository) -eq "true") { | ||
| 30 | git fetch --unshallow # `git describe` won't work on a shallow repo | ||
| 31 | } | ||
| 32 | |||
| 33 | Write-Output "Building from source..." | ||
| 34 | Remove-Item -Path 'build-debug' -Recurse -Force -ErrorAction Ignore | ||
| 35 | New-Item -Path 'build-debug' -ItemType Directory | ||
| 36 | Set-Location -Path 'build-debug' | ||
| 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 | $Env:ZIG_GLOBAL_CACHE_DIR="$(Get-Location)\zig-global-cache" | ||
| 42 | $Env:ZIG_LOCAL_CACHE_DIR="$(Get-Location)\zig-local-cache" | ||
| 43 | |||
| 44 | # CMake gives a syntax error when file paths with backward slashes are used. | ||
| 45 | # Here, we use forward slashes only to work around this. | ||
| 46 | & cmake .. ` | ||
| 47 | -GNinja ` | ||
| 48 | -DCMAKE_INSTALL_PREFIX="stage3-debug" ` | ||
| 49 | -DCMAKE_PREFIX_PATH="$($PREFIX_PATH -Replace "\\", "/")" ` | ||
| 50 | -DCMAKE_BUILD_TYPE=Debug ` | ||
| 51 | -DCMAKE_C_COMPILER="$($ZIG -Replace "\\", "/");cc;-target;$TARGET;-mcpu=$MCPU" ` | ||
| 52 | -DCMAKE_CXX_COMPILER="$($ZIG -Replace "\\", "/");c++;-target;$TARGET;-mcpu=$MCPU" ` | ||
| 53 | -DCMAKE_AR="$($ZIG -Replace "\\", "/")" ` | ||
| 54 | -DZIG_AR_WORKAROUND=ON ` | ||
| 55 | -DZIG_TARGET_TRIPLE="$TARGET" ` | ||
| 56 | -DZIG_TARGET_MCPU="$MCPU" ` | ||
| 57 | -DZIG_STATIC=ON ` | ||
| 58 | -DZIG_NO_LIB=ON | ||
| 59 | CheckLastExitCode | ||
| 60 | |||
| 61 | ninja install | ||
| 62 | CheckLastExitCode | ||
| 63 | |||
| 64 | Write-Output "Main test suite..." | ||
| 65 | & "stage3-debug\bin\zig.exe" build test docs ` | ||
| 66 | --zig-lib-dir "$ZIG_LIB_DIR" ` | ||
| 67 | --search-prefix "$PREFIX_PATH" ` | ||
| 68 | -Dstatic-llvm ` | ||
| 69 | -Dskip-non-native ` | ||
| 70 | -Dskip-release ` | ||
| 71 | -Denable-symlinks-windows | ||
| 72 | CheckLastExitCode | ||
| 73 | |||
| 74 | Write-Output "Build x86_64-windows-msvc behavior tests using the C backend..." | ||
| 75 | & "stage3-debug\bin\zig.exe" test ` | ||
| 76 | ..\test\behavior.zig ` | ||
| 77 | --zig-lib-dir "$ZIG_LIB_DIR" ` | ||
| 78 | -ofmt=c ` | ||
| 79 | -femit-bin="test-x86_64-windows-msvc.c" ` | ||
| 80 | --test-no-exec ` | ||
| 81 | -target x86_64-windows-msvc ` | ||
| 82 | -lc | ||
| 83 | CheckLastExitCode | ||
| 84 | |||
| 85 | & "stage3-debug\bin\zig.exe" build-obj ` | ||
| 86 | --zig-lib-dir "$ZIG_LIB_DIR" ` | ||
| 87 | -ofmt=c ` | ||
| 88 | -OReleaseSmall ` | ||
| 89 | --name compiler_rt ` | ||
| 90 | -femit-bin="compiler_rt-x86_64-windows-msvc.c" ` | ||
| 91 | --dep build_options ` | ||
| 92 | -target x86_64-windows-msvc ` | ||
| 93 | --mod root ..\lib\compiler_rt.zig ` | ||
| 94 | --mod build_options config.zig | ||
| 95 | CheckLastExitCode | ||
| 96 | |||
| 97 | Import-Module "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" | ||
| 98 | CheckLastExitCode | ||
| 99 | |||
| 100 | Enter-VsDevShell -VsInstallPath "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools" ` | ||
| 101 | -DevCmdArguments '-arch=x64 -no_logo' ` | ||
| 102 | -StartInPath $(Get-Location) | ||
| 103 | CheckLastExitCode | ||
| 104 | |||
| 105 | Write-Output "Build and run behavior tests with msvc..." | ||
| 106 | & cl.exe -I..\lib test-x86_64-windows-msvc.c compiler_rt-x86_64-windows-msvc.c /W3 /Z7 -link -nologo -debug -subsystem:console kernel32.lib ntdll.lib libcmt.lib | ||
| 107 | CheckLastExitCode | ||
| 108 | |||
| 109 | & .\test-x86_64-windows-msvc.exe | ||
| 110 | CheckLastExitCode | ||
ci/x86_64-windows-release.ps1 deleted-109| ... | @@ -1,109 +0,0 @@ | ||
| 1 | $TARGET = "$($Env:ARCH)-windows-gnu" | ||
| 2 | $ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.13.0-dev.130+98a30acad" | ||
| 3 | $MCPU = "baseline" | ||
| 4 | $ZIG_LLVM_CLANG_LLD_URL = "https://ziglang.org/deps/$ZIG_LLVM_CLANG_LLD_NAME.zip" | ||
| 5 | $PREFIX_PATH = "$($Env:USERPROFILE)\$ZIG_LLVM_CLANG_LLD_NAME" | ||
| 6 | $ZIG = "$PREFIX_PATH\bin\zig.exe" | ||
| 7 | $ZIG_LIB_DIR = "$(Get-Location)\lib" | ||
| 8 | |||
| 9 | if (!(Test-Path "$PREFIX_PATH.zip")) { | ||
| 10 | Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL" | ||
| 11 | Invoke-WebRequest -Uri "$ZIG_LLVM_CLANG_LLD_URL" -OutFile "$PREFIX_PATH.zip" | ||
| 12 | |||
| 13 | Write-Output "Extracting..." | ||
| 14 | Add-Type -AssemblyName System.IO.Compression.FileSystem ; | ||
| 15 | [System.IO.Compression.ZipFile]::ExtractToDirectory("$PREFIX_PATH.zip", "$PREFIX_PATH\..") | ||
| 16 | } | ||
| 17 | |||
| 18 | function CheckLastExitCode { | ||
| 19 | if (!$?) { | ||
| 20 | exit 1 | ||
| 21 | } | ||
| 22 | return 0 | ||
| 23 | } | ||
| 24 | |||
| 25 | # Make the `zig version` number consistent. | ||
| 26 | # This will affect the `zig build` command below which uses `git describe`. | ||
| 27 | git fetch --tags | ||
| 28 | |||
| 29 | if ((git rev-parse --is-shallow-repository) -eq "true") { | ||
| 30 | git fetch --unshallow # `git describe` won't work on a shallow repo | ||
| 31 | } | ||
| 32 | |||
| 33 | Write-Output "Building from source..." | ||
| 34 | Remove-Item -Path 'build-release' -Recurse -Force -ErrorAction Ignore | ||
| 35 | New-Item -Path 'build-release' -ItemType Directory | ||
| 36 | Set-Location -Path '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 | $Env:ZIG_GLOBAL_CACHE_DIR="$(Get-Location)\zig-global-cache" | ||
| 42 | $Env:ZIG_LOCAL_CACHE_DIR="$(Get-Location)\zig-local-cache" | ||
| 43 | |||
| 44 | # CMake gives a syntax error when file paths with backward slashes are used. | ||
| 45 | # Here, we use forward slashes only to work around this. | ||
| 46 | & cmake .. ` | ||
| 47 | -GNinja ` | ||
| 48 | -DCMAKE_INSTALL_PREFIX="stage3-release" ` | ||
| 49 | -DCMAKE_PREFIX_PATH="$($PREFIX_PATH -Replace "\\", "/")" ` | ||
| 50 | -DCMAKE_BUILD_TYPE=Release ` | ||
| 51 | -DCMAKE_C_COMPILER="$($ZIG -Replace "\\", "/");cc;-target;$TARGET;-mcpu=$MCPU" ` | ||
| 52 | -DCMAKE_CXX_COMPILER="$($ZIG -Replace "\\", "/");c++;-target;$TARGET;-mcpu=$MCPU" ` | ||
| 53 | -DCMAKE_AR="$($ZIG -Replace "\\", "/")" ` | ||
| 54 | -DZIG_AR_WORKAROUND=ON ` | ||
| 55 | -DZIG_TARGET_TRIPLE="$TARGET" ` | ||
| 56 | -DZIG_TARGET_MCPU="$MCPU" ` | ||
| 57 | -DZIG_STATIC=ON ` | ||
| 58 | -DZIG_NO_LIB=ON | ||
| 59 | CheckLastExitCode | ||
| 60 | |||
| 61 | ninja install | ||
| 62 | CheckLastExitCode | ||
| 63 | |||
| 64 | Write-Output "Main test suite..." | ||
| 65 | & "stage3-release\bin\zig.exe" build test docs ` | ||
| 66 | --zig-lib-dir "$ZIG_LIB_DIR" ` | ||
| 67 | --search-prefix "$PREFIX_PATH" ` | ||
| 68 | -Dstatic-llvm ` | ||
| 69 | -Dskip-non-native ` | ||
| 70 | -Denable-symlinks-windows | ||
| 71 | CheckLastExitCode | ||
| 72 | |||
| 73 | Write-Output "Build x86_64-windows-msvc behavior tests using the C backend..." | ||
| 74 | & "stage3-release\bin\zig.exe" test ` | ||
| 75 | ..\test\behavior.zig ` | ||
| 76 | --zig-lib-dir "$ZIG_LIB_DIR" ` | ||
| 77 | -ofmt=c ` | ||
| 78 | -femit-bin="test-x86_64-windows-msvc.c" ` | ||
| 79 | --test-no-exec ` | ||
| 80 | -target x86_64-windows-msvc ` | ||
| 81 | -lc | ||
| 82 | CheckLastExitCode | ||
| 83 | |||
| 84 | & "stage3-release\bin\zig.exe" build-obj ` | ||
| 85 | --zig-lib-dir "$ZIG_LIB_DIR" ` | ||
| 86 | -ofmt=c ` | ||
| 87 | -OReleaseSmall ` | ||
| 88 | --name compiler_rt ` | ||
| 89 | -femit-bin="compiler_rt-x86_64-windows-msvc.c" ` | ||
| 90 | --dep build_options ` | ||
| 91 | -target x86_64-windows-msvc ` | ||
| 92 | --mod root ..\lib\compiler_rt.zig ` | ||
| 93 | --mod build_options config.zig | ||
| 94 | CheckLastExitCode | ||
| 95 | |||
| 96 | Import-Module "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" | ||
| 97 | CheckLastExitCode | ||
| 98 | |||
| 99 | Enter-VsDevShell -VsInstallPath "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools" ` | ||
| 100 | -DevCmdArguments '-arch=x64 -no_logo' ` | ||
| 101 | -StartInPath $(Get-Location) | ||
| 102 | CheckLastExitCode | ||
| 103 | |||
| 104 | Write-Output "Build and run behavior tests with msvc..." | ||
| 105 | & cl.exe -I..\lib test-x86_64-windows-msvc.c compiler_rt-x86_64-windows-msvc.c /W3 /Z7 -link -nologo -debug -subsystem:console kernel32.lib ntdll.lib libcmt.lib | ||
| 106 | CheckLastExitCode | ||
| 107 | |||
| 108 | & .\test-x86_64-windows-msvc.exe | ||
| 109 | CheckLastExitCode | ||
lib/std/Build/Step/RemoveDir.zig+3-9| ... | @@ -35,14 +35,8 @@ fn make(step: *Step, options: Step.MakeOptions) !void { | ... | @@ -35,14 +35,8 @@ fn make(step: *Step, options: Step.MakeOptions) !void { |
| 35 | const full_doomed_path = remove_dir.doomed_path.getPath2(b, step); | 35 | const full_doomed_path = remove_dir.doomed_path.getPath2(b, step); |
| 36 | 36 | ||
| 37 | b.build_root.handle.deleteTree(full_doomed_path) catch |err| { | 37 | b.build_root.handle.deleteTree(full_doomed_path) catch |err| { |
| 38 | if (b.build_root.path) |base| { | 38 | return step.fail("unable to recursively delete path '{s}': {s}", .{ |
| 39 | return step.fail("unable to recursively delete path '{s}/{s}': {s}", .{ | 39 | b.pathFromRoot(full_doomed_path), @errorName(err), |
| 40 | base, full_doomed_path, @errorName(err), | 40 | }); |
| 41 | }); | ||
| 42 | } else { | ||
| 43 | return step.fail("unable to recursively delete path '{s}': {s}", .{ | ||
| 44 | full_doomed_path, @errorName(err), | ||
| 45 | }); | ||
| 46 | } | ||
| 47 | }; | 41 | }; |
| 48 | } | 42 | } |
lib/std/posix.zig+4-1| ... | @@ -7353,7 +7353,10 @@ const lfs64_abi = native_os == .linux and builtin.link_libc and builtin.abi.isGn | ... | @@ -7353,7 +7353,10 @@ const lfs64_abi = native_os == .linux and builtin.link_libc and builtin.abi.isGn |
| 7353 | /// If this happens the fix is to add the error code to the corresponding | 7353 | /// If this happens the fix is to add the error code to the corresponding |
| 7354 | /// switch expression, possibly introduce a new error in the error set, and | 7354 | /// switch expression, possibly introduce a new error in the error set, and |
| 7355 | /// send a patch to Zig. | 7355 | /// send a patch to Zig. |
| 7356 | pub const unexpected_error_tracing = builtin.zig_backend == .stage2_llvm and builtin.mode == .Debug; | 7356 | pub const unexpected_error_tracing = switch (builtin.zig_backend) { |
| 7357 | .stage2_c, .stage2_llvm, .stage2_x86_64 => true, | ||
| 7358 | else => false, | ||
| 7359 | }; | ||
| 7357 | 7360 | ||
| 7358 | pub const UnexpectedError = error{ | 7361 | pub const UnexpectedError = error{ |
| 7359 | /// The Operating System returned an undocumented error code. | 7362 | /// The Operating System returned an undocumented error code. |