cmake-args: -DZLIB_COMPAT=ON -DZLIB_SYMBOL_PREFIX=zTest_
codecov: ubuntu_gcc_compat_sprefix
- - name: Ubuntu GCC -O1 OSB
+ - name: Ubuntu GCC -O3 OSB
os: ubuntu-latest
compiler: gcc
cxx-compiler: g++
build-dir: ../build
build-src-dir: ../zlib-ng
codecov: ubuntu_gcc_osb
- cflags: -O1 -g3
+ cflags: -O3
- - name: Ubuntu GCC -O3 No Unaligned UBSAN
+ - name: Ubuntu GCC -O1 No Unaligned UBSAN
os: ubuntu-latest
compiler: gcc
cxx-compiler: g++
cmake-args: -DWITH_UNALIGNED=OFF -DWITH_SANITIZER=Undefined
- codecov: ubuntu_gcc_o3
- cflags: -O3
+ codecov: ubuntu_gcc_o1
+ cflags: -O1
- name: Ubuntu GCC 32-bit
os: ubuntu-latest
cmake-args: -GNinja -DWITH_SANITIZER=Memory
packages: ninja-build llvm-11-tools
gcov-exec: llvm-cov-11 gcov
- cflags: -g3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize-memory-track-origins
- name: Windows MSVC Win32
os: windows-latest
# detect-sanitizer.cmake -- Detect supported compiler sanitizer flags
# Licensed under the Zlib license, see LICENSE.md for details
+macro(add_common_sanitizer_flags)
+ if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
+ add_compile_options(-g3)
+ endif()
+ check_c_compiler_flag(-fno-omit-frame-pointer HAVE_NO_OMIT_FRAME_POINTER)
+ if(HAVE_NO_OMIT_FRAME_POINTER)
+ add_compile_options(-fno-omit-frame-pointer)
+ add_link_options(-fno-omit-frame-pointer)
+ endif()
+ check_c_compiler_flag(-fno-optimize-sibling-calls HAVE_NO_OPTIMIZE_SIBLING_CALLS)
+ if(HAVE_NO_OPTIMIZE_SIBLING_CALLS)
+ add_compile_options(-fno-optimize-sibling-calls)
+ add_link_options(-fno-optimize-sibling-calls)
+ endif()
+endmacro()
+
macro(check_sanitizer_support known_checks supported_checks)
set(available_checks "")
message(STATUS "Address sanitizer is enabled: ${supported_checks}")
add_compile_options(-fsanitize=${supported_checks})
add_link_options(-fsanitize=${supported_checks})
+ add_common_sanitizer_flags()
else()
message(STATUS "Address sanitizer is not supported")
endif()
message(STATUS "Leak sanitizer is enabled: ${supported_checks}")
add_compile_options(-fsanitize=${supported_checks})
add_link_options(-fsanitize=${supported_checks})
+ add_common_sanitizer_flags()
else()
message(STATUS "Leak sanitizer is not supported")
endif()
message(STATUS "Memory sanitizer is enabled: ${supported_checks}")
add_compile_options(-fsanitize=${supported_checks})
add_link_options(-fsanitize=${supported_checks})
+ add_common_sanitizer_flags()
+
+ check_c_compiler_flag(-fsanitize-memory-track-origins HAVE_MEMORY_TRACK_ORIGINS)
+ if(HAVE_MEMORY_TRACK_ORIGINS)
+ add_compile_options(-fsanitize-memory-track-origins)
+ add_link_options(-fsanitize-memory-track-origins)
+ endif()
else()
message(STATUS "Memory sanitizer is not supported")
endif()
message(STATUS "Thread sanitizer is enabled: ${supported_checks}")
add_compile_options(-fsanitize=${supported_checks})
add_link_options(-fsanitize=${supported_checks})
+ add_common_sanitizer_flags()
else()
message(STATUS "Thread sanitizer is not supported")
endif()
if(WITH_UNALIGNED)
add_compile_options(-fno-sanitize=alignment)
endif()
+
+ add_common_sanitizer_flags()
else()
message(STATUS "Undefined behavior sanitizer is not supported")
endif()