Skip to content
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

CI: Rework Sanitizing #107

Merged
merged 7 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
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
58 changes: 30 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ jobs:
cxx_standard: ${{ fromJSON(needs.generate-base-matrix.outputs.cxx_versions) }}
config:
# clang
- prefix: "Linux"
suffix: "ASan"
os: "ubuntu-latest"
container:
image: "ghcr.io/dnkpp/clang:19"
compiler_name: "clang"
compiler_version: "19"
asan: true

- prefix: "Linux"
suffix: "/libc++"
os: "ubuntu-latest"
Expand All @@ -79,16 +88,13 @@ jobs:
compiler_name: "clang"
compiler_version: "19"
libcxx: true
asan: true

- prefix: "Linux"
os: "ubuntu-latest"
container:
image: "ghcr.io/dnkpp/clang:19"
compiler_name: "clang"
compiler_version: "19"
libcxx: false
asan: true

- prefix: "Linux"
suffix: "/libc++"
Expand All @@ -98,16 +104,13 @@ jobs:
compiler_name: "clang"
compiler_version: "18"
libcxx: true
asan: true

- prefix: "Linux"
os: "ubuntu-latest"
container:
image: "ghcr.io/dnkpp/clang:18"
compiler_name: "clang"
compiler_version: "18"
libcxx: false
asan: true

- prefix: "Linux"
suffix: "/libc++"
Expand All @@ -117,16 +120,13 @@ jobs:
compiler_name: "clang"
compiler_version: "17"
libcxx: true
asan: true

- prefix: "Linux"
os: "ubuntu-latest"
container:
image: "ghcr.io/dnkpp/clang:17"
compiler_name: "clang"
compiler_version: "17"
libcxx: false
asan: true

- prefix: "Linux"
suffix: "/libc++"
Expand All @@ -137,7 +137,6 @@ jobs:
compiler_version: "16"
only_fmt: true
libcxx: true
asan: true

- prefix: "Linux"
os: "ubuntu-latest"
Expand All @@ -146,27 +145,30 @@ jobs:
compiler_name: "clang"
compiler_version: "16"
only_fmt: true
libcxx: false
asan: true

# gcc
- prefix: "Linux"
suffix: "ASan"
os: "ubuntu-latest"
container:
image: "ghcr.io/dnkpp/gcc:14"
compiler_name: "gcc"
compiler_version: "14"
libcxx: false
asan: true

- prefix: "Linux"
os: "ubuntu-latest"
container:
image: "ghcr.io/dnkpp/gcc:14"
compiler_name: "gcc"
compiler_version: "14"

- prefix: "Linux"
os: "ubuntu-latest"
container:
image: "ghcr.io/dnkpp/gcc:13"
compiler_name: "gcc"
compiler_version: "13"
libcxx: false
asan: true

- prefix: "Linux"
os: "ubuntu-latest"
Expand All @@ -175,8 +177,6 @@ jobs:
compiler_name: "gcc"
compiler_version: "12"
only_fmt: true
libcxx: false
asan: true

# msvc
- prefix: "Windows 2022"
Expand All @@ -199,7 +199,7 @@ jobs:
compiler_version: "ClangCl"
cmake_generator: "Visual Studio 17 2022"

# macOs
# macOS
- prefix: "macOS"
os: "macos-latest"
compiler_name: "AppleClang"
Expand All @@ -218,8 +218,8 @@ jobs:
os: "macos-latest"
compiler_name: "AppleClang"
compiler_version: "16"
only_fmt: true
ldflags_workaround: "-L/opt/homebrew/opt/llvm@16/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm@16/lib/c++"
only_fmt: true
asan: true

exclude:
Expand All @@ -233,6 +233,10 @@ jobs:
- architecture: "32bit"
config:
prefix: "macOS"
# run asan only in debug mode
- build_mode: "Release"
config:
asan: true

steps:
- name: Checkout code
Expand Down Expand Up @@ -347,18 +351,16 @@ jobs:
libc++abi-${{ matrix.config.compiler_version }}-dev:i386

- name: Enable Address and Undefined Sanitizer
if: ${{ matrix.config.asan == true }}
if: ${{ matrix.config.asan }}
shell: bash
run: |
echo "CMAKE_BASE_OPTIONS=$(echo ${CMAKE_BASE_OPTIONS} -DSANITIZE_ADDRESS=YES -DSANITIZE_UNDEFINED=YES)" >> $GITHUB_ENV
# ASan has some serious trouble with libc++ exception mechanism
# see: https://github.com/llvm/llvm-project/issues/59432
#if [[ "${{ matrix.config.libcxx }}" ]]; then
# echo "ASAN_OPTIONS=$(echo ${ASAN_OPTIONS}:alloc_dealloc_mismatch=0)" >> $GITHUB_ENV
#fi

# ASan has some serious trouble with libc++ exception mechanism
# see: https://github.com/llvm/llvm-project/issues/59432
- name: Disable alloc_dealloc_mismatch detection with libc++
if: ${{ matrix.config.asan == true && matrix.config.libcxx == true}}
shell: bash
run: |
echo "ASAN_OPTIONS=$(echo ${ASAN_OPTIONS}:alloc_dealloc_mismatch=0)" >> $GITHUB_ENV
echo "CMAKE_BASE_OPTIONS=$(echo ${CMAKE_BASE_OPTIONS} -DSANITIZE_ADDRESS=YES -DSANITIZE_UNDEFINED=YES)" >> $GITHUB_ENV

#################################
# Without optional features
Expand Down
14 changes: 10 additions & 4 deletions cmake/EnableSanitizers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ function(enable_sanitizers TARGET_NAME)
if (SANITIZE_ADDRESS)
# workaround linker errors on msvc
# see: https://learn.microsoft.com/en-us/answers/questions/864574/enabling-address-sanitizer-results-in-error-lnk203
target_compile_definitions(
${TARGET_NAME}
target_compile_definitions(${TARGET_NAME}
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:_DISABLE_VECTOR_ANNOTATION>
$<$<CXX_COMPILER_ID:MSVC>:_DISABLE_STRING_ANNOTATION>
"$<$<CXX_COMPILER_ID:MSVC>:_DISABLE_VECTOR_ANNOTATION;_DISABLE_STRING_ANNOTATION>"
)

target_compile_options(${TARGET_NAME}
PRIVATE
# see: https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html#index-fsanitize_003dbuiltin
"$<$<CXX_COMPILER_ID:GNU>:-g;-fno-omit-frame-pointer;-fno-optimize-sibling-calls;-fno-ipa-icf>"
# see: https://clang.llvm.org/docs/AddressSanitizer.html#id3
"$<$<CXX_COMPILER_ID:Clang>:-g;-fno-omit-frame-pointer;-fno-optimize-sibling-calls>"
)
endif()

Expand Down
Loading