Skip to content

Commit 689c812

Browse files
authored
Add the native ARM64 toolchain build to the main CI (#847)
1 parent 7ff3246 commit 689c812

File tree

2 files changed

+359
-129
lines changed

2 files changed

+359
-129
lines changed

.github/workflows/build-toolchain.yml

Lines changed: 158 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ on:
3636
default: true
3737
required: false
3838

39+
create_snapshot:
40+
description: 'Create Snapshot'
41+
type: boolean
42+
default: true
43+
required: false
44+
45+
build_android:
46+
required: false
47+
default: false
48+
type: boolean
49+
3950
workflow_call:
4051
inputs:
4152
swift_version:
@@ -71,15 +82,41 @@ on:
7182
default: true
7283
required: false
7384

74-
windows_default_runner:
75-
description: 'Build runner'
85+
create_snapshot:
86+
description: 'Create Snapshot'
87+
type: boolean
88+
default: true
89+
required: false
90+
91+
windows_x64_default_runner:
92+
description: 'X64 Build runner'
7693
required: false
7794
type: string
7895

79-
windows_compilers_runner:
80-
description: 'Build runner for `compilers` job'
96+
windows_arm64_default_runner:
97+
description: 'ARM64 Build runner'
98+
required: false
99+
type: string
100+
101+
windows_x64_compilers_runner:
102+
description: 'X64 Build runner for `compilers` job'
103+
required: false
104+
type: string
105+
106+
windows_arm64_compilers_runner:
107+
description: 'ARM64 Build runner for `compilers` job'
108+
required: false
81109
type: string
110+
111+
windows_build_arch:
112+
description: 'Windows build architecture'
82113
required: false
114+
type: string
115+
116+
build_android:
117+
required: false
118+
default: false
119+
type: boolean
83120

84121
secrets:
85122
SYMBOL_SERVER_PAT:
@@ -153,12 +190,19 @@ jobs:
153190
signed: ${{ steps.context.outputs.signed }}
154191
swift_version: ${{ steps.context.outputs.swift_version }}
155192
swift_tag: ${{ steps.context.outputs.swift_tag }}
156-
windows_build_runner: ${{ steps.context.outputs.windows_build_runner }}
157-
windows_compilers_runner: ${{ steps.context.outputs.windows_compilers_runner }}
193+
windows_arm64_build_runner: ${{ steps.context.outputs.windows_arm64_build_runner }}
194+
windows_arm64_compilers_runner: ${{ steps.context.outputs.windows_arm64_compilers_runner }}
195+
windows_build_arch: ${{ steps.context.outputs.windows_build_arch }}
196+
windows_build_cpu: ${{ steps.context.outputs.windows_build_cpu }}
197+
windows_x64_build_runner: ${{ steps.context.outputs.windows_x64_build_runner }}
198+
windows_x64_compilers_runner: ${{ steps.context.outputs.windows_x64_compilers_runner }}
158199
mac_build_runner: ${{ steps.context.outputs.mac_build_runner }}
159-
windows_host_matrix: ${{ steps.setup-matrix.outputs.windows_host_matrix }}
160-
windows_build_matrix: ${{ steps.setup-matrix.outputs.windows_build_matrix }}
161-
windows_target_matrix: ${{ steps.setup-matrix.outputs.windows_target_matrix }}
200+
windows_arm64_build_matrix: ${{ steps.setup-matrix.outputs.windows_arm64_build_matrix }}
201+
windows_arm64_host_matrix: ${{ steps.setup-matrix.outputs.windows_arm64_host_matrix }}
202+
windows_arm64_target_matrix: ${{ steps.setup-matrix.outputs.windows_arm64_target_matrix }}
203+
windows_x64_build_matrix: ${{ steps.setup-matrix.outputs.windows_x64_build_matrix }}
204+
windows_x64_host_matrix: ${{ steps.setup-matrix.outputs.windows_x64_host_matrix }}
205+
windows_x64_target_matrix: ${{ steps.setup-matrix.outputs.windows_x64_target_matrix }}
162206
darwin_host_matrix: ${{ steps.setup-matrix.outputs.darwin_host_matrix }}
163207
darwin_build_matrix: ${{ steps.setup-matrix.outputs.darwin_build_matrix }}
164208
darwin_target_matrix: ${{ steps.setup-matrix.outputs.darwin_target_matrix }}
@@ -284,15 +328,26 @@ jobs:
284328
fi
285329
fi
286330
287-
echo windows_build_runner=${{ inputs.windows_default_runner || vars.WINDOWS_BUILD_RUNNER || 'windows-latest' }} >> ${GITHUB_OUTPUT}
288-
echo windows_compilers_runner=${{ inputs.windows_compilers_runner || inputs.windows_default_runner || vars.COMPILERS_BUILD_RUNNER || vars.WINDOWS_BUILD_RUNNER || 'windows-latest' }} >> ${GITHUB_OUTPUT}
331+
echo windows_x64_build_runner=${{ inputs.windows_x64_default_runner || vars.WINDOWS_BUILD_RUNNER || 'windows-latest' }} >> ${GITHUB_OUTPUT}
332+
echo windows_x64_compilers_runner=${{ inputs.windows_x64_compilers_runner || inputs.windows_x64_default_runner || vars.WINDOWS_X64_COMPILERS_BUILD_RUNNER || vars.WINDOWS_X64_DEFAULT_BUILD_RUNNER || 'windows-latest' }} >> ${GITHUB_OUTPUT}
333+
echo windows_arm64_build_runner=${{ inputs.windows_arm64_default_runner || vars.WINDOWS_ARM64_DEFAULT_BUILD_RUNNER || 'windows-latest' }} >> ${GITHUB_OUTPUT}
334+
echo windows_arm64_compilers_runner=${{ inputs.windows_arm64_compilers_runner || inputs.windows_arm64_default_runner || vars.WINDOWS_ARM64_COMPILERS_BUILD_RUNNER || vars.WINDOWS_ARM64_DEFAULT_BUILD_RUNNER || 'windows-latest' }} >> ${GITHUB_OUTPUT}
335+
if [[ "${{ inputs.windows_build_arch }}" == "arm64" ]] ; then
336+
echo windows_build_arch=arm64 >> ${GITHUB_OUTPUT}
337+
echo windows_build_cpu=arm64 >> ${GITHUB_OUTPUT}
338+
else
339+
echo windows_build_arch=amd64 >> ${GITHUB_OUTPUT}
340+
echo windows_build_cpu=x64 >> ${GITHUB_OUTPUT}
341+
fi
342+
289343
# TODO: Make the mac runner configurable.
290344
echo mac_build_runner=macos-latest >> ${GITHUB_OUTPUT}
291345
292346
echo ANDROID_API_LEVEL=${{ inputs.android_api_level }} >> ${GITHUB_OUTPUT}
293347
echo ANDROID_NDK_VERSION=r26b >> ${GITHUB_OUTPUT}
294348
295349
- uses: actions/upload-artifact@v4
350+
if: inputs.create_snapshot == true
296351
with:
297352
name: stable.xml
298353
path: stable.xml
@@ -301,11 +356,13 @@ jobs:
301356
- name: Setup matrix
302357
id: setup-matrix
303358
env:
304-
WINDOWS_HOST_MATRIX: >-
359+
WINDOWS_X64_HOST_MATRIX: >-
305360
{
306361
"include": [
307362
{
308363
"arch": "amd64",
364+
"cpu": "x86_64",
365+
"triple": "x86_64-unknown-windows-msvc",
309366
"compiler_target": "x86_64-unknown-windows-msvc",
310367
"os": "Windows",
311368
"cc": "cl",
@@ -317,6 +374,8 @@ jobs:
317374
},
318375
{
319376
"arch": "arm64",
377+
"cpu": "aarch64",
378+
"triple": "aarch64-unknown-windows-msvc",
320379
"compiler_target": "aarch64-unknown-windows-msvc",
321380
"os": "Windows",
322381
"cc": "cl",
@@ -328,11 +387,30 @@ jobs:
328387
}
329388
]
330389
}
331-
WINDOWS_BUILD_MATRIX: >-
390+
WINDOWS_ARM64_HOST_MATRIX: >-
391+
{
392+
"include": [
393+
{
394+
"arch": "arm64",
395+
"cpu": "aarch64",
396+
"triple": "aarch64-unknown-windows-msvc",
397+
"compiler_target": "aarch64-unknown-windows-msvc",
398+
"os": "Windows",
399+
"cc": "cl",
400+
"cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}",
401+
"cxx": "cl",
402+
"cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}",
403+
"swiftflags": "${{ steps.context.outputs.WINDOWS_CMAKE_Swift_FLAGS }}",
404+
"extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=ARM64 -D CMAKE_MT=mt"
405+
}
406+
]
407+
}
408+
WINDOWS_X64_BUILD_MATRIX: >-
332409
{
333410
"include": [
334411
{
335412
"arch": "amd64",
413+
"compiler_target": "x86_64-unknown-windows-msvc",
336414
"os": "Windows",
337415
"cc": "cl",
338416
"cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}",
@@ -343,7 +421,23 @@ jobs:
343421
}
344422
]
345423
}
346-
WINDOWS_TARGET_MATRIX: >-
424+
WINDOWS_ARM64_BUILD_MATRIX: >-
425+
{
426+
"include": [
427+
{
428+
"arch": "arm64",
429+
"compiler_target": "aarch64-unknown-windows-msvc",
430+
"os": "Windows",
431+
"cc": "cl",
432+
"cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}",
433+
"cxx": "cl",
434+
"cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}",
435+
"swiftflags": "${{ steps.context.outputs.WINDOWS_CMAKE_Swift_FLAGS }}",
436+
"extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=ARM64 -D CMAKE_MT=mt"
437+
}
438+
]
439+
}
440+
WINDOWS_X64_TARGET_MATRIX: >-
347441
{
348442
"include": [
349443
{
@@ -418,6 +512,41 @@ jobs:
418512
}
419513
]
420514
}
515+
WINDOWS_ARM64_TARGET_MATRIX: >-
516+
{
517+
"include": [
518+
{
519+
"arch": "amd64",
520+
"os": "Windows",
521+
"cc": "cl",
522+
"cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}",
523+
"cxx": "cl",
524+
"cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}",
525+
"swiftflags": "${{ steps.context.outputs.WINDOWS_CMAKE_Swift_FLAGS }}",
526+
"extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=AMD64 -D CMAKE_MT=mt"
527+
},
528+
{
529+
"arch": "arm64",
530+
"os": "Windows",
531+
"cc": "cl",
532+
"cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}",
533+
"cxx": "cl",
534+
"cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}",
535+
"swiftflags": "${{ steps.context.outputs.WINDOWS_CMAKE_Swift_FLAGS }}",
536+
"extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=ARM64 -D CMAKE_MT=mt"
537+
},
538+
{
539+
"arch": "x86",
540+
"os": "Windows",
541+
"cc": "cl",
542+
"cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}",
543+
"cxx": "cl",
544+
"cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}",
545+
"swiftflags": "",
546+
"extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=X86 -D CMAKE_MT=mt"
547+
}
548+
]
549+
}
421550
DARWIN_HOST_MATRIX: >-
422551
{
423552
"include": [
@@ -486,23 +615,27 @@ jobs:
486615
]
487616
}
488617
run: |
489-
echo "windows_host_matrix=$(jq -r -c '.' <<< ${WINDOWS_HOST_MATRIX})" >> ${GITHUB_OUTPUT}
490-
echo "windows_build_matrix=$(jq -r -c '.' <<< ${WINDOWS_BUILD_MATRIX})" >> ${GITHUB_OUTPUT}
491-
echo "windows_target_matrix=$(jq -r -c '.' <<< ${WINDOWS_TARGET_MATRIX})" >> ${GITHUB_OUTPUT}
618+
echo "windows_x64_host_matrix=$(jq -r -c '.' <<< ${WINDOWS_X64_HOST_MATRIX})" >> ${GITHUB_OUTPUT}
619+
echo "windows_arm64_host_matrix=$(jq -r -c '.' <<< ${WINDOWS_ARM64_HOST_MATRIX})" >> ${GITHUB_OUTPUT}
620+
echo "windows_x64_build_matrix=$(jq -r -c '.' <<< ${WINDOWS_X64_BUILD_MATRIX})" >> ${GITHUB_OUTPUT}
621+
echo "windows_arm64_build_matrix=$(jq -r -c '.' <<< ${WINDOWS_ARM64_BUILD_MATRIX})" >> ${GITHUB_OUTPUT}
622+
echo "windows_x64_target_matrix=$(jq -r -c '.' <<< ${WINDOWS_X64_TARGET_MATRIX})" >> ${GITHUB_OUTPUT}
623+
echo "windows_arm64_target_matrix=$(jq -r -c '.' <<< ${WINDOWS_ARM64_TARGET_MATRIX})" >> ${GITHUB_OUTPUT}
492624
echo "darwin_host_matrix=$(jq -r -c '.' <<< ${DARWIN_HOST_MATRIX})" >> ${GITHUB_OUTPUT}
493625
echo "darwin_build_matrix=$(jq -r -c '.' <<< ${DARWIN_BUILD_MATRIX})" >> ${GITHUB_OUTPUT}
494626
echo "darwin_target_matrix=$(jq -r -c '.' <<< ${DARWIN_TARGET_MATRIX})" >> ${GITHUB_OUTPUT}
495627
496628
windows-build:
497629
needs: [context]
498630
name: Windows Swift Toolchains Build
631+
499632
uses: ./.github/workflows/swift-toolchain.yml
500633
with:
501634
build_os: Windows
502-
build_arch: amd64
503-
build_matrix: ${{ needs.context.outputs.windows_build_matrix }}
504-
host_matrix: ${{ needs.context.outputs.windows_host_matrix }}
505-
target_matrix: ${{ needs.context.outputs.windows_target_matrix }}
635+
build_arch: ${{ inputs.windows_build_arch }}
636+
build_matrix: ${{ needs.context.outputs[format('windows_{0}_build_matrix', needs.context.outputs.windows_build_cpu)] }}
637+
host_matrix: ${{ needs.context.outputs[format('windows_{0}_host_matrix', needs.context.outputs.windows_build_cpu)] }}
638+
target_matrix: ${{ needs.context.outputs[format('windows_{0}_target_matrix', needs.context.outputs.windows_build_cpu)] }}
506639
curl_revision: ${{ needs.context.outputs.curl_revision }}
507640
curl_version: ${{ needs.context.outputs.curl_version }}
508641
ds2_revision: ${{ needs.context.outputs.ds2_revision }}
@@ -557,8 +690,9 @@ jobs:
557690
signed: ${{ fromJSON(needs.context.outputs.signed) }}
558691
swift_version: ${{ needs.context.outputs.swift_version }}
559692
swift_tag: ${{ needs.context.outputs.swift_tag }}
560-
default_build_runner: ${{ needs.context.outputs.windows_build_runner }}
561-
compilers_build_runner: ${{ needs.context.outputs.windows_compilers_runner }}
693+
default_build_runner: ${{ needs.context.outputs[format('windows_{0}_build_runner', needs.context.outputs.windows_build_cpu)] }}
694+
compilers_build_runner: ${{ needs.context.outputs[format('windows_{0}_compilers_runner', needs.context.outputs.windows_build_cpu)] }}
695+
build_android: ${{ inputs.build_android }}
562696
secrets:
563697
SYMBOL_SERVER_PAT: ${{ secrets.SYMBOL_SERVER_PAT }}
564698
CERTIFICATE: ${{ secrets.CERTIFICATE }}
@@ -640,7 +774,7 @@ jobs:
640774
snapshot:
641775
runs-on: ubuntu-latest
642776
needs: [context, windows-build]
643-
if: github.event_name == 'schedule'
777+
if: inputs.create_snapshot == true && github.event_name == 'schedule'
644778
steps:
645779
- uses: actions/checkout@v4
646780
with:

0 commit comments

Comments
 (0)