Skip to content

Commit 0806ec8

Browse files
compnerdhjyamauchi
andauthored
GHA: simplify the compiler context (#896)
With the removal of the runtimes build in unified build, we are able to universally inline some of the computation of the flags. Other options are no longer required to be evaluated at build time. Re-order some of the options to similarly order the macOS and Windows builds. Co-authored-by: Hiroshi Yamauchi <[email protected]>
1 parent db9ed8f commit 0806ec8

File tree

1 file changed

+10
-23
lines changed

1 file changed

+10
-23
lines changed

.github/workflows/swift-toolchain.yml

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -992,52 +992,39 @@ jobs:
992992
$ExtraFlags = "${{ matrix.extra_flags }}"
993993
994994
if ( "${{ matrix.os }}" -eq "Windows" ) {
995-
$SWIFTC = cygpath -m (Get-Command swiftc).Source
996995
# Use toolchain clang to avoid broken __prefetch intrinsic on arm64 in Clang 18.
997996
# TODO: Use llvm-19 when available. See https://github.com/compnerd/swift-build/issues/846
998-
$CLANG_LOCATION = Split-Path (Get-Command swiftc).Source
999-
if ( "${{ matrix.arch }}" -eq "arm64" ) {
1000-
$ExtraFlags += " -D CMAKE_SYSTEM_NAME=Windows"
1001-
$CACHE="${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-aarch64.cmake"
997+
$CLANG_LOCATION = cygpath -m $(Split-Path (Get-Command swiftc).Source)
998+
$SWIFTC = cygpath -m (Get-Command swiftc).Source
1002999
1003-
# FIXME(compnerd) re-enable runtimes after we sort out compiler-rt
1004-
(Get-Content ${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-aarch64.cmake).Replace(' runtimes', '') | Set-Content ${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-aarch64.cmake
1005-
} else {
1006-
# FIXME(steelskin) Setting `CMAKE_SYSTEM_NAME and `CMAKE_SYSTEM_PROCESSOR` breaks the compiler-rt build
1007-
$ExtraFlags = ""
1008-
$CACHE="${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-x86_64.cmake"
1009-
}
1010-
$CC = "cl"
1011-
$CXX = "cl"
1000+
$CC = "${{ matrix.cc }}"
1001+
$CXX = "${{ matrix.cxx }}"
1002+
$SDKROOT = cygpath -m ${env:SDKROOT}
10121003
10131004
# Workaround for compiler and STL version mismatch on Windows.
10141005
$CxxFlags += " -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH"
10151006
$SwiftFlags += " -Xcc -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH"
10161007
1017-
$SDKROOT = cygpath -m ${env:SDKROOT}
1018-
$CLANG_LOCATION = cygpath -m $CLANG_LOCATION
10191008
$LIBPYTHON_PATH = "${env:PYTHON_LOCATION_${{ matrix.arch }}}/libs/python39.lib"
10201009
$PYTHON_INCLUDE_DIR = "${env:PYTHON_LOCATION_${{ matrix.arch }}}/include"
10211010
$PYTHON_BINARY="python.exe"
1011+
10221012
Remove-Item env:\SDKROOT
10231013
} elseif ( "${{ matrix.os }}" -eq "Darwin" ) {
10241014
# Default swiftc comes from /usr/bin and is not compatible with the toolchain.
10251015
$CLANG_LOCATION = "${env:HOME}/Library/Developer/Toolchains/swift-${{ env.WORKAROUND_MACOS_PINNED_BOOTSTRAP_TOOLCHAIN_TAG }}.xctoolchain/usr/bin"
10261016
$SWIFTC = Join-Path $CLANG_LOCATION "swiftc"
10271017
10281018
# We need to use llvm-17 to build the compiler on macOS. We get it from the Swift toolchain.
1029-
$CC = Join-Path $CLANG_LOCATION "clang"
1030-
$CXX = Join-Path $CLANG_LOCATION "clang++"
1031-
$CACHE = "${{ github.workspace }}/SourceCache/swift/cmake/caches/Darwin-${{ matrix.arch }}.cmake"
1019+
$CC = Join-Path $CLANG_LOCATION ${{ matrix.cc }}
1020+
$CXX = Join-Path $CLANG_LOCATION ${{ matrix.cxx }}
10321021
$SDKROOT = xcrun --sdk macosx --show-sdk-path
10331022
1034-
$ExtraFlags += " -D CMAKE_SYSTEM_NAME=Darwin"
10351023
# TODO: Use early-swift-driver on Windows too.
10361024
$ExtraFlags += " -D SWIFT_EARLY_SWIFT_DRIVER_BUILD=${{ github.workspace }}/BinaryCache/swift-driver/bin"
10371025
$LIBPYTHON_PATH = "${env:pythonLocation}/lib/python3.9/config-3.9-darwin/libpython3.9.a"
10381026
$PYTHON_INCLUDE_DIR = "${env:pythonLocation}/include/python3.9"
10391027
$PYTHON_BINARY="python3"
1040-
$ExeSuffix = ""
10411028
}
10421029
10431030
$SwiftFlags += " -sdk `"${SDKROOT}`""
@@ -1050,7 +1037,6 @@ jobs:
10501037
cxxflags=${CxxFlags}
10511038
swiftflags=${SwiftFlags}
10521039
extra_flags=${ExtraFlags}
1053-
cache=${CACHE}
10541040
clang_location=${CLANG_LOCATION}
10551041
libpython_path=${LIBPYTHON_PATH}
10561042
python_include_dir=${PYTHON_INCLUDE_DIR}
@@ -1071,7 +1057,7 @@ jobs:
10711057
}
10721058
10731059
cmake -B ${{ github.workspace }}/BinaryCache/1 `
1074-
-C "${{ steps.setup-context.outputs.cache }}" `
1060+
-C "${{ github.workspace }}/SourceCache/swift/cmake/caches/${{ matrix.os }}-${{ matrix.cpu }}.cmake" `
10751061
-D CMAKE_BUILD_TYPE=Release `
10761062
-D CMAKE_C_COMPILER="${{ steps.setup-context.outputs.cc }}" `
10771063
-D CMAKE_C_COMPILER_LAUNCHER=sccache `
@@ -1086,6 +1072,7 @@ jobs:
10861072
-D CMAKE_STATIC_LIBRARY_PREFIX_Swift= `
10871073
-D CMAKE_FIND_PACKAGE_PREFER_CONFIG=YES `
10881074
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr `
1075+
-D CMAKE_SYSTEM_NAME=${{ matrix.os }} `
10891076
${{ steps.setup-context.outputs.extra_flags }} `
10901077
-G Ninja `
10911078
-S ${{ github.workspace }}/SourceCache/llvm-project/llvm `

0 commit comments

Comments
 (0)