Skip to content

GHA: build sanitizers for distribution #897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 89 additions & 1 deletion .github/workflows/swift-toolchain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,93 @@ jobs:
symbolsFolder: ${{ github.workspace }}/BinaryCache/1
searchPattern: '**/*.exe'

sanitizers:
# TODO: Build this on macOS or make an equivalent Mac-only job
if: inputs.build_os == 'Windows'
runs-on: ${{ inputs.default_build_runner }}
needs: [compilers]

strategy:
fail-fast: false
matrix: ${{ fromJSON(inputs.target_matrix) }}

name: ${{ matrix.os }} ${{ matrix.arch }} Sanitizers

steps:
- name: Download Compilers
uses: thebrowsercompany/gha-download-tar-artifact@59992d91335d4ecba543c8535f7d07238e42125d # main
with:
name: compilers-Windows-${{ inputs.build_arch }}
path: ${{ github.workspace }}/BinaryCache/Library

- uses: actions/checkout@v4
with:
repository: swiftlang/llvm-project
ref: ${{ inputs.llvm_project_revision }}
path: ${{ github.workspace }}/SourceCache/llvm-project
show-progress: false

- uses: nttld/setup-ndk@v1
if: matrix.os == 'Android' && inputs.build_android
id: setup-ndk
with:
ndk-version: ${{ inputs.ANDROID_NDK_VERSION }}

- name: Compute workspace hash
id: workspace_hash
shell: pwsh
run: |
$stringAsStream = [System.IO.MemoryStream]::new()
$writer = [System.IO.StreamWriter]::new($stringAsStream)
$writer.write("${{ github.workspace }}")
$writer.Flush()
$stringAsStream.Position = 0
$hash = (Get-FileHash -Algorithm SHA256 -InputStream $stringAsStream).Hash
echo "hash=$hash" >> $env:GITHUB_OUTPUT

- name: Setup sccache
uses: hendrikmuhs/ccache-action@2e0e89e8d74340a03f75d58d02aae4c5ee1b15c6
with:
max-size: 500M
key: ${{ steps.workspace_hash.outputs.hash }}-${{ matrix.os }}-${{ matrix.arch }}-sanitizers
variant: sccache

- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master

- name: Configure Sanitizers
run: |
cmake -B "${{ github.workspace }}/BinaryCache/${{ matrix.os }}-${{ matrix.arch }}-sanitzers" `
-D CMAKE_BUILD_TYPE=Release `
-D CMAKE_ASM_COMPILER="${{ github.workspace }}/BinaryCache/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin/clang${{ matrix.exe_suffix }}" `
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path needs an update here (and below)

-D CMAKE_ASM_COMPILER_LAUNCHER=sccache `
-D CMAKE_C_COMPILER="${{ matrix.cc }}" `
-D CMAKE_C_COMPILER_LAUNCHER=sccache `
-D CMAKE_C_FLAGS="${{ matrix.cflags }}" `
-D CMAKE_CXX_COMPILER="${{ matrix.cxx }}" `
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache `
-D CMAKE_CXX_FLAGS="${{ matrix.cxxflags }}" `
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr `
-D CMAKE_SYSTEM_NAME=${{ matrix.os }} `
-G Ninja `
-S ${{ github.workspace }}/SourceCache/llvm-project/compiler-rt `
-D COMPILER_RT_DEFAULT_TARGET_ONLY=YES `
-D COMPILER_RT_BUILD_BUILTINS=NO `
-D COMPILER_RT_BUILD_CRT=NO `
-D COMPILER_RT_BUILD_LIBFUZZER=NO `
-D COMPILER_RT_BUILD_ORC=NO `
-D COMPILER_RT_BUILD_PROFILE=YES `
-D COMPILER_RT_BUILD_SANITIZERS=YES `
-D COMPILER_RT_BUILD_XRAY=NO
- name: Build Sanitizers
run: cmake --build ${{ github.workspace }}/BinaryCache/${{ matrix.os }}-${{ matrix.arch }}-sanitzers
- name: Install Sanitizers
run: cmake --build ${{ github.workspace }}/BinaryCache/${{ matrix.os }}-${{ matrix.arch }}-sanitzers --target install-compiler-rt-stripped

- uses: thebrowsercompany/gha-upload-tar-artifact@e18c33b1cd416d0d96a91dc6dce06219f98e4e27 # main
with:
name: sanitizers-${{ matrix.os }}-${{ matrix.arch }}
path: ${{ github.workspace }}/BuildRoot/Library

zlib:
runs-on: ${{ inputs.default_build_runner }}

Expand Down Expand Up @@ -1630,7 +1717,7 @@ jobs:
os: Windows
llvm_flags:
linker_flags: '-D CMAKE_EXE_LINKER_FLAGS="${{ inputs.WINDOWS_CMAKE_EXE_LINKER_FLAGS }}" -D CMAKE_SHARED_LINKER_FLAGS="${{ inputs.WINDOWS_CMAKE_SHARED_LINKER_FLAGS }}"'
extra_flags:
extra_flags:

- arch: arm64
cpu: 'aarch64'
Expand Down Expand Up @@ -1696,6 +1783,7 @@ jobs:
with:
name: compilers-Windows-${{ inputs.build_arch }}
path: ${{ github.workspace }}/BinaryCache/Library

- uses: actions/checkout@v4
with:
repository: swiftlang/llvm-project
Expand Down