Skip to content

Commit 87c478f

Browse files
committed
GHA: build sanitizers for distribution
The unified build was split, separating the runtimes from the compilers build to be more effective about cross-compilation. Wire up the new sanitizers build in the GHA build to allow packaging into the toolchain.
1 parent a511f46 commit 87c478f

File tree

1 file changed

+89
-1
lines changed

1 file changed

+89
-1
lines changed

.github/workflows/swift-toolchain.yml

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,93 @@ jobs:
12261226
symbolsFolder: ${{ github.workspace }}/BinaryCache/1
12271227
searchPattern: '**/*.exe'
12281228

1229+
sanitizers:
1230+
# TODO: Build this on macOS or make an equivalent Mac-only job
1231+
if: inputs.build_os == 'Windows'
1232+
runs-on: ${{ inputs.default_build_runner }}
1233+
needs: [compilers]
1234+
1235+
strategy:
1236+
fail-fast: false
1237+
matrix: ${{ fromJSON(inputs.target_matrix) }}
1238+
1239+
name: ${{ matrix.os }} ${{ matrix.arch }} Sanitizers
1240+
1241+
steps:
1242+
- name: Download Compilers
1243+
uses: thebrowsercompany/gha-download-tar-artifact@59992d91335d4ecba543c8535f7d07238e42125d # main
1244+
with:
1245+
name: compilers-Windows-${{ inputs.build_arch }}
1246+
path: ${{ github.workspace }}/BinaryCache/Library
1247+
1248+
- uses: actions/checkout@v4
1249+
with:
1250+
repository: swiftlang/llvm-project
1251+
ref: ${{ inputs.llvm_project_revision }}
1252+
path: ${{ github.workspace }}/SourceCache/llvm-project
1253+
show-progress: false
1254+
1255+
- uses: nttld/setup-ndk@v1
1256+
if: matrix.os == 'Android' && inputs.build_android
1257+
id: setup-ndk
1258+
with:
1259+
ndk-version: ${{ inputs.ANDROID_NDK_VERSION }}
1260+
1261+
- name: Compute workspace hash
1262+
id: workspace_hash
1263+
shell: pwsh
1264+
run: |
1265+
$stringAsStream = [System.IO.MemoryStream]::new()
1266+
$writer = [System.IO.StreamWriter]::new($stringAsStream)
1267+
$writer.write("${{ github.workspace }}")
1268+
$writer.Flush()
1269+
$stringAsStream.Position = 0
1270+
$hash = (Get-FileHash -Algorithm SHA256 -InputStream $stringAsStream).Hash
1271+
echo "hash=$hash" >> $env:GITHUB_OUTPUT
1272+
1273+
- name: Setup sccache
1274+
uses: hendrikmuhs/ccache-action@2e0e89e8d74340a03f75d58d02aae4c5ee1b15c6
1275+
with:
1276+
max-size: 500M
1277+
key: ${{ steps.workspace_hash.outputs.hash }}-${{ matrix.os }}-${{ matrix.arch }}-sanitizers
1278+
variant: sccache
1279+
1280+
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
1281+
1282+
- name: Configure Sanitizers
1283+
run: |
1284+
cmake -B "${{ github.workspace }}/BinaryCache/${{ matrix.os }}-${{ matrix.arch }}-sanitzers" `
1285+
-D CMAKE_BUILD_TYPE=Release `
1286+
-D CMAKE_ASM_COMPILER="${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/clang${{ matrix.exe_suffix }}" `
1287+
-D CMAKE_ASM_COMPILER_LAUNCHER=sccache `
1288+
-D CMAKE_C_COMPILER="${{ matrix.cc }}" `
1289+
-D CMAKE_C_COMPILER_LAUNCHER=sccache `
1290+
-D CMAKE_C_FLAGS="${{ matrix.cflags }}" `
1291+
-D CMAKE_CXX_COMPILER="${{ matrix.cxx }}" `
1292+
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache `
1293+
-D CMAKE_CXX_FLAGS="${{ matrix.cxxflags }}" `
1294+
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr `
1295+
-D CMAKE_SYSTEM_NAME=${{ matrix.os }} `
1296+
-G Ninja `
1297+
-S ${{ github.workspace }}/SourceCache/llvm-project/compiler-rt `
1298+
-D COMPILER_RT_DEFAULT_TARGET_ONLY=YES `
1299+
-D COMPILER_RT_BUILD_BUILTINS=NO `
1300+
-D COMPILER_RT_BUILD_CRT=NO `
1301+
-D COMPILER_RT_BUILD_LIBFUZZER=NO `
1302+
-D COMPILER_RT_BUILD_ORC=NO `
1303+
-D COMPILER_RT_BUILD_PROFILE=YES `
1304+
-D COMPILER_RT_BUILD_SANITIZERS=YES `
1305+
-D COMPILER_RT_BUILD_XRAY=NO
1306+
- name: Build Sanitizers
1307+
run: cmake --build ${{ github.workspace }}/BinaryCache/${{ matrix.os }}-${{ matrix.arch }}-sanitzers
1308+
- name: Install Sanitizers
1309+
run: cmake --build ${{ github.workspace }}/BinaryCache/${{ matrix.os }}-${{ matrix.arch }}-sanitzers --target install-compiler-rt-stripped
1310+
1311+
- uses: thebrowsercompany/gha-upload-tar-artifact@e18c33b1cd416d0d96a91dc6dce06219f98e4e27 # main
1312+
with:
1313+
name: sanitizers-${{ matrix.os }}-${{ matrix.arch }}
1314+
path: ${{ github.workspace }}/BuildRoot/Library
1315+
12291316
zlib:
12301317
runs-on: ${{ inputs.default_build_runner }}
12311318

@@ -1630,7 +1717,7 @@ jobs:
16301717
os: Windows
16311718
llvm_flags:
16321719
linker_flags: '-D CMAKE_EXE_LINKER_FLAGS="${{ inputs.WINDOWS_CMAKE_EXE_LINKER_FLAGS }}" -D CMAKE_SHARED_LINKER_FLAGS="${{ inputs.WINDOWS_CMAKE_SHARED_LINKER_FLAGS }}"'
1633-
extra_flags:
1720+
extra_flags:
16341721

16351722
- arch: arm64
16361723
cpu: 'aarch64'
@@ -1696,6 +1783,7 @@ jobs:
16961783
with:
16971784
name: compilers-Windows-${{ inputs.build_arch }}
16981785
path: ${{ github.workspace }}/BinaryCache/Library
1786+
16991787
- uses: actions/checkout@v4
17001788
with:
17011789
repository: swiftlang/llvm-project

0 commit comments

Comments
 (0)