Skip to content

Commit 824eea7

Browse files
committed
Use a pre-configure setup task
* 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 6213359 commit 824eea7

File tree

1 file changed

+44
-21
lines changed

1 file changed

+44
-21
lines changed

.github/workflows/swift-toolchain.yml

+44-21
Original file line numberDiff line numberDiff line change
@@ -978,27 +978,28 @@ jobs:
978978
key: ${{ steps.workspace_hash.outputs.hash }}-${{ matrix.os }}-${{ matrix.arch }}-compilers
979979
variant: sccache
980980

981-
- name: Configure Compilers
981+
- name: Setup context
982+
id: setup-context
982983
run: |
983984
$CxxFlags = "${{ matrix.cxxflags }}"
984985
$SwiftFlags = ""
985-
$EXTRA_FLAGS = @()
986986
987+
$ExtraFlags = "${{ matrix.extra_flags }}"
987988
if ( "${{ matrix.os }}" -eq "Windows" ) {
988989
$SWIFTC = cygpath -m (Get-Command swiftc).Source
989990
# Use toolchain clang to avoid broken __prefetch intrinsic on arm64 in Clang 18.
990991
# TODO: Use llvm-19 when available. See https://github.com/compnerd/swift-build/issues/846
991992
$CLANG_LOCATION = Split-Path (Get-Command swiftc).Source
992993
if ( "${{ matrix.arch }}" -eq "arm64" ) {
993-
$EXTRA_FLAGS += "${{ matrix.extra_flags }}".Split()
994-
$EXTRA_FLAGS += @("-D", "CMAKE_SYSTEM_NAME=Windows")
994+
$ExtraFlags += " ${{ matrix.extra_flags }}"
995+
$ExtraFlags += " -D CMAKE_SYSTEM_NAME=Windows"
995996
$CACHE="${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-aarch64.cmake"
996997
997998
# FIXME(compnerd) re-enable runtimes after we sort out compiler-rt
998999
(Get-Content ${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-aarch64.cmake).Replace(' runtimes', '') | Set-Content ${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-aarch64.cmake
9991000
} else {
10001001
# FIXME(steelskin) Setting `CMAKE_SYSTEM_PROCESSOR` and `CMAKE_SYSTEM_NAME` breaks the compiler-rt build.
1001-
$EXTRA_FLAGS += @("-D", "CMAKE_MT=mt")
1002+
$ExtraFlags += "-D CMAKE_MT=mt"
10021003
$CACHE="${{ github.workspace }}/SourceCache/swift/cmake/caches/Windows-x86_64.cmake"
10031004
}
10041005
$CC = "cl"
@@ -1013,7 +1014,6 @@ jobs:
10131014
$LIBPYTHON_PATH = "${env:PYTHON_LOCATION_${{ matrix.arch }}}/libs/python39.lib"
10141015
$PYTHON_INCLUDE_DIR = "${env:PYTHON_LOCATION_${{ matrix.arch }}}/include"
10151016
$PYTHON_BINARY="python.exe"
1016-
$ExeSuffix = ".exe"
10171017
Remove-Item env:\SDKROOT
10181018
} elseif ( "${{ matrix.os }}" -eq "Darwin" ) {
10191019
# Default swiftc comes from /usr/bin and is not compatible with the toolchain.
@@ -1025,10 +1025,11 @@ jobs:
10251025
$CXX = Join-Path $CLANG_LOCATION "clang++"
10261026
$CACHE = "${{ github.workspace }}/SourceCache/swift/cmake/caches/Darwin-${{ matrix.arch }}.cmake"
10271027
$SDKROOT = xcrun --sdk macosx --show-sdk-path
1028-
$EXTRA_FLAGS += "${{ matrix.extra_flags }}".Split()
1029-
$EXTRA_FLAGS += @("-D", "CMAKE_SYSTEM_NAME=Darwin")
1028+
1029+
$ExtraFlags += "${{ matrix.extra_flags }}"
1030+
$ExtraFlags += " -D CMAKE_SYSTEM_NAME=Darwin"
10301031
# TODO: Use early-swift-driver on Windows too.
1031-
$EXTRA_FLAGS += @("-D", "SWIFT_EARLY_SWIFT_DRIVER_BUILD=${{ github.workspace }}/BinaryCache/swift-driver/bin")
1032+
$ExtraFlags += " -D SWIFT_EARLY_SWIFT_DRIVER_BUILD=${{ github.workspace }}/BinaryCache/swift-driver/bin"
10321033
$LIBPYTHON_PATH = "${env:pythonLocation}/lib/python3.9/config-3.9-darwin/libpython3.9.a"
10331034
$PYTHON_INCLUDE_DIR = "${env:pythonLocation}/include/python3.9"
10341035
$PYTHON_BINARY="python3"
@@ -1037,22 +1038,44 @@ jobs:
10371038
10381039
$SwiftFlags += " -sdk `"${SDKROOT}`""
10391040
1041+
Write-Output "cc=${CC}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1042+
Write-Output "cxx=${CXX}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1043+
Write-Output "swiftc=${SWIFTC}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1044+
Write-Output "cxxflags=${CxxFlags}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1045+
Write-Output "swiftflags=${SwiftFlags}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1046+
Write-Output "extra_flags=${ExtraFlags}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1047+
Write-Output "cache=${CACHE}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1048+
Write-Output "clang_location=${CLANG_LOCATION}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1049+
Write-Output "libpython_path=${LIBPYTHON_PATH}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1050+
Write-Output "python_include_dir=${PYTHON_INCLUDE_DIR}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1051+
Write-Output "python_binary=${PYTHON_BINARY}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
1052+
1053+
- name: Configure Compilers
1054+
env:
1055+
NDKPATH: ${{ steps.setup-ndk.outputs.ndk-path }}
1056+
run: |
1057+
if ( "${{ matrix.os }}" -eq "Windows" ) {
1058+
$ExeSuffix = ".exe"
1059+
Remove-Item env:\SDKROOT
1060+
} elseif ( "${{ matrix.os }}" -eq "Darwin" ) {
1061+
$ExeSuffix = ""
1062+
}
1063+
10401064
cmake -B ${{ github.workspace }}/BinaryCache/1 `
1041-
-C "${CACHE}" `
1065+
-C "${{ steps.setup-context.outputs.cache }}" `
10421066
-D CMAKE_BUILD_TYPE=Release `
1043-
-D CMAKE_C_COMPILER="${CC}" `
1067+
-D CMAKE_C_COMPILER="${{ steps.setup-context.outputs.cc }}" `
10441068
-D CMAKE_C_COMPILER_LAUNCHER=sccache `
10451069
-D CMAKE_C_FLAGS="${{ matrix.cflags }}" `
1046-
-D CMAKE_CXX_COMPILER="${CXX}" `
1070+
-D CMAKE_CXX_COMPILER="${{ steps.setup-context.outputs.cxx }}" `
10471071
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache `
1048-
-D CMAKE_CXX_FLAGS="${CxxFlags}" `
1049-
-D CMAKE_Swift_COMPILER="${SWIFTC}" `
1072+
-D CMAKE_CXX_FLAGS="${{ steps.setup-context.outputs.cxxflags }}" `
1073+
-D CMAKE_Swift_COMPILER="${{ steps.setup-context.outputs.swiftc }}" `
10501074
-D CMAKE_Swift_COMPILER_WORKS=YES `
1051-
-D CMAKE_Swift_FLAGS="${SwiftFlags}" `
1075+
-D CMAKE_Swift_FLAGS="${{ steps.setup-context.outputs.swiftlags }}" `
10521076
${{ matrix.cmake_linker_flags }} `
1053-
-D CMAKE_FIND_PACKAGE_PREFER_CONFIG=YES `
10541077
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr `
1055-
@EXTRA_FLAGS `
1078+
${{ steps.setup-context.outputs.extra_flags }} `
10561079
-G Ninja `
10571080
-S ${{ github.workspace }}/SourceCache/llvm-project/llvm `
10581081
-D CLANG_TABLEGEN="${{ github.workspace }}/BinaryCache/0/bin/clang-tblgen${ExeSuffix}" `
@@ -1079,7 +1102,7 @@ jobs:
10791102
-D SWIFT_PATH_TO_LIBDISPATCH_SOURCE=${{ github.workspace }}/SourceCache/swift-corelibs-libdispatch `
10801103
-D SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE=${{ github.workspace }}/SourceCache/swift-syntax `
10811104
-D SWIFT_PATH_TO_STRING_PROCESSING_SOURCE=${{ github.workspace }}/SourceCache/swift-experimental-string-processing `
1082-
-D SWIFT_PATH_TO_SWIFT_SDK="${SDKROOT}" `
1105+
-D SWIFT_PATH_TO_SWIFT_SDK="${{ steps.setup-context.outputs.sdkroot }}" `
10831106
-D CLANG_VENDOR=compnerd.org `
10841107
-D CLANG_VENDOR_UTI=org.compnerd.dt `
10851108
-D cmark-gfm_DIR=${{ github.workspace }}/BinaryCache/Library/cmark-gfm-${{ inputs.swift_cmark_version }}/usr/lib/cmake `
@@ -1090,12 +1113,12 @@ jobs:
10901113
-D SWIFT_PARALLEL_LINK_JOBS=2 `
10911114
-D LLVM_APPEND_VC_REV=NO `
10921115
-D LLVM_VERSION_SUFFIX="" `
1093-
-D LLDB_PYTHON_EXE_RELATIVE_PATH=${PYTHON_BINARY} `
1116+
-D LLDB_PYTHON_EXE_RELATIVE_PATH=${{ steps.setup-context.outputs.python_binary }} `
10941117
-D LLDB_PYTHON_EXT_SUFFIX=.pyd `
10951118
-D LLDB_PYTHON_RELATIVE_PATH=lib/site-packages `
10961119
-D Python3_EXECUTABLE=${{ steps.python.outputs.python-path }} `
1097-
-D Python3_INCLUDE_DIR=$PYTHON_INCLUDE_DIR `
1098-
-D Python3_LIBRARY=$LIBPYTHON_PATH `
1120+
-D Python3_INCLUDE_DIR=${{ steps.setup-context.outputs.python_include_dir }} `
1121+
-D Python3_LIBRARY=${{ steps.setup-context.outputs.libpython_path }} `
10991122
-D Python3_ROOT_DIR=$env:pythonLocation
11001123
11011124
- name: Build Compiler Distribution

0 commit comments

Comments
 (0)