Skip to content

Commit 9bcfe55

Browse files
authored
Merge pull request #13879 from ziglang/ci-add-aarch64-windows
CI: add aarch64-windows coverage
2 parents a792e13 + d10fd78 commit 9bcfe55

File tree

11 files changed

+439
-264
lines changed

11 files changed

+439
-264
lines changed

.github/workflows/ci.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
run: sh ci/aarch64-linux-release.sh
4040
x86_64-macos:
4141
runs-on: "macos-11"
42-
env:
42+
env:
4343
ARCH: "x86_64"
4444
steps:
4545
- name: Checkout
@@ -48,7 +48,7 @@ jobs:
4848
run: ci/x86_64-macos.sh
4949
aarch64-macos:
5050
runs-on: [self-hosted, macOS, aarch64]
51-
env:
51+
env:
5252
ARCH: "aarch64"
5353
steps:
5454
- name: Checkout
@@ -64,3 +64,12 @@ jobs:
6464
uses: actions/checkout@v3
6565
- name: Build and Test
6666
run: ci/x86_64-windows.ps1
67+
aarch64-windows:
68+
runs-on: [self-hosted, Windows, aarch64]
69+
env:
70+
ARCH: "aarch64"
71+
steps:
72+
- name: Checkout
73+
uses: actions/checkout@v3
74+
- name: Build and Test
75+
run: ci/aarch64-windows.ps1

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,19 @@ string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_LIBC_INCLUDE_DIR_ESCAPED "${ZIG_LIBC_
120120
set(ZIG_TARGET_TRIPLE "native" CACHE STRING "arch-os-abi to output binaries for")
121121
set(ZIG_TARGET_MCPU "native" CACHE STRING "-mcpu parameter to output binaries for")
122122
set(ZIG_SINGLE_THREADED off CACHE BOOL "limit the zig compiler to use only 1 thread")
123+
set(ZIG_AR_WORKAROUND off CACHE BOOL "append 'ar' subcommand to CMAKE_AR")
123124

124125
if("${ZIG_TARGET_TRIPLE}" STREQUAL "native")
125126
set(ZIG_USE_LLVM_CONFIG ON CACHE BOOL "use llvm-config to find LLVM libraries")
126127
else()
127128
set(ZIG_USE_LLVM_CONFIG OFF CACHE BOOL "use llvm-config to find LLVM libraries")
128129
endif()
129130

131+
if(ZIG_AR_WORKAROUND)
132+
string(REPLACE "<CMAKE_AR>" "<CMAKE_AR> ar" CMAKE_C_ARCHIVE_CREATE ${CMAKE_C_ARCHIVE_CREATE})
133+
string(REPLACE "<CMAKE_AR>" "<CMAKE_AR> ar" CMAKE_CXX_ARCHIVE_CREATE ${CMAKE_CXX_ARCHIVE_CREATE})
134+
endif()
135+
130136
find_package(llvm 15)
131137
find_package(clang 15)
132138
find_package(lld 15)
@@ -702,6 +708,8 @@ if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "AMD64")
702708
set(HOST_TARGET_ARCH "x86_64")
703709
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64")
704710
set(HOST_TARGET_ARCH "aarch64")
711+
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "ARM64")
712+
set(HOST_TARGET_ARCH "aarch64")
705713
else()
706714
string(TOLOWER "${CMAKE_HOST_SYSTEM_PROCESSOR}" HOST_TARGET_ARCH)
707715
endif()

ci/aarch64-windows.ps1

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
$TARGET = "$($Env:ARCH)-windows-gnu"
2+
$ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.11.0-dev.670+f7fea080b"
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 config core.abbrev 9
28+
git fetch --tags
29+
30+
if ((git rev-parse --is-shallow-repository) -eq "true") {
31+
git fetch --unshallow # `git describe` won't work on a shallow repo
32+
}
33+
34+
Write-Output "Building from source..."
35+
Remove-Item -Path 'build-release' -Recurse -Force -ErrorAction Ignore
36+
New-Item -Path 'build-release' -ItemType Directory
37+
Set-Location -Path 'build-release'
38+
39+
# CMake gives a syntax error when file paths with backward slashes are used.
40+
# Here, we use forward slashes only to work around this.
41+
& cmake .. `
42+
-GNinja `
43+
-DCMAKE_INSTALL_PREFIX="stage3-release" `
44+
-DCMAKE_PREFIX_PATH="$($PREFIX_PATH -Replace "\\", "/")" `
45+
-DCMAKE_BUILD_TYPE=Release `
46+
-DCMAKE_C_COMPILER="$($ZIG -Replace "\\", "/");cc;-target;$TARGET;-mcpu=$MCPU" `
47+
-DCMAKE_CXX_COMPILER="$($ZIG -Replace "\\", "/");c++;-target;$TARGET;-mcpu=$MCPU" `
48+
-DCMAKE_AR="$ZIG" `
49+
-DZIG_AR_WORKAROUND=ON `
50+
-DZIG_TARGET_TRIPLE="$TARGET" `
51+
-DZIG_TARGET_MCPU="$MCPU" `
52+
-DZIG_STATIC=ON
53+
CheckLastExitCode
54+
55+
ninja install
56+
CheckLastExitCode
57+
58+
Write-Output "Main test suite..."
59+
& "stage3-release\bin\zig.exe" build test docs `
60+
--zig-lib-dir "$ZIG_LIB_DIR" `
61+
--search-prefix "$PREFIX_PATH" `
62+
-Dstatic-llvm `
63+
-Dskip-non-native `
64+
-Denable-symlinks-windows
65+
CheckLastExitCode
66+
67+
Write-Output "Testing Autodocs..."
68+
& "stage3-release\bin\zig.exe" test "..\lib\std\std.zig" `
69+
--zig-lib-dir "$ZIG_LIB_DIR" `
70+
-femit-docs `
71+
-fno-emit-bin
72+
CheckLastExitCode
73+

stage1/zig1.wasm

376 Bytes
Binary file not shown.

test/behavior/align.zig

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,20 @@ test "page aligned array on stack" {
275275
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
276276
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
277277
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
278-
// https://github.com/ziglang/zig/issues/13679
278+
279279
if (builtin.zig_backend == .stage2_llvm and
280-
builtin.cpu.arch == .aarch64 and
281-
builtin.os.tag == .windows) return error.SkipZigTest;
280+
builtin.cpu.arch == .aarch64 and builtin.os.tag == .windows)
281+
{
282+
// https://github.com/ziglang/zig/issues/13679
283+
return error.SkipZigTest;
284+
}
285+
286+
if (builtin.zig_backend == .stage2_c and
287+
builtin.os.tag == .windows and builtin.cpu.arch == .aarch64)
288+
{
289+
// https://github.com/ziglang/zig/issues/13876
290+
return error.SkipZigTest;
291+
}
282292

283293
// Large alignment value to make it hard to accidentally pass.
284294
var array align(0x1000) = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8 };

test/behavior/cast.zig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,13 @@ test "cast f128 to narrower types" {
13511351
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
13521352
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
13531353

1354+
if (builtin.os.tag == .windows and builtin.cpu.arch == .aarch64 and
1355+
builtin.zig_backend == .stage2_c)
1356+
{
1357+
// https://github.com/ziglang/zig/issues/13876
1358+
return error.SkipZigTest;
1359+
}
1360+
13541361
const S = struct {
13551362
fn doTheTest() !void {
13561363
var x: f128 = 1234.0;

0 commit comments

Comments
 (0)