Skip to content

Commit

Permalink
CMake: Create a set of vcpkg overlay triplets for sanitizers
Browse files Browse the repository at this point in the history
This changes the Sanitizer configs to build all the vcpkg dependencies
with our specified CFLAGS and CXXFLAGS for ASAN and UBSAN.

Unfortunately, we can't yet enable actually compiling them with
sanitizers enabled, because this causes test failures that need to be
investigated.
  • Loading branch information
ADKaster committed Jun 17, 2024
1 parent 2a888ca commit 9b642a7
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .github/workflows/lagom-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ jobs:
echo "host_cxx=$(brew --prefix llvm@18)/bin/clang++" >> "$GITHUB_OUTPUT"
fi
- name: Set dynamic environment variables
id: 'set-env-vars'
run: |
# Note: Required for vcpkg to use this compiler for its own builds.
echo "CC=${{ steps.build-parameters.outputs.host_cc }} >> "$GITHUB_ENV"
echo "CXX=${{ steps.build-parameters.outputs.host_cxx }} >> "$GITHUB_ENV"
# https://github.com/actions/runner-images/issues/9330
- name: Enable Microphone Access (macOS 14)
if: ${{ inputs.os == 'macos-14' }}
Expand Down
3 changes: 2 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"ENABLE_UNDEFINED_SANITIZER": "ON",
"ENABLE_ADDRESS_SANITIZER": "ON"
"ENABLE_ADDRESS_SANITIZER": "ON",
"VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/Meta/CMake/vcpkg/sanitizer-triplets"
}
},
{
Expand Down
9 changes: 9 additions & 0 deletions Meta/CMake/vcpkg/sanitizer-triplets/arm64-osx.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set(VCPKG_TARGET_ARCHITECTURE arm64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)

set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
set(VCPKG_OSX_ARCHITECTURES arm64)

set(VCPKG_C_FLAGS "")
set(VCPKG_CXX_FLAGS "-frtti")
8 changes: 8 additions & 0 deletions Meta/CMake/vcpkg/sanitizer-triplets/x64-linux.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)

set(VCPKG_CMAKE_SYSTEM_NAME Linux)

set(VCPKG_C_FLAGS "")
set(VCPKG_CXX_FLAGS "-frtti")
9 changes: 9 additions & 0 deletions Meta/CMake/vcpkg/sanitizer-triplets/x64-osx.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)

set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
set(VCPKG_OSX_ARCHITECTURES x86_64)

set(VCPKG_C_FLAGS "")
set(VCPKG_CXX_FLAGS "-frtti")
4 changes: 4 additions & 0 deletions Meta/ladybird.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ cmd_with_target() {
CMAKE_ARGS+=("-DCMAKE_C_COMPILER=${CC}")
CMAKE_ARGS+=("-DCMAKE_CXX_COMPILER=${CXX}")

# Export CC and CXX for the vcpkg toolchain, so it will pick up the same version as the ladybird build
export CC="$CC"
export CXX="$CXX"

if [ ! -d "$LADYBIRD_SOURCE_DIR" ]; then
LADYBIRD_SOURCE_DIR="$(get_top_dir)"
export LADYBIRD_SOURCE_DIR
Expand Down

0 comments on commit 9b642a7

Please sign in to comment.