diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cff0012c29..84366c2325 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,9 +15,11 @@ concurrency: jobs: libmamba_static: runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.sanitizer != 'no_sanitizer' }} strategy: matrix: os: [ubuntu-latest, macos-latest] + sanitizer: [ no_sanitizer, asan, ubsan, tsan ] steps: - uses: actions/checkout@v3 - name: create build environment @@ -40,6 +42,9 @@ jobs: -DBUILD_STATIC=ON \ -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ -DCMAKE_C_COMPILER_LAUNCHER=sccache \ + -DENABLE_ASAN=${{ matrix.sanitizer == 'asan' && 'ON' || 'OFF' }} \ + -DENABLE_TSAN=${{ matrix.sanitizer == 'tsan' && 'ON' || 'OFF' }} \ + -DENABLE_UBSAN=${{ matrix.sanitizer == 'ubsan' && 'ON' || 'OFF' }} \ -GNinja ninja - name: build cache statistics @@ -54,9 +59,11 @@ jobs: libmamba_cpp_tests: needs: [libmamba_static] runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.sanitizer != 'no_sanitizer' }} strategy: matrix: os: [ubuntu-latest, macos-latest] + sanitizer: [ no_sanitizer, asan, ubsan, tsan ] steps: - uses: actions/checkout@v3 - name: create build environment @@ -82,6 +89,9 @@ jobs: -DBUILD_LIBMAMBA_TESTS=ON \ -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ -DCMAKE_C_COMPILER_LAUNCHER=sccache \ + -DENABLE_ASAN=${{ matrix.sanitizer == 'asan' && 'ON' || 'OFF' }} \ + -DENABLE_TSAN=${{ matrix.sanitizer == 'tsan' && 'ON' || 'OFF' }} \ + -DENABLE_UBSAN=${{ matrix.sanitizer == 'ubsan' && 'ON' || 'OFF' }} \ -GNinja ninja testing_libmamba_lock ninja test @@ -97,9 +107,11 @@ jobs: umamba_tests: needs: [libmamba_static] runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.sanitizer != 'no_sanitizer' }} strategy: matrix: os: [ubuntu-latest, macos-latest] + sanitizer: [ no_sanitizer, asan, ubsan, tsan ] steps: - uses: actions/checkout@v3 - name: create build environment @@ -126,6 +138,9 @@ jobs: -DBUILD_SHARED=ON \ -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ -DCMAKE_C_COMPILER_LAUNCHER=sccache \ + -DENABLE_ASAN=${{ matrix.sanitizer == 'asan' && 'ON' || 'OFF' }} \ + -DENABLE_TSAN=${{ matrix.sanitizer == 'tsan' && 'ON' || 'OFF' }} \ + -DENABLE_UBSAN=${{ matrix.sanitizer == 'ubsan' && 'ON' || 'OFF' }} \ -GNinja ninja - name: build cache statistics @@ -156,9 +171,11 @@ jobs: mamba_python_tests: needs: [libmamba_static] runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.sanitizer != 'no_sanitizer' }} strategy: matrix: os: [ubuntu-latest, macos-latest] + sanitizer: [ no_sanitizer, asan, ubsan, tsan ] python_version: ["3.8"] steps: @@ -194,6 +211,9 @@ jobs: -DBUILD_MAMBA_PACKAGE=ON \ -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ -DCMAKE_C_COMPILER_LAUNCHER=sccache \ + -DENABLE_ASAN=${{ matrix.sanitizer == 'asan' && 'ON' || 'OFF' }} \ + -DENABLE_TSAN=${{ matrix.sanitizer == 'tsan' && 'ON' || 'OFF' }} \ + -DENABLE_UBSAN=${{ matrix.sanitizer == 'ubsan' && 'ON' || 'OFF' }} \ -GNinja ninja ninja install diff --git a/CMakeLists.txt b/CMakeLists.txt index 34614d8b6b..a2018d29fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,36 @@ if (MSVC) # add_definitions("-DUNICODE -D_UNICODE") endif() + +option(ENABLE_ASAN "Enable Address-Sanitizer (currently only supported on GCC and Clang)" OFF) +option(ENABLE_TSAN "Enable Thread-Sanitizer (currently only supported on GCC and Clang)" OFF) +option(ENABLE_UBSAN "Enable Undefined-Behavior-Sanitizer (currently only supported on GCC and Clang)" OFF) + +if(ENABLE_ASAN) + message(WARNING "Address-Sanitizer instrumentation will be injected into binaries - do not release these binaries") + set(SANITIZER_FLAGS ${SANITIZER_FLAGS} -fno-omit-frame-pointer -fsanitize=address) +endif() + +if(ENABLE_TSAN) + message(WARNING "Thread-Sanitizer instrumentation will be injected into binaries - do not release these binaries") + set(SANITIZER_FLAGS ${SANITIZER_FLAGS} -fno-omit-frame-pointer -fsanitize=thread) +endif() + +if(ENABLE_UBSAN) + message(WARNING "Undefined-Sanitizer instrumentation will be injected into binaries - do not release these binaries") + set(SANITIZER_FLAGS ${SANITIZER_FLAGS} -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=all) +endif() + +if(SANITIZER_FLAGS) + add_compile_options(${SANITIZER_FLAGS}) + add_link_options(${SANITIZER_FLAGS}) + if(BUILD_STATIC) + # This is necessary because add_link_options() only pass flags to linker, not static cases + set(STATIC_LIBRARY_FLAGS ${STATIC_LIBRARY_FLAGS} ${SANITIZER_FLAGS}) + endif() +endif() + + # Variants # ======== diff --git a/libmamba/CMakeLists.txt b/libmamba/CMakeLists.txt index 20c4c54053..08686844b5 100644 --- a/libmamba/CMakeLists.txt +++ b/libmamba/CMakeLists.txt @@ -63,27 +63,6 @@ if (WIN32) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) endif () -option(ENABLE_ASAN "Enable Address-Sanitizer (currently only supported on GCC and Clang)" OFF) - -if(ENABLE_ASAN) - message(WARNING "Address-Sanitizer instrumentation will be injected into binaries - do not release these binaries") - add_compile_options(-fno-omit-frame-pointer -fsanitize=address) - add_link_options(-fno-omit-frame-pointer -fsanitize=address) -endif() - -if(ENABLE_TSAN) - message(WARNING "Thread-Sanitizer instrumentation will be injected into binaries - do not release these binaries") - add_compile_options(-fno-omit-frame-pointer -fsanitize=thread) - add_link_options(-fno-omit-frame-pointer -fsanitize=thread) -endif() - -if(ENABLE_USAN) - message(WARNING "Undefined-Sanitizer instrumentation will be injected into binaries - do not release these binaries") - add_compile_options(-fno-omit-frame-pointer -fsanitize=undefined) - add_link_options(-fno-omit-frame-pointer -fsanitize=undefined) -endif() - - # Source files # ============ diff --git a/micromamba/CMakeLists.txt b/micromamba/CMakeLists.txt index 199a7659c3..cf1ef61165 100644 --- a/micromamba/CMakeLists.txt +++ b/micromamba/CMakeLists.txt @@ -19,6 +19,7 @@ else () set(MICROMAMBA_LINKAGE "DYNAMIC" CACHE STRING "micromamba linkage against libraries") endif () + # Source files # ============