Skip to content

Commit 3645aa7

Browse files
Add option to build compilers with clang-cl/lld-link (#1040)
1 parent bd02309 commit 3645aa7

File tree

2 files changed

+59
-16
lines changed

2 files changed

+59
-16
lines changed

.github/workflows/build-toolchain.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ on:
5454
default: false
5555
type: boolean
5656

57-
stable_point:
58-
description: 'Use Repo Smart Sync'
57+
use_host_toolchain:
58+
description: 'Use host toolchain (MSVC) instead of clang-cl/lld-link'
5959
type: boolean
60-
default: false
60+
default: true
6161
required: false
6262

6363
workflow_call:
@@ -628,6 +628,7 @@ jobs:
628628
compilers_build_runner: ${{ needs.context.outputs[format('windows_{0}_compilers_runner', needs.context.outputs.windows_build_cpu)] }}
629629
build_android: ${{ inputs.build_android }}
630630
python_version: ${{ needs.context.outputs.python_version }}
631+
use_host_toolchain: ${{ inputs.use_host_toolchain }}
631632
secrets:
632633
SYMBOL_SERVER_PAT: ${{ secrets.SYMBOL_SERVER_PAT }}
633634
CERTIFICATE: ${{ secrets.CERTIFICATE }}

.github/workflows/swift-toolchain.yml

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ on:
248248
required: true
249249
type: string
250250

251+
use_host_toolchain:
252+
required: false
253+
type: boolean
254+
default: true
255+
251256
secrets:
252257
SYMBOL_SERVER_PAT:
253258
required: true
@@ -350,10 +355,12 @@ jobs:
350355
install-dir: ${{ github.workspace }}/BuildRoot/Library/sqlite-${{ inputs.swift_toolchain_sqlite_version }}/usr
351356
android-api-level: ${{ inputs.ANDROID_API_LEVEL }}
352357
android-clang-version: ${{ inputs.ANDROID_CLANG_VERSION }}
353-
msvc-compilers: '@("C")'
358+
msvc-compilers: ${{ inputs.use_host_toolchain && '@("C")' || '@()' }}
359+
pinned-compilers: ${{ inputs.use_host_toolchain && '@()' || '@("C")' }}
354360
cmake-defines: |
355361
@{
356362
'BUILD_SHARED_LIBS' = "NO";
363+
'CMAKE_C_FLAGS' = "${{ inputs.use_host_toolchain && '' || '-fuse-ld=lld' }}";
357364
}
358365
- name: Build SQLite
359366
run: cmake --build ${{ github.workspace }}/BinaryCache/sqlite-${{ inputs.swift_toolchain_sqlite_version }}
@@ -434,8 +441,14 @@ jobs:
434441
arch: ${{ inputs.build_arch }}
435442
src-dir: ${{ github.workspace }}/SourceCache/ds2/Tools/RegsGen2
436443
bin-dir: ${{ github.workspace }}/BinaryCache/RegsGen2
437-
msvc-compilers: '@("C", "CXX")'
444+
msvc-compilers: ${{ inputs.use_host_toolchain && '@("C", "CXX")' || '@()' }}
445+
pinned-compilers: ${{ inputs.use_host_toolchain && '@()' || '@("C", "CXX")' }}
438446
cache-script: ${{ github.workspace }}/SourceCache/ds2/cmake/caches/MSVCWarnings.cmake
447+
cmake-defines: |
448+
@{
449+
'CMAKE_C_FLAGS' = "${{ inputs.use_host_toolchain && '' || '-fuse-ld=lld' }}";
450+
'CMAKE_CXX_FLAGS' = "${{ inputs.use_host_toolchain && '' || '-fuse-ld=lld' }}";
451+
}
439452
- name: Build RegsGen2
440453
if: inputs.build_android
441454
run: cmake --build ${{ github.workspace }}/BinaryCache/RegsGen2 --config Release
@@ -632,12 +645,15 @@ jobs:
632645
src-dir: ${{ github.workspace }}/SourceCache/cmark-gfm
633646
bin-dir: ${{ github.workspace }}/BinaryCache/cmark-gfm-${{ inputs.swift_cmark_version }}
634647
install-dir: ${{ github.workspace }}/BuildRoot/Library/cmark-gfm-${{ inputs.swift_cmark_version }}/usr
635-
msvc-compilers: '@("C", "CXX")'
648+
msvc-compilers: ${{ inputs.use_host_toolchain && '@("C", "CXX")' || '@()' }}
649+
pinned-compilers: ${{ inputs.use_host_toolchain && '@()' || '@("C", "CXX")' }}
636650
cmake-defines: |
637651
@{
638652
'BUILD_SHARED_LIBS' = "YES";
639653
'BUILD_TESTING' = "NO";
640654
'CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP' = "YES";
655+
'CMAKE_C_FLAGS' = "${{ inputs.use_host_toolchain && '' || '-fuse-ld=lld' }}";
656+
'CMAKE_CXX_FLAGS' = "${{ inputs.use_host_toolchain && '' || '-fuse-ld=lld' }}";
641657
}
642658
- name: Build cmark-gfm
643659
run: cmake --build ${{ github.workspace }}/BinaryCache/cmark-gfm-${{ inputs.swift_cmark_version }}
@@ -725,7 +741,8 @@ jobs:
725741
arch: ${{ matrix.arch }}
726742
src-dir: ${{ github.workspace }}/SourceCache/llvm-project/llvm
727743
bin-dir: ${{ github.workspace }}/BinaryCache/0
728-
msvc-compilers: '@("ASM_MASM", "C", "CXX")'
744+
msvc-compilers: ${{ inputs.use_host_toolchain && '@("ASM_MASM", "C", "CXX")' || '@()' }}
745+
pinned-compilers: ${{ inputs.use_host_toolchain && '@()' || '@("ASM_MASM", "C", "CXX")' }}
729746
cmake-defines: |
730747
@{
731748
'CMAKE_CROSSCOMPILING' = "NO";
@@ -755,6 +772,8 @@ jobs:
755772
'SWIFT_INCLUDE_DOCS' = "NO";
756773
'SWIFT_INCLUDE_TESTS' = "NO";
757774
'cmark-gfm_DIR' = "${{ github.workspace }}/BuildRoot/Library/cmark-gfm-${{ inputs.swift_cmark_version }}/usr/lib/cmake";
775+
'CMAKE_C_FLAGS' = "${{ inputs.use_host_toolchain && '' || '-fuse-ld=lld' }}";
776+
'CMAKE_CXX_FLAGS' = "${{ inputs.use_host_toolchain && '' || '-fuse-ld=lld' }}";
758777
}
759778
- name: Build llvm-tblgen
760779
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target llvm-tblgen
@@ -1087,8 +1106,8 @@ jobs:
10871106
bin-dir: ${{ github.workspace }}/BinaryCache/1
10881107
install-dir: ${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/${{ inputs.swift_version }}+${{ matrix.variant }}/usr
10891108
swift-sdk-path: ${{ steps.setup-context.outputs.sdkroot }}
1090-
msvc-compilers: '@("C", "CXX")'
1091-
pinned-compilers: '@("Swift")'
1109+
msvc-compilers: ${{ inputs.use_host_toolchain && '@("C", "CXX")' || '@()' }}
1110+
pinned-compilers: ${{ inputs.use_host_toolchain && '@("Swift")' || '@("C", "CXX", "Swift")' }}
10921111
cache-script: ${{ github.workspace }}/SourceCache/swift/cmake/caches/${{ matrix.os }}-${{ matrix.cpu }}.cmake
10931112
cmake-defines: |
10941113
@{
@@ -1106,6 +1125,7 @@ jobs:
11061125
'LLDB_TABLEGEN' = "${{ github.workspace }}/BinaryCache/0/bin/lldb-tblgen${ExeSuffix}";
11071126
'LLVM_CONFIG_PATH' = "${{ github.workspace }}/BinaryCache/0/bin/llvm-config${ExeSuffix}";
11081127
'LLVM_ENABLE_ASSERTIONS' = ${{ matrix.variant == 'Asserts' && '"YES"' || '"NO"' }};
1128+
'LLVM_ENABLE_LLD' = "${{ inputs.use_host_toolchain && 'NO' || 'YES' }}";
11091129
'LLVM_EXTERNAL_SWIFT_SOURCE_DIR' = "${{ github.workspace }}/SourceCache/swift";
11101130
'LLVM_HOST_TRIPLE' = "${{ matrix.triple }}";
11111131
'LLVM_NATIVE_TOOL_DIR' = "${{ github.workspace }}/BinaryCache/0/bin";
@@ -1140,6 +1160,9 @@ jobs:
11401160
'LLVM_VERSION_SUFFIX' = "";
11411161
'LLVM_PARALLEL_LINK_JOBS' = "${{ steps.setup-context.outputs.link-jobs }}";
11421162
'SWIFT_PARALLEL_LINK_JOBS' = "${{ steps.setup-context.outputs.link-jobs }}";
1163+
'CMAKE_C_FLAGS' = "${{ inputs.use_host_toolchain && '' || '-fuse-ld=lld' }}";
1164+
'CMAKE_CXX_FLAGS' = "${{ inputs.use_host_toolchain && '' || '-fuse-ld=lld' }}";
1165+
'CMAKE_Swift_FLAGS' = "${{ inputs.use_host_toolchain && '' || '-use-ld=lld' }}";
11431166
}
11441167
11451168
- name: Build Compiler Distribution
@@ -1308,11 +1331,13 @@ jobs:
13081331
android-api-level: ${{ inputs.ANDROID_API_LEVEL }}
13091332
android-clang-version: ${{ inputs.ANDROID_CLANG_VERSION }}
13101333
ndk-path: ${{ steps.setup-ndk.outputs.ndk-path }}
1311-
msvc-compilers: '@("C")'
1334+
msvc-compilers: ${{ inputs.use_host_toolchain && '@("C")' || '@()' }}
1335+
pinned-compilers: ${{ inputs.use_host_toolchain && '@()' || '@("C")' }}
13121336
cmake-defines: |
13131337
@{
13141338
'BUILD_SHARED_LIBS' = "NO";
13151339
'CMAKE_POSITION_INDEPENDENT_CODE' = "YES";
1340+
'CMAKE_C_FLAGS' = "${{ inputs.use_host_toolchain && '' || '-fuse-ld=lld' }}";
13161341
}
13171342
- name: Build zlib
13181343
run: cmake --build ${{ github.workspace }}/BinaryCache/zlib-${{ inputs.zlib_version }}
@@ -1396,11 +1421,13 @@ jobs:
13961421
android-api-level: ${{ inputs.ANDROID_API_LEVEL }}
13971422
android-clang-version: ${{ inputs.ANDROID_CLANG_VERSION }}
13981423
ndk-path: ${{ steps.setup-ndk.outputs.ndk-path }}
1399-
msvc-compilers: '@("C")'
1424+
msvc-compilers: ${{ inputs.use_host_toolchain && '@("C")' || '@()' }}
1425+
pinned-compilers: ${{ inputs.use_host_toolchain && '@()' || '@("C")' }}
14001426
cmake-defines: |
14011427
@{
14021428
'BUILD_SHARED_LIBS' = "NO";
14031429
'CMAKE_POSITION_INDEPENDENT_CODE' = "YES";
1430+
'CMAKE_C_FLAGS' = "${{ inputs.use_host_toolchain && '' || '-fuse-ld=lld' }}";
14041431
}
14051432
- name: Build brotli
14061433
run: cmake --build ${{ github.workspace }}/BinaryCache/brotli-${{ inputs.brotli_version }}
@@ -1490,7 +1517,8 @@ jobs:
14901517
android-api-level: ${{ inputs.ANDROID_API_LEVEL }}
14911518
android-clang-version: ${{ inputs.ANDROID_CLANG_VERSION }}
14921519
ndk-path: ${{ steps.setup-ndk.outputs.ndk-path }}
1493-
msvc-compilers: '@("C")'
1520+
msvc-compilers: ${{ inputs.use_host_toolchain && '@("C")' || '@()' }}
1521+
pinned-compilers: ${{ inputs.use_host_toolchain && '@()' || '@("C")' }}
14941522
cmake-defines: |
14951523
@{
14961524
'BUILD_SHARED_LIBS' = "NO";
@@ -1580,6 +1608,7 @@ jobs:
15801608
'USE_WIN32_LDAP' = "NO";
15811609
'ZLIB_ROOT' = "${{ github.workspace }}/BuildRoot/Library/zlib-${{ inputs.zlib_version }}/usr";
15821610
'ZLIB_LIBRARY' = "${{ github.workspace }}/BuildRoot/Library/zlib-${{ inputs.zlib_version }}/usr/lib/zlibstatic.lib";
1611+
'CMAKE_C_FLAGS' = "${{ inputs.use_host_toolchain && '' || '-fuse-ld=lld' }}";
15831612
}
15841613
- name: Build curl
15851614
run: cmake --build ${{ github.workspace }}/BinaryCache/curl-${{ inputs.curl_version }}
@@ -1663,7 +1692,8 @@ jobs:
16631692
android-api-level: ${{ inputs.ANDROID_API_LEVEL }}
16641693
android-clang-version: ${{ inputs.ANDROID_CLANG_VERSION }}
16651694
ndk-path: ${{ steps.setup-ndk.outputs.ndk-path }}
1666-
msvc-compilers: '@("C", "CXX")'
1695+
msvc-compilers: ${{ inputs.use_host_toolchain && '@("C", "CXX")' || '@()' }}
1696+
pinned-compilers: ${{ inputs.use_host_toolchain && '@()' || '@("C", "CXX")' }}
16671697
cmake-defines: |
16681698
@{
16691699
'BUILD_SHARED_LIBS' = "NO";
@@ -1675,6 +1705,8 @@ jobs:
16751705
'LIBXML2_WITH_TESTS' = "NO";
16761706
'LIBXML2_WITH_THREADS' = "YES";
16771707
'LIBXML2_WITH_ZLIB' = "NO";
1708+
'CMAKE_C_FLAGS' = "${{ inputs.use_host_toolchain && '' || '-fuse-ld=lld' }}";
1709+
'CMAKE_CXX_FLAGS' = "${{ inputs.use_host_toolchain && '' || '-fuse-ld=lld' }}";
16781710
}
16791711
- name: Build libxml2
16801712
run: cmake --build ${{ github.workspace }}/BinaryCache/libxml2-${{ inputs.libxml2_version }}
@@ -1795,11 +1827,14 @@ jobs:
17951827
android-api-level: ${{ inputs.ANDROID_API_LEVEL }}
17961828
android-clang-version: ${{ inputs.ANDROID_CLANG_VERSION }}
17971829
ndk-path: ${{ steps.setup-ndk.outputs.ndk-path }}
1798-
msvc-compilers: '@("ASM_MASM", "C", "CXX")'
1830+
msvc-compilers: ${{ inputs.use_host_toolchain && '@("ASM_MASM", "C", "CXX")' || '@()' }}
1831+
pinned-compilers: ${{ inputs.use_host_toolchain && '@()' || '@("ASM_MASM", "C", "CXX")' }}
17991832
cmake-defines: |
18001833
@{
18011834
'LLVM_ENABLE_ASSERTIONS' = "YES";
18021835
'LLVM_HOST_TRIPLE' = "${{ matrix.triple }}";
1836+
'CMAKE_C_FLAGS' = "${{ inputs.use_host_toolchain && '' || '-fuse-ld=lld' }}";
1837+
'CMAKE_CXX_FLAGS' = "${{ inputs.use_host_toolchain && '' || '-fuse-ld=lld' }}";
18031838
}
18041839
18051840
- name: Configure Swift Standard Library
@@ -3706,7 +3741,8 @@ jobs:
37063741
bin-dir: ${{ github.workspace }}/BinaryCache/swift-format
37073742
install-dir: ${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/${{ inputs.swift_version }}+Asserts/usr
37083743
swift-sdk-path: ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/${{ matrix.os }}.platform/Developer/SDKs/${{ matrix.os }}.sdk
3709-
msvc-compilers: '@("C")'
3744+
msvc-compilers: ${{ inputs.use_host_toolchain && '@("C")' || '@()' }}
3745+
pinned-compilers: ${{ inputs.use_host_toolchain && '@()' || '@("C")' }}
37103746
built-compilers: '@("Swift")'
37113747
cmake-defines: |
37123748
@{
@@ -3715,6 +3751,7 @@ jobs:
37153751
'SwiftMarkdown_DIR' = "${{ github.workspace }}/BinaryCache/swift-markdown/cmake/modules";
37163752
'SwiftSyntax_DIR' = "${{ github.workspace }}/BinaryCache/swift-syntax/cmake/modules";
37173753
'cmark-gfm_DIR' = "${{ github.workspace }}/BinaryCache/Library/cmark-gfm-${{ inputs.swift_cmark_version }}/usr/lib/cmake";
3754+
'CMAKE_C_FLAGS' = "${{ inputs.use_host_toolchain && '' || '-fuse-ld=lld' }}";
37183755
}
37193756
- name: Build swift-format
37203757
run: cmake --build ${{ github.workspace }}/BinaryCache/swift-format
@@ -3733,7 +3770,12 @@ jobs:
37333770
src-dir: ${{ github.workspace }}/SourceCache/swift-lmdb
37343771
bin-dir: ${{ github.workspace }}/BinaryCache/swift-lmdb
37353772
swift-sdk-path: ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/${{ matrix.os }}.platform/Developer/SDKs/${{ matrix.os }}.sdk
3736-
msvc-compilers: '@("C")'
3773+
msvc-compilers: ${{ inputs.use_host_toolchain && '@("C")' || '@()' }}
3774+
pinned-compilers: ${{ inputs.use_host_toolchain && '@()' || '@("C")' }}
3775+
cmake-defines: |
3776+
@{
3777+
'CMAKE_C_FLAGS' = "${{ inputs.use_host_toolchain && '' || '-fuse-ld=lld' }}";
3778+
}
37373779
- name: Build swift-lmdb
37383780
run: cmake --build ${{ github.workspace }}/BinaryCache/swift-lmdb
37393781

0 commit comments

Comments
 (0)