Skip to content

Commit cbbbf46

Browse files
committed
[compilers] Use a pre-configure setup step
* Add a preliminary step to export the context for the compiler configuration step. This makes it easier to debug the compiler configuration step by seeing the full command line invocation on the GHA page.
1 parent e172c02 commit cbbbf46

File tree

1 file changed

+45
-20
lines changed

1 file changed

+45
-20
lines changed

.github/workflows/swift-toolchain.yml

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -990,25 +990,27 @@ jobs:
990990
key: ${{ steps.workspace_hash.outputs.hash }}-${{ matrix.os }}-${{ matrix.arch }}-compilers
991991
variant: sccache
992992

993-
- name: Configure Compilers
993+
- name: Setup context
994+
id: setup-context
994995
run: |
995996
$CxxFlags = "${{ matrix.cxxflags }}"
996997
$SwiftFlags = ""
997-
$EXTRA_FLAGS = @()
998+
$ExtraFlags = "${{ matrix.extra_flags }}"
998999
9991000
if ( "${{ matrix.os }}" -eq "Windows" ) {
10001001
$SWIFTC = cygpath -m (Get-Command swiftc).Source
10011002
# Use toolchain clang to avoid broken __prefetch intrinsic on arm64 in Clang 18.
10021003
# TODO: Use llvm-19 when available. See https://github.com/compnerd/swift-build/issues/846
10031004
$CLANG_LOCATION = Split-Path (Get-Command swiftc).Source
10041005
if ( "${{ matrix.arch }}" -eq "arm64" ) {
1005-
$EXTRA_FLAGS += "${{ matrix.extra_flags }}".Split()
1006-
$EXTRA_FLAGS += @("-D", "CMAKE_SYSTEM_NAME=Windows")
1006+
$ExtraFlags += " -D CMAKE_SYSTEM_NAME=Windows"
10071007
$CACHE="${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-aarch64.cmake"
10081008
10091009
# FIXME(compnerd) re-enable runtimes after we sort out compiler-rt
10101010
(Get-Content ${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-aarch64.cmake).Replace(' runtimes', '') | Set-Content ${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-aarch64.cmake
10111011
} else {
1012+
# FIXME(steelskin) Setting `CMAKE_SYSTEM_NAME and `CMAKE_SYSTEM_PROCESSOR` breaks the compiler-rt build
1013+
$ExtraFlags = ""
10121014
$CACHE="${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-x86_64.cmake"
10131015
}
10141016
$CC = "cl"
@@ -1023,7 +1025,6 @@ jobs:
10231025
$LIBPYTHON_PATH = "${env:PYTHON_LOCATION_${{ matrix.arch }}}/libs/python39.lib"
10241026
$PYTHON_INCLUDE_DIR = "${env:PYTHON_LOCATION_${{ matrix.arch }}}/include"
10251027
$PYTHON_BINARY="python.exe"
1026-
$ExeSuffix = ".exe"
10271028
Remove-Item env:\SDKROOT
10281029
} elseif ( "${{ matrix.os }}" -eq "Darwin" ) {
10291030
# Default swiftc comes from /usr/bin and is not compatible with the toolchain.
@@ -1035,10 +1036,10 @@ jobs:
10351036
$CXX = Join-Path $CLANG_LOCATION "clang++"
10361037
$CACHE = "${{ github.workspace }}/SourceCache/swift/cmake/caches/Darwin-${{ matrix.arch }}.cmake"
10371038
$SDKROOT = xcrun --sdk macosx --show-sdk-path
1038-
$EXTRA_FLAGS += "${{ matrix.extra_flags }}".Split()
1039-
$EXTRA_FLAGS += @("-D", "CMAKE_SYSTEM_NAME=Darwin")
1039+
1040+
$ExtraFlags += " -D CMAKE_SYSTEM_NAME=Darwin"
10401041
# TODO: Use early-swift-driver on Windows too.
1041-
$EXTRA_FLAGS += @("-D", "SWIFT_EARLY_SWIFT_DRIVER_BUILD=${{ github.workspace }}/BinaryCache/swift-driver/bin")
1042+
$ExtraFlags += " -D SWIFT_EARLY_SWIFT_DRIVER_BUILD=${{ github.workspace }}/BinaryCache/swift-driver/bin"
10421043
$LIBPYTHON_PATH = "${env:pythonLocation}/lib/python3.9/config-3.9-darwin/libpython3.9.a"
10431044
$PYTHON_INCLUDE_DIR = "${env:pythonLocation}/include/python3.9"
10441045
$PYTHON_BINARY="python3"
@@ -1047,22 +1048,46 @@ jobs:
10471048
10481049
$SwiftFlags += " -sdk `"${SDKROOT}`""
10491050
1051+
Write-Output "cc=${CC}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1052+
Write-Output "cxx=${CXX}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1053+
Write-Output "swiftc=${SWIFTC}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1054+
Write-Output "cxxflags=${CxxFlags}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1055+
Write-Output "swiftflags=${SwiftFlags}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1056+
Write-Output "extra_flags=${ExtraFlags}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1057+
Write-Output "cache=${CACHE}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1058+
Write-Output "clang_location=${CLANG_LOCATION}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1059+
Write-Output "libpython_path=${LIBPYTHON_PATH}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1060+
Write-Output "python_include_dir=${PYTHON_INCLUDE_DIR}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1061+
Write-Output "python_binary=${PYTHON_BINARY}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1062+
Write-Output "sdkroot=${SDKROOT}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1063+
1064+
- name: Configure Compilers
1065+
env:
1066+
NDKPATH: ${{ steps.setup-ndk.outputs.ndk-path }}
1067+
run: |
1068+
if ( "${{ matrix.os }}" -eq "Windows" ) {
1069+
$ExeSuffix = ".exe"
1070+
Remove-Item env:\SDKROOT
1071+
} elseif ( "${{ matrix.os }}" -eq "Darwin" ) {
1072+
$ExeSuffix = ""
1073+
}
1074+
10501075
cmake -B ${{ github.workspace }}/BinaryCache/1 `
1051-
-C "${CACHE}" `
1076+
-C "${{ steps.setup-context.outputs.cache }}" `
10521077
-D CMAKE_BUILD_TYPE=Release `
1053-
-D CMAKE_C_COMPILER="${CC}" `
1078+
-D CMAKE_C_COMPILER="${{ steps.setup-context.outputs.cc }}" `
10541079
-D CMAKE_C_COMPILER_LAUNCHER=sccache `
10551080
-D CMAKE_C_FLAGS="${{ matrix.cflags }}" `
1056-
-D CMAKE_CXX_COMPILER="${CXX}" `
1081+
-D CMAKE_CXX_COMPILER="${{ steps.setup-context.outputs.cxx }}" `
10571082
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache `
1058-
-D CMAKE_CXX_FLAGS="${CxxFlags}" `
1059-
-D CMAKE_Swift_COMPILER="${SWIFTC}" `
1083+
-D CMAKE_CXX_FLAGS="${{ steps.setup-context.outputs.cxxflags }}" `
1084+
-D CMAKE_Swift_COMPILER="${{ steps.setup-context.outputs.swiftc }}" `
10601085
-D CMAKE_Swift_COMPILER_WORKS=YES `
1061-
-D CMAKE_Swift_FLAGS="${SwiftFlags}" `
1086+
-D CMAKE_Swift_FLAGS="${{ steps.setup-context.outputs.swiftflags }}" `
10621087
${{ matrix.cmake_linker_flags }} `
10631088
-D CMAKE_FIND_PACKAGE_PREFER_CONFIG=YES `
10641089
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr `
1065-
@EXTRA_FLAGS `
1090+
${{ steps.setup-context.outputs.extra_flags }} `
10661091
-G Ninja `
10671092
-S ${{ github.workspace }}/SourceCache/llvm-project/llvm `
10681093
-D CLANG_TABLEGEN="${{ github.workspace }}/BinaryCache/0/bin/clang-tblgen${ExeSuffix}" `
@@ -1077,7 +1102,7 @@ jobs:
10771102
-D SWIFT_BUILD_DYNAMIC_STDLIB=NO `
10781103
-D SWIFT_BUILD_REMOTE_MIRROR=NO `
10791104
-D SWIFT_BUILD_SWIFT_SYNTAX=YES `
1080-
-D SWIFT_CLANG_LOCATION=${CLANG_LOCATION} `
1105+
-D SWIFT_CLANG_LOCATION="${{ steps.setup-context.outputs.clang_location }}" `
10811106
-D SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY=YES `
10821107
-D SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP=YES `
10831108
-D SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED=YES `
@@ -1089,7 +1114,7 @@ jobs:
10891114
-D SWIFT_PATH_TO_LIBDISPATCH_SOURCE=${{ github.workspace }}/SourceCache/swift-corelibs-libdispatch `
10901115
-D SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE=${{ github.workspace }}/SourceCache/swift-syntax `
10911116
-D SWIFT_PATH_TO_STRING_PROCESSING_SOURCE=${{ github.workspace }}/SourceCache/swift-experimental-string-processing `
1092-
-D SWIFT_PATH_TO_SWIFT_SDK="${SDKROOT}" `
1117+
-D SWIFT_PATH_TO_SWIFT_SDK="${{ steps.setup-context.outputs.sdkroot }}" `
10931118
-D CLANG_VENDOR=compnerd.org `
10941119
-D CLANG_VENDOR_UTI=org.compnerd.dt `
10951120
-D cmark-gfm_DIR=${{ github.workspace }}/BinaryCache/Library/cmark-gfm-${{ inputs.swift_cmark_version }}/usr/lib/cmake `
@@ -1100,12 +1125,12 @@ jobs:
11001125
-D SWIFT_PARALLEL_LINK_JOBS=2 `
11011126
-D LLVM_APPEND_VC_REV=NO `
11021127
-D LLVM_VERSION_SUFFIX="" `
1103-
-D LLDB_PYTHON_EXE_RELATIVE_PATH=${PYTHON_BINARY} `
1128+
-D LLDB_PYTHON_EXE_RELATIVE_PATH=${{ steps.setup-context.outputs.python_binary }} `
11041129
-D LLDB_PYTHON_EXT_SUFFIX=.pyd `
11051130
-D LLDB_PYTHON_RELATIVE_PATH=lib/site-packages `
11061131
-D Python3_EXECUTABLE=${{ steps.python.outputs.python-path }} `
1107-
-D Python3_INCLUDE_DIR=$PYTHON_INCLUDE_DIR `
1108-
-D Python3_LIBRARY=$LIBPYTHON_PATH `
1132+
-D Python3_INCLUDE_DIR=${{ steps.setup-context.outputs.python_include_dir }} `
1133+
-D Python3_LIBRARY=${{ steps.setup-context.outputs.libpython_path }} `
11091134
-D Python3_ROOT_DIR=$env:pythonLocation
11101135
11111136
- name: Build Compiler Distribution

0 commit comments

Comments
 (0)