-
Notifications
You must be signed in to change notification settings - Fork 52
3887 lines (3466 loc) · 191 KB
/
swift-toolchain.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: Swift Toolchain Build
on:
workflow_call:
inputs:
build_os:
required: true
type: string
build_arch:
required: true
type: string
build_matrix:
required: true
type: string
host_matrix:
required: true
type: string
target_matrix:
required: true
type: string
curl_revision:
required: true
type: string
curl_version:
required: true
type: string
ds2_revision:
required: true
type: string
indexstore_db_revision:
required: true
type: string
libxml2_revision:
required: true
type: string
libxml2_version:
required: true
type: string
llvm_project_revision:
required: true
type: string
mimalloc_revision:
required: true
type: string
sourcekit_lsp_revision:
required: true
type: string
swift_argument_parser_revision:
required: true
type: string
swift_asn1_revision:
required: true
type: string
swift_atomics_revision:
required: true
type: string
swift_certificates_revision:
required: true
type: string
swift_cmark_revision:
required: true
type: string
swift_cmark_version:
required: true
type: string
swift_collections_revision:
required: true
type: string
swift_corelibs_foundation_revision:
required: true
type: string
swift_corelibs_libdispatch_revision:
required: true
type: string
swift_corelibs_xctest_revision:
required: true
type: string
swift_crypto_revision:
required: true
type: string
swift_driver_revision:
required: true
type: string
swift_experimental_string_processing_revision:
required: true
type: string
swift_format_revision:
required: true
type: string
swift_foundation_revision:
required: true
type: string
swift_foundation_icu_revision:
required: true
type: string
swift_installer_scripts_revision:
required: true
type: string
swift_llbuild_revision:
required: true
type: string
swift_lmdb_revision:
required: true
type: string
swift_markdown_revision:
required: true
type: string
swift_package_manager_revision:
required: true
type: string
swift_revision:
required: true
type: string
swift_syntax_revision:
required: true
type: string
swift_system_revision:
required: true
type: string
swift_testing_revision:
required: true
type: string
swift_toolchain_sqlite_revision:
required: true
type: string
swift_toolchain_sqlite_version:
required: true
type: string
swift_tools_support_core_revision:
required: true
type: string
yams_revision:
required: true
type: string
zlib_revision:
required: true
type: string
zlib_version:
required: true
type: string
ANDROID_API_LEVEL:
required: true
type: string
ANDROID_NDK_VERSION:
required: true
type: string
WINDOWS_CMAKE_C_FLAGS:
required: true
type: string
WINDOWS_CMAKE_CXX_FLAGS:
required: true
type: string
WINDOWS_CMAKE_EXE_LINKER_FLAGS:
required: true
type: string
WINDOWS_CMAKE_SHARED_LINKER_FLAGS:
required: true
type: string
ANDROID_CMAKE_C_FLAGS:
required: true
type: string
ANDROID_CMAKE_CXX_FLAGS:
required: true
type: string
ANDROID_CMAKE_EXE_LINKER_FLAGS:
required: true
type: string
ANDROID_CMAKE_SHARED_LINKER_FLAGS:
required: true
type: string
CMAKE_Swift_FLAGS:
required: true
type: string
debug_info:
required: true
type: boolean
signed:
required: true
type: boolean
swift_version:
required: true
type: string
swift_tag:
required: true
type: string
default_build_runner:
required: true
type: string
compilers_build_runner:
required: true
type: string
build_android:
required: false
default: false
type: boolean
secrets:
SYMBOL_SERVER_PAT:
required: true
CERTIFICATE:
required: true
PASSPHRASE:
required: true
env:
SCCACHE_DIRECT: on
# Workaround for needing llvm-17 on macOS preventing us from using the 5.10 toolchain release.
WORKAROUND_MACOS_PINNED_BOOTSTRAP_TOOLCHAIN_BRANCH: swift-6.0.1-release
WORKAROUND_MACOS_PINNED_BOOTSTRAP_TOOLCHAIN_TAG: 6.0.1-RELEASE
# Workaround for the upstream builds are still built with VS versions (17.9.x and 17.10.x)
# with the ARM64 miscompile bug.
WORKAROUND_WINDOWS_PINNED_BOOTSTRAP_TOOLCHAIN_REPO: thebrowsercompany/swift-build
WORKAROUND_WINDOWS_PINNED_BOOTSTRAP_TOOLCHAIN_RELEASE: swift-6.0.0-20241216.0
defaults:
run:
shell: pwsh
jobs:
sqlite:
runs-on: ${{ inputs.default_build_runner }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(inputs.host_matrix) }}
name: ${{ matrix.os }} ${{ matrix.arch }} SQLite3
steps:
- uses: actions/checkout@v4
with:
path: ${{ github.workspace }}/SourceCache/swift-build
show-progress: false
- uses: actions/checkout@v4
with:
repository: swiftlang/swift-toolchain-sqlite
ref: ${{ inputs.swift_toolchain_sqlite_revision }}
path: ${{ github.workspace }}/SourceCache/swift-toolchain-sqlite
show-progress: false
- uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main
with:
host_arch: ${{ inputs.build_arch }}
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
arch: ${{ matrix.arch }}
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
if: inputs.build_os == 'Darwin'
- name: Compute workspace hash
id: workspace_hash
run: |
$stringAsStream = [System.IO.MemoryStream]::new()
$writer = [System.IO.StreamWriter]::new($stringAsStream)
$writer.write("${{ github.workspace }}")
$writer.Flush()
$stringAsStream.Position = 0
$hash = (Get-FileHash -Algorithm SHA256 -InputStream $stringAsStream).Hash
echo "hash=$hash" >> $env:GITHUB_OUTPUT
- name: Setup sccache
uses: hendrikmuhs/ccache-action@2e0e89e8d74340a03f75d58d02aae4c5ee1b15c6
with:
max-size: 100M
key: ${{ steps.workspace_hash.outputs.hash }}-${{ matrix.os }}-${{ matrix.arch }}-sqlite
variant: sccache
- name: Configure SQLite
run: |
cmake -B ${{ github.workspace }}/BinaryCache/sqlite-${{ inputs.swift_toolchain_sqlite_version }} `
-D BUILD_SHARED_LIBS=NO `
-D CMAKE_BUILD_TYPE=Release `
-D CMAKE_C_COMPILER=${{ matrix.cc }} `
-D CMAKE_C_COMPILER_LAUNCHER=sccache `
-D CMAKE_C_FLAGS="${{ matrix.cflags }}" `
-D CMAKE_CXX_COMPILER=${{ matrix.cxx }} `
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache `
-D CMAKE_CXX_FLAGS="${{ matrix.cxxflags }}" `
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/sqlite-${{ inputs.swift_toolchain_sqlite_version }}/usr `
-D CMAKE_SYSTEM_NAME=${{ matrix.os }} `
${{ matrix.extra_flags }} `
-G Ninja `
-S ${{ github.workspace }}/SourceCache/swift-toolchain-sqlite
- name: Build SQLite
run: cmake --build ${{ github.workspace }}/BinaryCache/sqlite-${{ inputs.swift_toolchain_sqlite_version }}
- name: Install SQLite
run: cmake --build ${{ github.workspace }}/BinaryCache/sqlite-${{ inputs.swift_toolchain_sqlite_version }} --target install
- uses: actions/upload-artifact@v4
with:
name: sqlite-${{ matrix.os }}-${{ matrix.arch }}-${{ inputs.swift_toolchain_sqlite_version }}
path: ${{ github.workspace }}/BuildRoot/Library/sqlite-${{ inputs.swift_toolchain_sqlite_version }}/usr
ds2_tools:
# TODO: Build this on macOS or make an equivalent Mac-only job
# There is currently no Android NDK for Windows ARM64 so build ds2 only on Windows X64 host only
if: inputs.build_android
runs-on: ${{ inputs.default_build_runner }}
name: ds2 Build Tools
steps:
- uses: actions/checkout@v4
with:
repository: compnerd/ds2
ref: ${{ inputs.ds2_revision }}
path: ${{ github.workspace }}/SourceCache/ds2
show-progress: false
- uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main
with:
host_arch: ${{ inputs.build_arch }}
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
arch: amd64
# TODO(issues/205): Preload Chocolatey package manager on Azure images so we can remove this step.
- uses: andrurogerz/ensure-chocolatey@v1
- name: Install Flex and Bison Tools
run: choco install winflexbison3
- name: Configure RegsGen2
run: |
cmake -B ${{ github.workspace }}/BinaryCache/RegsGen2 `
-S ${{ github.workspace }}/SourceCache/ds2/Tools/RegsGen2 `
-C ${{ github.workspace }}/SourceCache/ds2/cmake/caches/MSVCWarnings.cmake `
-D CMAKE_BUILD_TYPE=Release `
-D CMAKE_C_COMPILER=cl `
-D CMAKE_CXX_COMPILER=cl `
-D CMAKE_C_FLAGS="${{ inputs.WINDOWS_CMAKE_C_FLAGS }}" `
-D CMAKE_CXX_FLAGS="${{ inputs.WINDOWS_CMAKE_CXX_FLAGS }}" `
-G Ninja
- name: Build RegsGen2
run: cmake --build ${{ github.workspace }}/BinaryCache/RegsGen2 --config Release
- uses: actions/upload-artifact@v4
with:
name: windows-regsgen2
path: |
${{ github.workspace }}/BinaryCache/RegsGen2/regsgen2.exe
ds2:
# TODO: Build this on macOS or make an equivalent Mac-only job
# There is currently no Android NDK for Windows ARM64 so build ds2 only on Windows X64 host only
if: inputs.build_android
needs: [ds2_tools]
runs-on: ${{ inputs.default_build_runner }}
strategy:
fail-fast: false
matrix:
include:
- arch: arm64
cc: clang
cflags: ${{ inputs.ANDROID_CMAKE_C_FLAGS }}
cxx: clang++
cxxflags: ${{ inputs.ANDROID_CMAKE_CXX_FLAGS }}
os: Android
extra_flags: -DCMAKE_ANDROID_API=${{ inputs.ANDROID_API_LEVEL }} -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a
- arch: armv7
cc: clang
cflags: ${{ inputs.ANDROID_CMAKE_C_FLAGS }}
cxx: clang++
cxxflags: ${{ inputs.ANDROID_CMAKE_CXX_FLAGS }}
os: Android
extra_flags: -DCMAKE_ANDROID_API=${{ inputs.ANDROID_API_LEVEL }} -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a
- arch: i686
cc: clang
cflags: ${{ inputs.ANDROID_CMAKE_C_FLAGS }}
cxx: clang++
cxxflags: ${{ inputs.ANDROID_CMAKE_CXX_FLAGS }}
os: Android
extra_flags: -DCMAKE_ANDROID_API=${{ inputs.ANDROID_API_LEVEL }} -DCMAKE_ANDROID_ARCH_ABI=x86
- arch: x86_64
cc: clang
cflags: ${{ inputs.ANDROID_CMAKE_C_FLAGS }}
cxx: clang++
cxxflags: ${{ inputs.ANDROID_CMAKE_CXX_FLAGS }}
os: Android
extra_flags: -DCMAKE_ANDROID_API=${{ inputs.ANDROID_API_LEVEL }} -DCMAKE_ANDROID_ARCH_ABI=x86_64
name: ${{ matrix.os }} ${{ matrix.arch }} ds2
steps:
- uses: actions/checkout@v4
with:
repository: compnerd/ds2
ref: ${{ inputs.ds2_revision }}
path: ${{ github.workspace }}/SourceCache/ds2
show-progress: false
- uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main
with:
host_arch: ${{ inputs.build_arch }}
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
arch: ${{ matrix.arch }}
# TODO(issues/205): Preload Chocolatey package manager on Azure images so we can remove this step.
- uses: andrurogerz/ensure-chocolatey@v1
- name: Install Flex and Bison Tools
run: choco install winflexbison3
- uses: actions/download-artifact@v4
with:
name: windows-regsgen2
path: ${{ github.workspace }}/BinaryCache/RegsGen2
- uses: nttld/setup-ndk@v1
if: matrix.os == 'Android'
id: setup-ndk
with:
ndk-version: ${{ inputs.ANDROID_NDK_VERSION }}
- name: Configure DS2
run: |
$NDKPATH = cygpath -m ${{ steps.setup-ndk.outputs.ndk-path }}
cmake -B ${{ github.workspace }}/BinaryCache/ds2 `
-S ${{ github.workspace }}/SourceCache/ds2 `
-D CMAKE_BUILD_TYPE=Release `
-D CMAKE_C_COMPILER=${{ matrix.cc }} `
-D CMAKE_C_FLAGS="${{ matrix.cflags }}" `
-D CMAKE_CXX_COMPILER=${{ matrix.cxx }} `
-D CMAKE_CXX_FLAGS="${{ matrix.cxxflags }}" `
-D MSVC_C_ARCHITECTURE_ID=${{ matrix.arch }} `
-D DS2_REGSGEN2=${{ github.workspace }}/BinaryCache/RegsGen2/regsgen2.exe `
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BinaryCache/Library/Developer `
-D CMAKE_SYSTEM_NAME=${{ matrix.os }} `
-D CMAKE_ANDROID_NDK=$NDKPATH `
${{ matrix.extra_flags }} `
-G Ninja
- name: Build DS2
run: cmake --build ${{ github.workspace }}/BinaryCache/ds2
- name: Install DS2
run: cmake --build ${{ github.workspace }}/BinaryCache/ds2 --target install
- uses: actions/upload-artifact@v4
with:
name: ds2-${{ matrix.os }}-${{ matrix.arch }}
path: ${{ github.workspace }}/BinaryCache/Library/Developer
cmark_gfm:
runs-on: ${{ inputs.default_build_runner }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(inputs.host_matrix) }}
name: ${{ matrix.os }} ${{ matrix.arch }} CMark GFM
steps:
- uses: actions/checkout@v4
with:
repository: swiftlang/swift-cmark
ref: ${{ inputs.swift_cmark_revision }}
path: ${{ github.workspace }}/SourceCache/cmark-gfm
show-progress: false
- uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main
with:
host_arch: ${{ inputs.build_arch }}
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
arch: ${{ matrix.arch }}
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
if: inputs.build_os == 'Darwin'
- name: Compute workspace hash
id: workspace_hash
run: |
$stringAsStream = [System.IO.MemoryStream]::new()
$writer = [System.IO.StreamWriter]::new($stringAsStream)
$writer.write("${{ github.workspace }}")
$writer.Flush()
$stringAsStream.Position = 0
$hash = (Get-FileHash -Algorithm SHA256 -InputStream $stringAsStream).Hash
echo "hash=$hash" >> $env:GITHUB_OUTPUT
- name: Setup sccache
uses: hendrikmuhs/ccache-action@2e0e89e8d74340a03f75d58d02aae4c5ee1b15c6
with:
max-size: 1M
key: ${{ steps.workspace_hash.outputs.hash }}-${{ matrix.os }}-${{ matrix.arch }}-cmark-gfm
variant: sccache
- name: Configure cmark-gfm
run: >
cmake -B ${{ github.workspace }}/BinaryCache/cmark-gfm-${{ inputs.swift_cmark_version }} `
-D BUILD_SHARED_LIBS=YES `
-D BUILD_TESTING=NO `
-D CMAKE_BUILD_TYPE=Release `
-D CMAKE_C_COMPILER=${{ matrix.cc }} `
-D CMAKE_C_COMPILER_LAUNCHER=sccache `
-D CMAKE_C_COMPILER_FLAGS="${{ matrix.cflags }}" `
-D CMAKE_CXX_COMPILER=${{ matrix.cxx }} `
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache `
-D CMAKE_CXX_FLAGS="${{ matrix.cxxflags }}" `
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/cmark-gfm-${{ inputs.swift_cmark_version }}/usr `
-D CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=YES `
-D CMAKE_SYSTEM_NAME=${{ matrix.os }} `
${{ matrix.extra_flags }} `
-S ${{ github.workspace }}/SourceCache/cmark-gfm `
-G Ninja
- name: Build cmark-gfm
run: cmake --build ${{ github.workspace }}/BinaryCache/cmark-gfm-${{ inputs.swift_cmark_version }}
- name: Install cmark-gfm
run: cmake --build ${{ github.workspace }}/BinaryCache/cmark-gfm-${{ inputs.swift_cmark_version }} --target install
- uses: thebrowsercompany/gha-upload-tar-artifact@e18c33b1cd416d0d96a91dc6dce06219f98e4e27 # main
with:
name: cmark-gfm-${{ matrix.os }}-${{ matrix.arch }}-${{ inputs.swift_cmark_version }}
path: ${{ github.workspace }}/BuildRoot/Library/cmark-gfm-${{ inputs.swift_cmark_version }}/usr
build_tools:
needs: [cmark_gfm]
runs-on: ${{ inputs.default_build_runner }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(inputs.build_matrix) }}
name: ${{ matrix.os }} ${{ matrix.arch }} Compiler Build Tools
steps:
- uses: thebrowsercompany/gha-download-tar-artifact@59992d91335d4ecba543c8535f7d07238e42125d # main
with:
name: cmark-gfm-${{ matrix.os }}-${{ matrix.arch }}-${{ inputs.swift_cmark_version }}
path: ${{ github.workspace }}/BuildRoot/Library/cmark-gfm-${{ inputs.swift_cmark_version }}/usr
- uses: actions/checkout@v4
with:
repository: swiftlang/llvm-project
ref: ${{ inputs.llvm_project_revision }}
path: ${{ github.workspace }}/SourceCache/llvm-project
show-progress: false
- uses: actions/checkout@v4
with:
repository: swiftlang/swift
ref: ${{ inputs.swift_revision }}
path: ${{ github.workspace }}/SourceCache/swift
show-progress: false
- uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main
with:
host_arch: ${{ inputs.build_arch }}
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
arch: ${{ matrix.arch }}
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
if: inputs.build_os == 'Darwin'
- name: Compute workspace hash
id: workspace_hash
run: |
$stringAsStream = [System.IO.MemoryStream]::new()
$writer = [System.IO.StreamWriter]::new($stringAsStream)
$writer.write("${{ github.workspace }}")
$writer.Flush()
$stringAsStream.Position = 0
$hash = (Get-FileHash -Algorithm SHA256 -InputStream $stringAsStream).Hash
echo "hash=$hash" >> $env:GITHUB_OUTPUT
- name: Setup sccache
uses: hendrikmuhs/ccache-action@2e0e89e8d74340a03f75d58d02aae4c5ee1b15c6
with:
max-size: 100M
key: ${{ steps.workspace_hash.outputs.hash }}-${{ matrix.os }}-${{ matrix.arch }}-build_tools
variant: sccache
- name: Configure Tools
run: |
cmake -B ${{ github.workspace }}/BinaryCache/0 `
-D CMAKE_BUILD_TYPE=Release `
-D CMAKE_C_COMPILER=${{ matrix.cc }} `
-D CMAKE_C_COMPILER_LAUNCHER=sccache `
-D CMAKE_C_FLAGS="${{ matrix.cflags }}" `
-D CMAKE_CXX_COMPILER=${{ matrix.cxx }} `
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache `
-D CMAKE_CXX_FLAGS="${{ matrix.cxxflags }}" `
${{ matrix.extra_flags }} `
-D cmark-gfm_DIR=${{ github.workspace }}/BuildRoot/Library/cmark-gfm-${{ inputs.swift_cmark_version }}/usr/lib/cmake `
-G Ninja `
-S ${{ github.workspace }}/SourceCache/llvm-project/llvm `
-D LLVM_ENABLE_ASSERTIONS=NO `
-D LLVM_ENABLE_LIBEDIT=NO `
-D LLVM_ENABLE_LIBXML2=NO `
-D LLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lldb" `
-D LLVM_EXTERNAL_PROJECTS="swift" `
-D LLVM_EXTERNAL_SWIFT_SOURCE_DIR=${{ github.workspace }}/SourceCache/swift `
-D LLDB_ENABLE_PYTHON=NO `
-D LLDB_INCLUDE_TESTS=NO `
-D LLDB_ENABLE_SWIFT_SUPPORT=NO `
-D SWIFT_BUILD_DYNAMIC_SDK_OVERLAY=NO `
-D SWIFT_BUILD_DYNAMIC_STDLIB=NO `
-D SWIFT_BUILD_HOST_DISPATCH=NO `
-D SWIFT_BUILD_LIBEXEC=NO `
-D SWIFT_BUILD_REGEX_PARSER_IN_COMPILER=NO `
-D SWIFT_BUILD_REMOTE_MIRROR=NO `
-D SWIFT_BUILD_SOURCEKIT=NO `
-D SWIFT_BUILD_STATIC_SDK_OVERLAY=NO `
-D SWIFT_BUILD_STATIC_STDLIB=NO `
-D SWIFT_BUILD_SWIFT_SYNTAX=NO `
-D SWIFT_ENABLE_DISPATCH=NO `
-D SWIFT_INCLUDE_APINOTES=NO `
-D SWIFT_INCLUDE_DOCS=NO `
-D SWIFT_INCLUDE_TESTS=NO
- name: Build llvm-tblgen
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target llvm-tblgen
- name: Build clang-tblgen
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target clang-tblgen
- name: Build lldb-tblgen
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target lldb-tblgen
- name: Build llvm-config
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target llvm-config
- name: Build clang-pseudo-gen
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target clang-pseudo-gen
- name: Build clang-tidy-confusable-chars-gen
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target clang-tidy-confusable-chars-gen
- name: Build swift-def-to-strings-converter
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target swift-def-to-strings-converter
- name: Build swift-serialize-diagnostics
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target swift-serialize-diagnostics
- name: Build swift-compatibility-symbols
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target swift-compatibility-symbols
- name: Copy binaries
run: |
$Suffix = if ( "${{ matrix.os }}" -eq "Windows" ) { ".exe" } else { "" }
$Binaries = @(
"llvm-tblgen",
"clang-tblgen",
"lldb-tblgen",
"llvm-config",
"clang-pseudo-gen",
"clang-tidy-confusable-chars-gen",
"swift-def-to-strings-converter",
"swift-serialize-diagnostics",
"swift-compatibility-symbols"
)
# Create the target folder.
New-Item -ItemType Directory -Path "${{ github.workspace }}/BuildRoot/bin" -Force | Out-Null
foreach ($Binary in $Binaries) {
Copy-Item -Path "${{ github.workspace }}/BinaryCache/0/bin/${Binary}${Suffix}" -Destination "${{ github.workspace }}/BuildRoot/bin/${Binary}${Suffix}" -Force
}
- uses: thebrowsercompany/gha-upload-tar-artifact@e18c33b1cd416d0d96a91dc6dce06219f98e4e27 # main
with:
name: build-tools-${{ matrix.os }}
path: ${{ github.workspace }}/BuildRoot/bin
early_swift_driver:
runs-on: ${{ inputs.default_build_runner }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(inputs.build_matrix) }}
name: ${{ matrix.os }} ${{ matrix.arch }} early swift-driver
steps:
- uses: actions/checkout@v4
with:
repository: swiftlang/swift-llbuild
ref: ${{ inputs.swift_llbuild_revision }}
path: ${{ github.workspace }}/SourceCache/llbuild
show-progress: false
- uses: actions/checkout@v4
with:
repository: swiftlang/swift-toolchain-sqlite
ref: ${{ inputs.swift_toolchain_sqlite_revision }}
path: ${{ github.workspace }}/SourceCache/swift-toolchain-sqlite
show-progress: false
- uses: actions/checkout@v4
with:
repository: swiftlang/swift-tools-support-core
ref: ${{ inputs.swift_tools_support_core_revision }}
path: ${{ github.workspace }}/SourceCache/swift-tools-support-core
show-progress: false
- uses: actions/checkout@v4
with:
repository: apple/swift-argument-parser
ref: ${{ inputs.swift_argument_parser_revision }}
path: ${{ github.workspace }}/SourceCache/swift-argument-parser
show-progress: false
- uses: actions/checkout@v4
with:
repository: jpsim/Yams
ref: ${{ inputs.yams_revision }}
path: ${{ github.workspace }}/SourceCache/Yams
show-progress: false
- uses: actions/checkout@v4
with:
repository: swiftlang/swift-driver
ref: ${{ inputs.swift_driver_revision }}
path: ${{ github.workspace }}/SourceCache/swift-driver
show-progress: false
- name: Install Swift Toolchain (macOS)
if: matrix.os == 'Darwin'
uses: compnerd/gha-setup-swift@6c9f2db7c3155c57fe35f160bcd5cf5859b9c1ba # main
with:
branch: ${{ env.WORKAROUND_MACOS_PINNED_BOOTSTRAP_TOOLCHAIN_BRANCH }}
tag: ${{ env.WORKAROUND_MACOS_PINNED_BOOTSTRAP_TOOLCHAIN_TAG }}
- name: Install Swift Toolchain (Windows)
if: matrix.os == 'Windows'
uses: compnerd/gha-setup-swift@6c9f2db7c3155c57fe35f160bcd5cf5859b9c1ba # main
with:
github-repo: ${{ env.WORKAROUND_WINDOWS_PINNED_BOOTSTRAP_TOOLCHAIN_REPO }}
github-token: ${{ secrets.GITHUB_TOKEN }}
release-asset-name: installer-${{ inputs.build_arch }}.exe
release-tag-name: ${{ env.WORKAROUND_WINDOWS_PINNED_BOOTSTRAP_TOOLCHAIN_RELEASE }}
- name: Build early swift-driver
run: |
$env:SWIFTCI_USE_LOCAL_DEPS=1
$LinkerFlags = if ("${{ matrix.os }}" -eq "Windows") {
@("-Xlinker", "${env:SDKROOT}/usr/lib/swift/windows/x86_64/swiftCore.lib")
} else {
@()
}
swift build `
--configuration release `
--package-path ${{ github.workspace }}/SourceCache/swift-driver `
--build-path ${{ github.workspace }}/BinaryCache/swift-driver `
@LinkerFlags
- name: Copy binaries
run: |
if ("${{ matrix.os }}" -eq "Windows") {
$ExeSuffix = ".exe"
$Cpu = if ("${{ matrix.arch }}" -eq "arm64") { "aarch64" } else { "x86_64" }
$SourceBinDir = Join-Path "${{ github.workspace }}" "BinaryCache" "swift-driver" "${Cpu}-unknown-windows-msvc" "release"
} else {
$ExeSuffix = ""
$Cpu = "${{ matrix.arch }}"
$SourceBinDir = Join-Path "${{ github.workspace }}" "BinaryCache" "swift-driver" "${Cpu}-apple-macosx" "release"
}
$InstallBinDir = Join-Path "${{ github.workspace }}" "BuildRoot" "bin"
# Create the target folder.
New-Item -ItemType Directory -Path $InstallBinDir -Force
# Copy binaries.
foreach ($bin in @("swift-driver", "swift-help")) {
$binName = "${bin}${ExeSuffix}"
$binPath = Join-Path $InstallBinDir $binName
Copy-Item -Path "${SourceBinDir}/${binName}" -Destination $binPath -Force
}
- uses: thebrowsercompany/gha-upload-tar-artifact@e18c33b1cd416d0d96a91dc6dce06219f98e4e27 # main
with:
name: early-swift-driver-${{ matrix.os }}-${{ matrix.arch }}
path: ${{ github.workspace }}/BuildRoot
compilers:
needs: [libxml2, build_tools, cmark_gfm, early_swift_driver]
runs-on: ${{ inputs.compilers_build_runner }}
env:
# This will grab the latest Python 3.9 version available for setup-python. It is necessary to
# specify in this manner for Mac where actions/setup-python does not have version 3.9.10.
# Once the Python version is upgraded to 3.12, these should be kept in sync.
PYTHON_VERSION_MACOS: 3.9
# Must be a full version string from https://www.nuget.org/packages/pythonarm64
PYTHON_VERSION_WINDOWS: 3.9.10
strategy:
fail-fast: false
matrix: ${{ fromJSON(inputs.host_matrix) }}
name: ${{ matrix.os }} ${{ matrix.arch }} Toolchain
steps:
- uses: thebrowsercompany/gha-download-tar-artifact@59992d91335d4ecba543c8535f7d07238e42125d # main
with:
name: build-tools-${{ matrix.os }}
path: ${{ github.workspace }}/BinaryCache/0/bin
- uses: actions/download-artifact@v4
with:
name: libxml2-${{ matrix.os }}-${{ matrix.arch }}-${{ inputs.libxml2_version }}
path: ${{ github.workspace }}/BinaryCache/Library/libxml2-${{ inputs.libxml2_version }}/usr
- uses: thebrowsercompany/gha-download-tar-artifact@59992d91335d4ecba543c8535f7d07238e42125d # main
with:
name: cmark-gfm-${{ matrix.os }}-${{ matrix.arch }}-${{ inputs.swift_cmark_version }}
path: ${{ github.workspace }}/BinaryCache/Library/cmark-gfm-${{ inputs.swift_cmark_version }}/usr
- uses: thebrowsercompany/gha-download-tar-artifact@59992d91335d4ecba543c8535f7d07238e42125d # main
with:
name: early-swift-driver-${{ inputs.build_os }}-${{ inputs.build_arch }}
path: ${{ github.workspace }}/BinaryCache/swift-driver
- uses: actions/checkout@v4
with:
repository: swiftlang/llvm-project
ref: ${{ inputs.llvm_project_revision }}
path: ${{ github.workspace }}/SourceCache/llvm-project
show-progress: false
- uses: actions/checkout@v4
with:
repository: swiftlang/swift
ref: ${{ inputs.swift_revision }}
path: ${{ github.workspace }}/SourceCache/swift
show-progress: false
- uses: actions/checkout@v4
with:
repository: swiftlang/swift-experimental-string-processing
ref: ${{ inputs.swift_experimental_string_processing_revision }}
path: ${{ github.workspace }}/SourceCache/swift-experimental-string-processing
show-progress: false
- uses: actions/checkout@v4
with:
repository: swiftlang/swift-syntax
ref: ${{ inputs.swift_syntax_revision }}
path: ${{ github.workspace }}/SourceCache/swift-syntax
show-progress: false
- uses: actions/checkout@v4
with:
repository: apple/swift-corelibs-libdispatch
ref: ${{ inputs.swift_corelibs_libdispatch_revision }}
path: ${{ github.workspace }}/SourceCache/swift-corelibs-libdispatch
show-progress: false
- name: Install Python ${{ env.PYTHON_VERSION_MACOS }} (Host)
if: matrix.os == 'Darwin'
uses: actions/setup-python@v5
with:
python-version: '${{ env.PYTHON_VERSION_MACOS }}'
- name: Install Python ${{ env.PYTHON_VERSION_WINDOWS }} (Host)
if: matrix.os == 'Windows' && (matrix.arch == 'amd64' || inputs.build_arch == 'amd64')
uses: actions/setup-python@v5
id: python
with:
python-version: '${{ env.PYTHON_VERSION_WINDOWS }}'
architecture: x64
- uses: nuget/setup-nuget@v2
if: inputs.build_os == 'Windows' && (matrix.arch == 'arm64' || inputs.build_arch == 'arm64')
# TODO(lxbndr) use actions/cache to improve this step timings
- name: Install Python ${{ env.PYTHON_VERSION_WINDOWS }} (Windows arm64)
if: inputs.build_os == 'Windows' && (matrix.arch == 'arm64' || inputs.build_arch == 'arm64')
run: |
$NugetSources=[string](nuget Sources List -Format short)
if (-Not ($NugetSources.contains("api.nuget.org"))) {
nuget sources Add -Name api.nuget.org -Source https://api.nuget.org/v3/index.json -NonInteractive
}
nuget install pythonarm64 -Version ${{ env.PYTHON_VERSION_WINDOWS }}
- name: Export Python Location (Windows)
if: inputs.build_os == 'Windows'
run: |
echo "PYTHON_LOCATION_amd64=$env:pythonLocation" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "PYTHON_LOCATION_arm64=${{ github.workspace }}\pythonarm64.${{ env.PYTHON_VERSION_WINDOWS }}\tools" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main
with:
host_arch: ${{ inputs.build_arch }}
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
arch: ${{ matrix.arch }}
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
if: inputs.build_os == 'Darwin'
- name: Install Swift Toolchain
if: inputs.build_os == 'Windows'
uses: compnerd/gha-setup-swift@6c9f2db7c3155c57fe35f160bcd5cf5859b9c1ba # main
with:
github-repo: ${{ env.WORKAROUND_WINDOWS_PINNED_BOOTSTRAP_TOOLCHAIN_REPO }}
github-token: ${{ secrets.GITHUB_TOKEN }}
release-asset-name: installer-${{ inputs.build_arch }}.exe
release-tag-name: ${{ env.WORKAROUND_WINDOWS_PINNED_BOOTSTRAP_TOOLCHAIN_RELEASE }}
- name: Install Swift Toolchain
if: inputs.build_os == 'Darwin'
uses: compnerd/gha-setup-swift@6c9f2db7c3155c57fe35f160bcd5cf5859b9c1ba # main
with:
branch: ${{ env.WORKAROUND_MACOS_PINNED_BOOTSTRAP_TOOLCHAIN_BRANCH }}
tag: ${{ env.WORKAROUND_MACOS_PINNED_BOOTSTRAP_TOOLCHAIN_TAG }}
- uses: nttld/setup-ndk@v1
if: matrix.os == 'Android'
id: setup-ndk
with:
ndk-version: ${{ inputs.ANDROID_NDK_VERSION }}
- name: Compute workspace hash
id: workspace_hash
shell: pwsh
run: |
$stringAsStream = [System.IO.MemoryStream]::new()
$writer = [System.IO.StreamWriter]::new($stringAsStream)
$writer.write("${{ github.workspace }}")
$writer.Flush()
$stringAsStream.Position = 0
$hash = (Get-FileHash -Algorithm SHA256 -InputStream $stringAsStream).Hash
echo "hash=$hash" >> $env:GITHUB_OUTPUT
- name: Setup sccache
uses: hendrikmuhs/ccache-action@2e0e89e8d74340a03f75d58d02aae4c5ee1b15c6
with:
max-size: 500M
key: ${{ steps.workspace_hash.outputs.hash }}-${{ matrix.os }}-${{ matrix.arch }}-compilers
variant: sccache
- name: Configure Compilers
run: |
$CxxFlags = "${{ matrix.cxxflags }}"
$SwiftFlags = ""
$EXTRA_FLAGS = @()
if ( "${{ matrix.os }}" -eq "Windows" ) {
$SWIFTC = cygpath -m (Get-Command swiftc).Source
# Use toolchain clang to avoid broken __prefetch intrinsic on arm64 in Clang 18.
# TODO: Use llvm-19 when available. See https://github.com/compnerd/swift-build/issues/846
$CLANG_LOCATION = Split-Path (Get-Command swiftc).Source
if ( "${{ matrix.arch }}" -eq "arm64" ) {
$EXTRA_FLAGS += "${{ matrix.extra_flags }}".Split()
$EXTRA_FLAGS += @("-D", "CMAKE_SYSTEM_NAME=Windows")
$CACHE="${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-aarch64.cmake"
# FIXME(compnerd) re-enable runtimes after we sort out compiler-rt
(Get-Content ${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-aarch64.cmake).Replace(' runtimes', '') | Set-Content ${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-aarch64.cmake
} else {
$CACHE="${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-x86_64.cmake"
}
$CC = "cl"
$CXX = "cl"