Skip to content

Commit 4d4d026

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 936db4e commit 4d4d026

File tree

1 file changed

+45
-20
lines changed

1 file changed

+45
-20
lines changed

.github/workflows/swift-toolchain.yml

+45-20
Original file line numberDiff line numberDiff line change
@@ -976,25 +976,27 @@ jobs:
976976
key: ${{ steps.workspace_hash.outputs.hash }}-${{ matrix.os }}-${{ matrix.arch }}-compilers
977977
variant: sccache
978978

979-
- name: Configure Compilers
979+
- name: Setup context
980+
id: setup-context
980981
run: |
981982
$CxxFlags = "${{ matrix.cxxflags }}"
982983
$SwiftFlags = ""
983-
$EXTRA_FLAGS = @()
984+
$ExtraFlags = "${{ matrix.extra_flags }}"
984985
985986
if ( "${{ matrix.os }}" -eq "Windows" ) {
986987
$SWIFTC = cygpath -m (Get-Command swiftc).Source
987988
# Use toolchain clang to avoid broken __prefetch intrinsic on arm64 in Clang 18.
988989
# TODO: Use llvm-19 when available. See https://github.com/compnerd/swift-build/issues/846
989990
$CLANG_LOCATION = Split-Path (Get-Command swiftc).Source
990991
if ( "${{ matrix.arch }}" -eq "arm64" ) {
991-
$EXTRA_FLAGS += "${{ matrix.extra_flags }}".Split()
992-
$EXTRA_FLAGS += @("-D", "CMAKE_SYSTEM_NAME=Windows")
992+
$ExtraFlags += " -D CMAKE_SYSTEM_NAME=Windows"
993993
$CACHE="${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-aarch64.cmake"
994994
995995
# FIXME(compnerd) re-enable runtimes after we sort out compiler-rt
996996
(Get-Content ${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-aarch64.cmake).Replace(' runtimes', '') | Set-Content ${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-aarch64.cmake
997997
} else {
998+
# FIXME(steelskin) Setting `CMAKE_SYSTEM_NAME and `CMAKE_SYSTEM_PROCESSOR` breaks the compiler-rt build
999+
$ExtraFlags = ""
9981000
$CACHE="${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-x86_64.cmake"
9991001
}
10001002
$CC = "cl"
@@ -1009,7 +1011,6 @@ jobs:
10091011
$LIBPYTHON_PATH = "${env:PYTHON_LOCATION_${{ matrix.arch }}}/libs/python39.lib"
10101012
$PYTHON_INCLUDE_DIR = "${env:PYTHON_LOCATION_${{ matrix.arch }}}/include"
10111013
$PYTHON_BINARY="python.exe"
1012-
$ExeSuffix = ".exe"
10131014
Remove-Item env:\SDKROOT
10141015
} elseif ( "${{ matrix.os }}" -eq "Darwin" ) {
10151016
# Default swiftc comes from /usr/bin and is not compatible with the toolchain.
@@ -1021,10 +1022,10 @@ jobs:
10211022
$CXX = Join-Path $CLANG_LOCATION "clang++"
10221023
$CACHE = "${{ github.workspace }}/SourceCache/swift/cmake/caches/Darwin-${{ matrix.arch }}.cmake"
10231024
$SDKROOT = xcrun --sdk macosx --show-sdk-path
1024-
$EXTRA_FLAGS += "${{ matrix.extra_flags }}".Split()
1025-
$EXTRA_FLAGS += @("-D", "CMAKE_SYSTEM_NAME=Darwin")
1025+
1026+
$ExtraFlags += " -D CMAKE_SYSTEM_NAME=Darwin"
10261027
# TODO: Use early-swift-driver on Windows too.
1027-
$EXTRA_FLAGS += @("-D", "SWIFT_EARLY_SWIFT_DRIVER_BUILD=${{ github.workspace }}/BinaryCache/swift-driver/bin")
1028+
$ExtraFlags += " -D SWIFT_EARLY_SWIFT_DRIVER_BUILD=${{ github.workspace }}/BinaryCache/swift-driver/bin"
10281029
$LIBPYTHON_PATH = "${env:pythonLocation}/lib/python3.9/config-3.9-darwin/libpython3.9.a"
10291030
$PYTHON_INCLUDE_DIR = "${env:pythonLocation}/include/python3.9"
10301031
$PYTHON_BINARY="python3"
@@ -1033,22 +1034,46 @@ jobs:
10331034
10341035
$SwiftFlags += " -sdk `"${SDKROOT}`""
10351036
1037+
Write-Output "cc=${CC}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1038+
Write-Output "cxx=${CXX}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1039+
Write-Output "swiftc=${SWIFTC}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1040+
Write-Output "cxxflags=${CxxFlags}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1041+
Write-Output "swiftflags=${SwiftFlags}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1042+
Write-Output "extra_flags=${ExtraFlags}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1043+
Write-Output "cache=${CACHE}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1044+
Write-Output "clang_location=${CLANG_LOCATION}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1045+
Write-Output "libpython_path=${LIBPYTHON_PATH}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1046+
Write-Output "python_include_dir=${PYTHON_INCLUDE_DIR}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1047+
Write-Output "python_binary=${PYTHON_BINARY}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1048+
Write-Output "sdkroot=${SDKROOT}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1049+
1050+
- name: Configure Compilers
1051+
env:
1052+
NDKPATH: ${{ steps.setup-ndk.outputs.ndk-path }}
1053+
run: |
1054+
if ( "${{ matrix.os }}" -eq "Windows" ) {
1055+
$ExeSuffix = ".exe"
1056+
Remove-Item env:\SDKROOT
1057+
} elseif ( "${{ matrix.os }}" -eq "Darwin" ) {
1058+
$ExeSuffix = ""
1059+
}
1060+
10361061
cmake -B ${{ github.workspace }}/BinaryCache/1 `
1037-
-C "${CACHE}" `
1062+
-C "${{ steps.setup-context.outputs.cache }}" `
10381063
-D CMAKE_BUILD_TYPE=Release `
1039-
-D CMAKE_C_COMPILER="${CC}" `
1064+
-D CMAKE_C_COMPILER="${{ steps.setup-context.outputs.cc }}" `
10401065
-D CMAKE_C_COMPILER_LAUNCHER=sccache `
10411066
-D CMAKE_C_FLAGS="${{ matrix.cflags }}" `
1042-
-D CMAKE_CXX_COMPILER="${CXX}" `
1067+
-D CMAKE_CXX_COMPILER="${{ steps.setup-context.outputs.cxx }}" `
10431068
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache `
1044-
-D CMAKE_CXX_FLAGS="${CxxFlags}" `
1045-
-D CMAKE_Swift_COMPILER="${SWIFTC}" `
1069+
-D CMAKE_CXX_FLAGS="${{ steps.setup-context.outputs.cxxflags }}" `
1070+
-D CMAKE_Swift_COMPILER="${{ steps.setup-context.outputs.swiftc }}" `
10461071
-D CMAKE_Swift_COMPILER_WORKS=YES `
1047-
-D CMAKE_Swift_FLAGS="${SwiftFlags}" `
1072+
-D CMAKE_Swift_FLAGS="${{ steps.setup-context.outputs.swiftlags }}" `
10481073
${{ matrix.cmake_linker_flags }} `
10491074
-D CMAKE_FIND_PACKAGE_PREFER_CONFIG=YES `
10501075
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr `
1051-
@EXTRA_FLAGS `
1076+
${{ steps.setup-context.outputs.extra_flags }} `
10521077
-G Ninja `
10531078
-S ${{ github.workspace }}/SourceCache/llvm-project/llvm `
10541079
-D CLANG_TABLEGEN="${{ github.workspace }}/BinaryCache/0/bin/clang-tblgen${ExeSuffix}" `
@@ -1063,7 +1088,7 @@ jobs:
10631088
-D SWIFT_BUILD_DYNAMIC_STDLIB=NO `
10641089
-D SWIFT_BUILD_REMOTE_MIRROR=NO `
10651090
-D SWIFT_BUILD_SWIFT_SYNTAX=YES `
1066-
-D SWIFT_CLANG_LOCATION=${CLANG_LOCATION} `
1091+
-D SWIFT_CLANG_LOCATION="${{ steps.setup-context.outputs.clang_location }}" `
10671092
-D SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY=YES `
10681093
-D SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP=YES `
10691094
-D SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED=YES `
@@ -1075,7 +1100,7 @@ jobs:
10751100
-D SWIFT_PATH_TO_LIBDISPATCH_SOURCE=${{ github.workspace }}/SourceCache/swift-corelibs-libdispatch `
10761101
-D SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE=${{ github.workspace }}/SourceCache/swift-syntax `
10771102
-D SWIFT_PATH_TO_STRING_PROCESSING_SOURCE=${{ github.workspace }}/SourceCache/swift-experimental-string-processing `
1078-
-D SWIFT_PATH_TO_SWIFT_SDK="${SDKROOT}" `
1103+
-D SWIFT_PATH_TO_SWIFT_SDK="${{ steps.setup-context.outputs.sdkroot }}" `
10791104
-D CLANG_VENDOR=compnerd.org `
10801105
-D CLANG_VENDOR_UTI=org.compnerd.dt `
10811106
-D cmark-gfm_DIR=${{ github.workspace }}/BinaryCache/Library/cmark-gfm-${{ inputs.swift_cmark_version }}/usr/lib/cmake `
@@ -1086,12 +1111,12 @@ jobs:
10861111
-D SWIFT_PARALLEL_LINK_JOBS=2 `
10871112
-D LLVM_APPEND_VC_REV=NO `
10881113
-D LLVM_VERSION_SUFFIX="" `
1089-
-D LLDB_PYTHON_EXE_RELATIVE_PATH=${PYTHON_BINARY} `
1114+
-D LLDB_PYTHON_EXE_RELATIVE_PATH=${{ steps.setup-context.outputs.python_binary }} `
10901115
-D LLDB_PYTHON_EXT_SUFFIX=.pyd `
10911116
-D LLDB_PYTHON_RELATIVE_PATH=lib/site-packages `
10921117
-D Python3_EXECUTABLE=${{ steps.python.outputs.python-path }} `
1093-
-D Python3_INCLUDE_DIR=$PYTHON_INCLUDE_DIR `
1094-
-D Python3_LIBRARY=$LIBPYTHON_PATH `
1118+
-D Python3_INCLUDE_DIR=${{ steps.setup-context.outputs.python_include_dir }} `
1119+
-D Python3_LIBRARY=${{ steps.setup-context.outputs.libpython_path }} `
10951120
-D Python3_ROOT_DIR=$env:pythonLocation
10961121
10971122
- name: Build Compiler Distribution

0 commit comments

Comments
 (0)