Skip to content

Commit 8744e48

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 701485b commit 8744e48

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

.github/workflows/swift-toolchain.yml

+86
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,91 @@ jobs:
12251225
symbolsFolder: ${{ github.workspace }}/BinaryCache/1
12261226
searchPattern: '**/*.exe'
12271227

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

@@ -1695,6 +1780,7 @@ jobs:
16951780
with:
16961781
name: compilers-Windows-${{ inputs.build_arch }}
16971782
path: ${{ github.workspace }}/BinaryCache/Library
1783+
16981784
- uses: actions/checkout@v4
16991785
with:
17001786
repository: swiftlang/llvm-project

0 commit comments

Comments
 (0)