Skip to content

Commit abcedc8

Browse files
authored
[mac build] Build early swift-driver (#836)
This is a required preliminary step to build the compiler on macOS. * Separate Swift flags between Windows and Darwin. * Move arch-specific and OS-specific flags to matrix.extra_flags.
1 parent ba250e7 commit abcedc8

File tree

2 files changed

+166
-26
lines changed

2 files changed

+166
-26
lines changed

.github/workflows/build-toolchain.yml

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ jobs:
147147
ANDROID_CMAKE_EXE_LINKER_FLAGS: ${{ steps.context.outputs.ANDROID_CMAKE_EXE_LINKER_FLAGS }}
148148
ANDROID_CMAKE_SHARED_LINKER_FLAGS: ${{ steps.context.outputs.ANDROID_CMAKE_SHARED_LINKER_FLAGS }}
149149
ANDROID_NDK_VERSION: ${{ steps.context.outputs.ANDROID_NDK_VERSION }}
150-
CMAKE_Swift_FLAGS: ${{ steps.context.outputs.CMAKE_Swift_FLAGS }}
150+
WINDOWS_CMAKE_Swift_FLAGS: ${{ steps.context.outputs.WINDOWS_CMAKE_Swift_FLAGS }}
151+
DARWIN_CMAKE_Swift_FLAGS: ${{ steps.context.outputs.DARWIN_CMAKE_Swift_FLAGS }}
151152
debug_info: ${{ steps.context.outputs.debug_info }}
152153
signed: ${{ steps.context.outputs.signed }}
153154
swift_version: ${{ steps.context.outputs.swift_version }}
@@ -247,7 +248,8 @@ jobs:
247248
echo ANDROID_CMAKE_CXX_FLAGS="-ffunction-sections -fdata-sections -g" >> ${GITHUB_OUTPUT}
248249
echo WINDOWS_CMAKE_EXE_LINKER_FLAGS="-incremental:no -debug -opt:ref -opt:icf" >> ${GITHUB_OUTPUT}
249250
echo WINDOWS_CMAKE_SHARED_LINKER_FLAGS="-incremental:no -debug -opt:ref -opt:icf" >> ${GITHUB_OUTPUT}
250-
echo CMAKE_Swift_FLAGS="-g -debug-info-format=codeview -Xlinker -debug -Xlinker -incremental:no -Xlinker -opt:ref -Xlinker -opt:icf" >> ${GITHUB_OUTPUT}
251+
echo WINDOWS_CMAKE_Swift_FLAGS="-g -debug-info-format=codeview -Xlinker -debug -Xlinker -incremental:no -Xlinker -opt:ref -Xlinker -opt:icf" >> ${GITHUB_OUTPUT}
252+
echo DARWIN_CMAKE_Swift_FLAGS="-g" >> ${GITHUB_OUTPUT}
251253
else
252254
echo debug_info=false >> ${GITHUB_OUTPUT}
253255
echo WINDOWS_CMAKE_C_FLAGS="/GS- /Gw /Gy /Oi /Oy /Zc:inline /Zc:preprocessor" >> ${GITHUB_OUTPUT}
@@ -258,7 +260,8 @@ jobs:
258260
echo ANDROID_CMAKE_CXX_FLAGS="-ffunction-sections -fdata-sections" >> ${GITHUB_OUTPUT}
259261
echo WINDOWS_CMAKE_EXE_LINKER_FLAGS="" >> ${GITHUB_OUTPUT}
260262
echo WINDOWS_CMAKE_SHARED_LINKER_FLAGS="" >> ${GITHUB_OUTPUT}
261-
echo CMAKE_Swift_FLAGS="-Xlinker -incremental:no -Xlinker -opt:ref -Xlinker -opt:icf" >> ${GITHUB_OUTPUT}
263+
echo WINDOWS_CMAKE_Swift_FLAGS="-Xlinker -incremental:no -Xlinker -opt:ref -Xlinker -opt:icf" >> ${GITHUB_OUTPUT}
264+
echo DARWIN_CMAKE_Swift_FLAGS="" >> ${GITHUB_OUTPUT}
262265
fi
263266
echo ANDROID_CMAKE_EXE_LINKER_FLAGS="" >> ${GITHUB_OUTPUT}
264267
echo ANDROID_CMAKE_SHARED_LINKER_FLAGS="" >> ${GITHUB_OUTPUT}
@@ -303,19 +306,25 @@ jobs:
303306
"include": [
304307
{
305308
"arch": "amd64",
309+
"compiler_target": "x86_64-unknown-windows-msvc",
306310
"os": "Windows",
307311
"cc": "cl",
308312
"cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}",
309313
"cxx": "cl",
310-
"cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}"
314+
"cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}",
315+
"swiftflags": "${{ steps.context.outputs.WINDOWS_CMAKE_Swift_FLAGS }}",
316+
"extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=AMD64 -D CMAKE_MT=mt"
311317
},
312318
{
313319
"arch": "arm64",
320+
"compiler_target": "aarch64-unknown-windows-msvc",
314321
"os": "Windows",
315322
"cc": "cl",
316323
"cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}",
317324
"cxx": "cl",
318-
"cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}"
325+
"cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}",
326+
"swiftflags": "${{ steps.context.outputs.WINDOWS_CMAKE_Swift_FLAGS }}",
327+
"extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=ARM64 -D CMAKE_MT=mt"
319328
}
320329
]
321330
}
@@ -328,7 +337,9 @@ jobs:
328337
"cc": "cl",
329338
"cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}",
330339
"cxx": "cl",
331-
"cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}"
340+
"cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}",
341+
"swiftflags": "${{ steps.context.outputs.WINDOWS_CMAKE_Swift_FLAGS }}",
342+
"extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=AMD64 -D CMAKE_MT=mt"
332343
}
333344
]
334345
}
@@ -342,7 +353,8 @@ jobs:
342353
"cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}",
343354
"cxx": "cl",
344355
"cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}",
345-
"extra_flags": ""
356+
"swiftflags": "${{ steps.context.outputs.WINDOWS_CMAKE_Swift_FLAGS }}",
357+
"extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=AMD64 -D CMAKE_MT=mt"
346358
},
347359
{
348360
"arch": "arm64",
@@ -351,7 +363,8 @@ jobs:
351363
"cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}",
352364
"cxx": "cl",
353365
"cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}",
354-
"extra_flags": ""
366+
"swiftflags": "${{ steps.context.outputs.WINDOWS_CMAKE_Swift_FLAGS }}",
367+
"extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=ARM64 -D CMAKE_MT=mt"
355368
},
356369
{
357370
"arch": "x86",
@@ -360,7 +373,8 @@ jobs:
360373
"cflags": "${{ steps.context.outputs.WINDOWS_CMAKE_C_FLAGS }}",
361374
"cxx": "cl",
362375
"cxxflags": "${{ steps.context.outputs.WINDOWS_CMAKE_CXX_FLAGS }}",
363-
"extra_flags": ""
376+
"swiftflags": "",
377+
"extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=X86 -D CMAKE_MT=mt"
364378
},
365379
{
366380
"arch": "arm64",
@@ -369,6 +383,7 @@ jobs:
369383
"cflags": "${{ steps.context.outputs.ANDROID_CMAKE_C_FLAGS }}",
370384
"cxx": "clang++",
371385
"cxxflags": "${{ steps.context.outputs.ANDROID_CMAKE_CXX_FLAGS }}",
386+
"swiftflags": "",
372387
"extra_flags": "-DCMAKE_ANDROID_API=${{ inputs.ANDROID_API_LEVEL }} -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a"
373388
},
374389
{
@@ -378,6 +393,7 @@ jobs:
378393
"cflags": "${{ steps.context.outputs.ANDROID_CMAKE_C_FLAGS }}",
379394
"cxx": "clang++",
380395
"cxxflags": "${{ steps.context.outputs.ANDROID_CMAKE_CXX_FLAGS }}",
396+
"swiftflags": "",
381397
"extra_flags": "-DCMAKE_ANDROID_API=${{ inputs.ANDROID_API_LEVEL }} -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a"
382398
},
383399
{
@@ -387,6 +403,7 @@ jobs:
387403
"cflags": "${{ steps.context.outputs.ANDROID_CMAKE_C_FLAGS }}",
388404
"cxx": "clang++",
389405
"cxxflags": "${{ steps.context.outputs.ANDROID_CMAKE_CXX_FLAGS }}",
406+
"swiftflags": "",
390407
"extra_flags": "-DCMAKE_ANDROID_API=${{ inputs.ANDROID_API_LEVEL }} -DCMAKE_ANDROID_ARCH_ABI=x86"
391408
},
392409
{
@@ -396,6 +413,7 @@ jobs:
396413
"cflags": "${{ steps.context.outputs.ANDROID_CMAKE_C_FLAGS }}",
397414
"cxx": "clang++",
398415
"cxxflags": "${{ steps.context.outputs.ANDROID_CMAKE_CXX_FLAGS }}",
416+
"swiftflags": "",
399417
"extra_flags": "-DCMAKE_ANDROID_API=${{ inputs.ANDROID_API_LEVEL }} -DCMAKE_ANDROID_ARCH_ABI=x86_64"
400418
}
401419
]
@@ -405,32 +423,40 @@ jobs:
405423
"include": [
406424
{
407425
"arch": "x86_64",
426+
"compiler_target": "x86_64-apple-macosx10.15",
408427
"os": "Darwin",
409428
"cc": "clang",
410429
"cflags": "${{ steps.context.outputs.DARWIN_CMAKE_C_FLAGS }}",
411430
"cxx": "clang++",
412-
"cxxflags": "${{ steps.context.outputs.DARWIN_CMAKE_CXX_FLAGS }}"
431+
"cxxflags": "${{ steps.context.outputs.DARWIN_CMAKE_CXX_FLAGS }}",
432+
"swiftflags": "${{ steps.context.outputs.DARWIN_CMAKE_Swift_FLAGS }}",
433+
"extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=x86_64 -D CMAKE_OSX_DEPLOYMENT_TARGET=\"10.15\" -D CMAKE_OSX_ARCHITECTURES=x86_64"
413434
},
414435
{
415-
"arch": "aarch64",
436+
"arch": "arm64",
437+
"compiler_target": "arm64-apple-macosx10.15",
416438
"os": "Darwin",
417439
"cc": "clang",
418440
"cflags": "${{ steps.context.outputs.DARWIN_CMAKE_C_FLAGS }}",
419441
"cxx": "clang++",
420-
"cxxflags": "${{ steps.context.outputs.DARWIN_CMAKE_CXX_FLAGS }}"
442+
"cxxflags": "${{ steps.context.outputs.DARWIN_CMAKE_CXX_FLAGS }}",
443+
"swiftflags": "${{ steps.context.outputs.DARWIN_CMAKE_Swift_FLAGS }}",
444+
"extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=arm64 -D CMAKE_OSX_DEPLOYMENT_TARGET=\"10.15\" -D CMAKE_OSX_ARCHITECTURES=arm64"
421445
}
422446
]
423447
}
424448
DARWIN_BUILD_MATRIX: >-
425449
{
426450
"include": [
427451
{
428-
"arch": "aarch64",
452+
"arch": "arm64",
429453
"os": "Darwin",
430454
"cc": "clang",
431455
"cflags": "${{ steps.context.outputs.DARWIN_CMAKE_C_FLAGS }}",
432456
"cxx": "clang++",
433457
"cxxflags": "${{ steps.context.outputs.DARWIN_CMAKE_CXX_FLAGS }}"
458+
"swiftflags": "${{ steps.context.outputs.DARWIN_CMAKE_Swift_FLAGS }}",
459+
"extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=arm64 -D CMAKE_OSX_DEPLOYMENT_TARGET=\"10.15\" -D CMAKE_OSX_ARCHITECTURES=arm64"
434460
}
435461
]
436462
}
@@ -444,16 +470,18 @@ jobs:
444470
"cflags": "${{ steps.context.outputs.DARWIN_CMAKE_C_FLAGS }}",
445471
"cxx": "clang++",
446472
"cxxflags": "${{ steps.context.outputs.DARWIN_CMAKE_CXX_FLAGS }}",
447-
"extra_flags": ""
473+
"swiftflags": "${{ steps.context.outputs.DARWIN_CMAKE_Swift_FLAGS }}",
474+
"extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=x86_64 -D CMAKE_OSX_DEPLOYMENT_TARGET=\"10.15\" -D CMAKE_OSX_ARCHITECTURES=x86_64"
448475
},
449476
{
450-
"arch": "aarch64",
477+
"arch": "arm64",
451478
"os": "Darwin",
452479
"cc": "clang",
453480
"cflags": "${{ steps.context.outputs.DARWIN_CMAKE_C_FLAGS }}",
454481
"cxx": "clang++",
455482
"cxxflags": "${{ steps.context.outputs.DARWIN_CMAKE_CXX_FLAGS }}",
456-
"extra_flags": ""
483+
"swiftflags": "${{ steps.context.outputs.DARWIN_CMAKE_Swift_FLAGS }}",
484+
"extra_flags": "-D CMAKE_SYSTEM_PROCESSOR=arm64 -D CMAKE_OSX_DEPLOYMENT_TARGET=\"10.15\" -D CMAKE_OSX_ARCHITECTURES=arm64"
457485
}
458486
]
459487
}
@@ -524,7 +552,7 @@ jobs:
524552
ANDROID_CMAKE_EXE_LINKER_FLAGS: ${{ needs.context.outputs.ANDROID_CMAKE_EXE_LINKER_FLAGS }}
525553
ANDROID_CMAKE_SHARED_LINKER_FLAGS: ${{ needs.context.outputs.ANDROID_CMAKE_SHARED_LINKER_FLAGS }}
526554
ANDROID_NDK_VERSION: ${{ needs.context.outputs.ANDROID_NDK_VERSION }}
527-
CMAKE_Swift_FLAGS: ${{ needs.context.outputs.CMAKE_Swift_FLAGS }}
555+
CMAKE_Swift_FLAGS: ${{ needs.context.outputs.WINDOWS_CMAKE_Swift_FLAGS }}
528556
debug_info: ${{ fromJSON(needs.context.outputs.debug_info) }}
529557
signed: ${{ fromJSON(needs.context.outputs.signed) }}
530558
swift_version: ${{ needs.context.outputs.swift_version }}
@@ -597,7 +625,7 @@ jobs:
597625
ANDROID_CMAKE_EXE_LINKER_FLAGS: ${{ needs.context.outputs.ANDROID_CMAKE_EXE_LINKER_FLAGS }}
598626
ANDROID_CMAKE_SHARED_LINKER_FLAGS: ${{ needs.context.outputs.ANDROID_CMAKE_SHARED_LINKER_FLAGS }}
599627
ANDROID_NDK_VERSION: ${{ needs.context.outputs.ANDROID_NDK_VERSION }}
600-
CMAKE_Swift_FLAGS: ${{ needs.context.outputs.CMAKE_Swift_FLAGS }}
628+
CMAKE_Swift_FLAGS: ${{ needs.context.outputs.DARWIN_CMAKE_Swift_FLAGS }}
601629
debug_info: ${{ fromJSON(needs.context.outputs.debug_info) }}
602630
signed: ${{ fromJSON(needs.context.outputs.signed) }}
603631
swift_version: ${{ needs.context.outputs.swift_version }}

0 commit comments

Comments
 (0)