Skip to content

Commit b5f43a6

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 67b4b37 commit b5f43a6

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
@@ -975,25 +975,27 @@ jobs:
975975
key: ${{ steps.workspace_hash.outputs.hash }}-${{ matrix.os }}-${{ matrix.arch }}-compilers
976976
variant: sccache
977977

978-
- name: Configure Compilers
978+
- name: Setup context
979+
id: setup-context
979980
run: |
980981
$CxxFlags = "${{ matrix.cxxflags }}"
981982
$SwiftFlags = ""
982-
$EXTRA_FLAGS = @()
983+
$ExtraFlags = "${{ matrix.extra_flags }}"
983984
984985
if ( "${{ matrix.os }}" -eq "Windows" ) {
985986
$SWIFTC = cygpath -m (Get-Command swiftc).Source
986987
# Use toolchain clang to avoid broken __prefetch intrinsic on arm64 in Clang 18.
987988
# TODO: Use llvm-19 when available. See https://github.com/compnerd/swift-build/issues/846
988989
$CLANG_LOCATION = Split-Path (Get-Command swiftc).Source
989990
if ( "${{ matrix.arch }}" -eq "arm64" ) {
990-
$EXTRA_FLAGS += "${{ matrix.extra_flags }}".Split()
991-
$EXTRA_FLAGS += @("-D", "CMAKE_SYSTEM_NAME=Windows")
991+
$ExtraFlags += " -D CMAKE_SYSTEM_NAME=Windows"
992992
$CACHE="${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-aarch64.cmake"
993993
994994
# FIXME(compnerd) re-enable runtimes after we sort out compiler-rt
995995
(Get-Content ${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-aarch64.cmake).Replace(' runtimes', '') | Set-Content ${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-aarch64.cmake
996996
} else {
997+
# FIXME(steelskin) Setting `CMAKE_SYSTEM_NAME and `CMAKE_SYSTEM_PROCESSOR` breaks the compiler-rt build
998+
$ExtraFlags = ""
997999
$CACHE="${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-x86_64.cmake"
9981000
}
9991001
$CC = "cl"
@@ -1008,7 +1010,6 @@ jobs:
10081010
$LIBPYTHON_PATH = "${env:PYTHON_LOCATION_${{ matrix.arch }}}/libs/python39.lib"
10091011
$PYTHON_INCLUDE_DIR = "${env:PYTHON_LOCATION_${{ matrix.arch }}}/include"
10101012
$PYTHON_BINARY="python.exe"
1011-
$ExeSuffix = ".exe"
10121013
Remove-Item env:\SDKROOT
10131014
} elseif ( "${{ matrix.os }}" -eq "Darwin" ) {
10141015
# Default swiftc comes from /usr/bin and is not compatible with the toolchain.
@@ -1020,10 +1021,10 @@ jobs:
10201021
$CXX = Join-Path $CLANG_LOCATION "clang++"
10211022
$CACHE = "${{ github.workspace }}/SourceCache/swift/cmake/caches/Darwin-${{ matrix.arch }}.cmake"
10221023
$SDKROOT = xcrun --sdk macosx --show-sdk-path
1023-
$EXTRA_FLAGS += "${{ matrix.extra_flags }}".Split()
1024-
$EXTRA_FLAGS += @("-D", "CMAKE_SYSTEM_NAME=Darwin")
1024+
1025+
$ExtraFlags += " -D CMAKE_SYSTEM_NAME=Darwin"
10251026
# TODO: Use early-swift-driver on Windows too.
1026-
$EXTRA_FLAGS += @("-D", "SWIFT_EARLY_SWIFT_DRIVER_BUILD=${{ github.workspace }}/BinaryCache/swift-driver/bin")
1027+
$ExtraFlags += " -D SWIFT_EARLY_SWIFT_DRIVER_BUILD=${{ github.workspace }}/BinaryCache/swift-driver/bin"
10271028
$LIBPYTHON_PATH = "${env:pythonLocation}/lib/python3.9/config-3.9-darwin/libpython3.9.a"
10281029
$PYTHON_INCLUDE_DIR = "${env:pythonLocation}/include/python3.9"
10291030
$PYTHON_BINARY="python3"
@@ -1032,22 +1033,46 @@ jobs:
10321033
10331034
$SwiftFlags += " -sdk `"${SDKROOT}`""
10341035
1036+
Write-Output "cc=${CC}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1037+
Write-Output "cxx=${CXX}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1038+
Write-Output "swiftc=${SWIFTC}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1039+
Write-Output "cxxflags=${CxxFlags}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1040+
Write-Output "swiftflags=${SwiftFlags}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1041+
Write-Output "extra_flags=${ExtraFlags}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1042+
Write-Output "cache=${CACHE}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1043+
Write-Output "clang_location=${CLANG_LOCATION}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1044+
Write-Output "libpython_path=${LIBPYTHON_PATH}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1045+
Write-Output "python_include_dir=${PYTHON_INCLUDE_DIR}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1046+
Write-Output "python_binary=${PYTHON_BINARY}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1047+
Write-Output "sdkroot=${SDKROOT}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1048+
1049+
- name: Configure Compilers
1050+
env:
1051+
NDKPATH: ${{ steps.setup-ndk.outputs.ndk-path }}
1052+
run: |
1053+
if ( "${{ matrix.os }}" -eq "Windows" ) {
1054+
$ExeSuffix = ".exe"
1055+
Remove-Item env:\SDKROOT
1056+
} elseif ( "${{ matrix.os }}" -eq "Darwin" ) {
1057+
$ExeSuffix = ""
1058+
}
1059+
10351060
cmake -B ${{ github.workspace }}/BinaryCache/1 `
1036-
-C "${CACHE}" `
1061+
-C "${{ steps.setup-context.outputs.cache }}" `
10371062
-D CMAKE_BUILD_TYPE=Release `
1038-
-D CMAKE_C_COMPILER="${CC}" `
1063+
-D CMAKE_C_COMPILER="${{ steps.setup-context.outputs.cc }}" `
10391064
-D CMAKE_C_COMPILER_LAUNCHER=sccache `
10401065
-D CMAKE_C_FLAGS="${{ matrix.cflags }}" `
1041-
-D CMAKE_CXX_COMPILER="${CXX}" `
1066+
-D CMAKE_CXX_COMPILER="${{ steps.setup-context.outputs.cxx }}" `
10421067
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache `
1043-
-D CMAKE_CXX_FLAGS="${CxxFlags}" `
1044-
-D CMAKE_Swift_COMPILER="${SWIFTC}" `
1068+
-D CMAKE_CXX_FLAGS="${{ steps.setup-context.outputs.cxxflags }}" `
1069+
-D CMAKE_Swift_COMPILER="${{ steps.setup-context.outputs.swiftc }}" `
10451070
-D CMAKE_Swift_COMPILER_WORKS=YES `
1046-
-D CMAKE_Swift_FLAGS="${SwiftFlags}" `
1071+
-D CMAKE_Swift_FLAGS="${{ steps.setup-context.outputs.swiftflags }}" `
10471072
${{ matrix.cmake_linker_flags }} `
10481073
-D CMAKE_FIND_PACKAGE_PREFER_CONFIG=YES `
10491074
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr `
1050-
@EXTRA_FLAGS `
1075+
${{ steps.setup-context.outputs.extra_flags }} `
10511076
-G Ninja `
10521077
-S ${{ github.workspace }}/SourceCache/llvm-project/llvm `
10531078
-D CLANG_TABLEGEN="${{ github.workspace }}/BinaryCache/0/bin/clang-tblgen${ExeSuffix}" `
@@ -1062,7 +1087,7 @@ jobs:
10621087
-D SWIFT_BUILD_DYNAMIC_STDLIB=NO `
10631088
-D SWIFT_BUILD_REMOTE_MIRROR=NO `
10641089
-D SWIFT_BUILD_SWIFT_SYNTAX=YES `
1065-
-D SWIFT_CLANG_LOCATION=${CLANG_LOCATION} `
1090+
-D SWIFT_CLANG_LOCATION="${{ steps.setup-context.outputs.clang_location }}" `
10661091
-D SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY=YES `
10671092
-D SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP=YES `
10681093
-D SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED=YES `
@@ -1074,7 +1099,7 @@ jobs:
10741099
-D SWIFT_PATH_TO_LIBDISPATCH_SOURCE=${{ github.workspace }}/SourceCache/swift-corelibs-libdispatch `
10751100
-D SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE=${{ github.workspace }}/SourceCache/swift-syntax `
10761101
-D SWIFT_PATH_TO_STRING_PROCESSING_SOURCE=${{ github.workspace }}/SourceCache/swift-experimental-string-processing `
1077-
-D SWIFT_PATH_TO_SWIFT_SDK="${SDKROOT}" `
1102+
-D SWIFT_PATH_TO_SWIFT_SDK="${{ steps.setup-context.outputs.sdkroot }}" `
10781103
-D CLANG_VENDOR=compnerd.org `
10791104
-D CLANG_VENDOR_UTI=org.compnerd.dt `
10801105
-D cmark-gfm_DIR=${{ github.workspace }}/BinaryCache/Library/cmark-gfm-${{ inputs.swift_cmark_version }}/usr/lib/cmake `
@@ -1085,12 +1110,12 @@ jobs:
10851110
-D SWIFT_PARALLEL_LINK_JOBS=2 `
10861111
-D LLVM_APPEND_VC_REV=NO `
10871112
-D LLVM_VERSION_SUFFIX="" `
1088-
-D LLDB_PYTHON_EXE_RELATIVE_PATH=${PYTHON_BINARY} `
1113+
-D LLDB_PYTHON_EXE_RELATIVE_PATH=${{ steps.setup-context.outputs.python_binary }} `
10891114
-D LLDB_PYTHON_EXT_SUFFIX=.pyd `
10901115
-D LLDB_PYTHON_RELATIVE_PATH=lib/site-packages `
10911116
-D Python3_EXECUTABLE=${{ steps.python.outputs.python-path }} `
1092-
-D Python3_INCLUDE_DIR=$PYTHON_INCLUDE_DIR `
1093-
-D Python3_LIBRARY=$LIBPYTHON_PATH `
1117+
-D Python3_INCLUDE_DIR=${{ steps.setup-context.outputs.python_include_dir }} `
1118+
-D Python3_LIBRARY=${{ steps.setup-context.outputs.libpython_path }} `
10941119
-D Python3_ROOT_DIR=$env:pythonLocation
10951120
10961121
- name: Build Compiler Distribution

0 commit comments

Comments
 (0)