mirror of
https://github.com/GerbilSoft/zlib-ng.git
synced 2025-06-18 11:35:35 -04:00
Compile MSAN instrumented C++ libraries for MSAN build with googletest.
This commit is contained in:
parent
21251622da
commit
f7e746bcf6
14
.github/workflows/cmake.yml
vendored
14
.github/workflows/cmake.yml
vendored
@ -443,6 +443,20 @@ jobs:
|
||||
run: |
|
||||
wineboot --init
|
||||
|
||||
- name: Compile LLVM C++ libraries (MSAN)
|
||||
if: contains(matrix.name, 'MSAN')
|
||||
run: |
|
||||
git clone --depth=1 https://github.com/llvm/llvm-project --single-branch --branch llvmorg-11.0.0
|
||||
cd llvm-project
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -G Ninja ../llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" -DLLVM_USE_SANITIZER=MemoryWithOrigins -DLLVM_LIBC_ENABLE_LINTING=OFF
|
||||
cmake --build . -- cxx cxxabi
|
||||
echo "LLVM_BUILD_DIR=`pwd`" >> $GITHUB_ENV
|
||||
env:
|
||||
CC: ${{ matrix.compiler }}
|
||||
CXX: ${{ matrix.cxx-compiler }}
|
||||
|
||||
- name: Generate project files
|
||||
# Shared libraries turned off for qemu ppc* and sparc & reduce code coverage sources
|
||||
run: |
|
||||
|
@ -7,6 +7,17 @@ enable_language(CXX)
|
||||
# Google test requires at least C++11
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
# Google test requires MSAN instrumented LLVM C++ libraries
|
||||
if(WITH_SANITIZER STREQUAL "Memory")
|
||||
if(NOT DEFINED ENV{LLVM_BUILD_DIR})
|
||||
message(FATAL_ERROR "MSAN instrumented C++ libraries required!")
|
||||
endif()
|
||||
|
||||
# Must set include and compile options before fetching googletest
|
||||
include_directories($ENV{LLVM_BUILD_DIR}/include $ENV{LLVM_BUILD_DIR}/include/c++/v1)
|
||||
add_compile_options(-stdlib=libc++ -g)
|
||||
endif()
|
||||
|
||||
# Prevent overriding the parent project's compiler/linker settings for Windows
|
||||
set(gtest_force_shared_crt ON CACHE BOOL
|
||||
"Use shared (DLL) run-time lib even when Google Test is built as static lib." FORCE)
|
||||
@ -36,6 +47,15 @@ target_include_directories(gtest_zlib PRIVATE
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR})
|
||||
|
||||
if(WITH_SANITIZER STREQUAL "Memory")
|
||||
target_link_directories(gtest_zlib PRIVATE $ENV{LLVM_BUILD_DIR}/lib)
|
||||
target_link_options(gtest_zlib PRIVATE
|
||||
-stdlib=libc++
|
||||
-lc++abi
|
||||
-fsanitize=memory
|
||||
-fsanitize-memory-track-origins)
|
||||
endif()
|
||||
|
||||
target_link_libraries(gtest_zlib zlibstatic gtest)
|
||||
|
||||
if(ZLIB_ENABLE_TESTS)
|
||||
|
Loading…
Reference in New Issue
Block a user