master
1$TARGET = "aarch64-windows-gnu"
2$ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.16.0-dev.104+689461e31"
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
9if (!(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
18function CheckLastExitCode {
19 if (!$?) {
20 exit 1
21 }
22 return 0
23}
24
25# Override the cache directories because they won't actually help other CI runs
26# which will be testing alternate versions of zig, and ultimately would just
27# fill up space on the hard drive for no reason.
28$Env:ZIG_GLOBAL_CACHE_DIR="$(Get-Location)\zig-global-cache"
29$Env:ZIG_LOCAL_CACHE_DIR="$(Get-Location)\zig-local-cache"
30
31Write-Output "Building from source..."
32New-Item -Path 'build-release' -ItemType Directory
33Set-Location -Path 'build-release'
34
35# CMake gives a syntax error when file paths with backward slashes are used.
36# Here, we use forward slashes only to work around this.
37& cmake .. `
38 -GNinja `
39 -DCMAKE_INSTALL_PREFIX="stage3-release" `
40 -DCMAKE_PREFIX_PATH="$($PREFIX_PATH -Replace "\\", "/")" `
41 -DCMAKE_BUILD_TYPE=Release `
42 -DCMAKE_C_COMPILER="$($ZIG -Replace "\\", "/");cc;-target;$TARGET;-mcpu=$MCPU" `
43 -DCMAKE_CXX_COMPILER="$($ZIG -Replace "\\", "/");c++;-target;$TARGET;-mcpu=$MCPU" `
44 -DCMAKE_AR="$ZIG" `
45 -DZIG_AR_WORKAROUND=ON `
46 -DZIG_TARGET_TRIPLE="$TARGET" `
47 -DZIG_TARGET_MCPU="$MCPU" `
48 -DZIG_STATIC=ON `
49 -DZIG_NO_LIB=ON
50CheckLastExitCode
51
52ninja install
53CheckLastExitCode
54
55Write-Output "Main test suite..."
56& "stage3-release\bin\zig.exe" build test docs `
57 --zig-lib-dir "$ZIG_LIB_DIR" `
58 --search-prefix "$PREFIX_PATH" `
59 -Dstatic-llvm `
60 -Dskip-non-native `
61 -Denable-symlinks-windows `
62 --test-timeout 30m
63CheckLastExitCode
64
65# Ensure that stage3 and stage4 are byte-for-byte identical.
66Write-Output "Build and compare stage4..."
67& "stage3-release\bin\zig.exe" build `
68 --prefix stage4-release `
69 -Denable-llvm `
70 -Dno-lib `
71 -Doptimize=ReleaseFast `
72 -Dstrip `
73 -Dtarget="$TARGET" `
74 -Duse-zig-libcxx `
75 -Dversion-string="$(stage3-release\bin\zig version)"
76CheckLastExitCode
77
78# Compare-Object returns an error code if the files differ.
79Write-Output "If the following command fails, it means nondeterminism has been"
80Write-Output "introduced, making stage3 and stage4 no longer byte-for-byte identical."
81Compare-Object (Get-Content stage3-release\bin\zig.exe) (Get-Content stage4-release\bin\zig.exe)
82CheckLastExitCode