Fix build with ubsan and tsan

This commit is contained in:
Daan 2024-12-31 11:03:18 -08:00 committed by GitHub
parent 611bf61d82
commit 9f4bd23085
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: B5690EEEBB952194

View file

@ -611,20 +611,19 @@ endif()
# Build fuzz tests # Build fuzz tests
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
if(DEFINED ENV{LIB_FUZZING_ENGINE}) if(DEFINED ENV{LIB_FUZZING_ENGINE})
set(FUZZING_ENGINE $ENV{LIB_FUZZING_ENGINE}) set(FUZZING_ENGINE $ENV{LIB_FUZZING_ENGINE})
set(FUZZING_COMPILE_FLAGS "") set(FUZZING_COMPILE_FLAGS "")
set(FUZZING_LINK_FLAGS "${FUZZING_ENGINE}") set(FUZZING_LINK_FLAGS "${FUZZING_ENGINE}")
else() else()
set(FUZZING_COMPILE_FLAGS "-fsanitize=fuzzer,address") set(FUZZING_COMPILE_FLAGS "-fsanitize=fuzzer,address")
set(FUZZING_LINK_FLAGS "-fsanitize=fuzzer,address") set(FUZZING_LINK_FLAGS "-fsanitize=fuzzer,address")
endif() endif()
if('${CMAKE_CXX_COMPILER_ID}' STREQUAL 'Clang') if(('${CMAKE_CXX_COMPILER_ID}' STREQUAL 'Clang') AND NOT MI_DEBUG_TSAN)
## fuzz testing ## fuzz testing
add_executable(fuzz-random-alloc test/fuzz-random-alloc.c) add_executable(mimalloc-test-fuzz test/test-fuzz.c)
target_link_libraries(fuzz-random-alloc PUBLIC mimalloc) target_compile_definitions(mimalloc-test-fuzz PRIVATE ${mi_defines})
set_target_properties(fuzz-random-alloc PROPERTIES target_compile_options(mimalloc-test-fuzz PRIVATE ${mi_cflags} "${FUZZING_COMPILE_FLAGS}")
COMPILE_FLAGS "${FUZZING_COMPILE_FLAGS}" target_include_directories(mimalloc-test-fuzz PRIVATE include)
LINK_FLAGS "${FUZZING_LINK_FLAGS}" target_link_libraries(mimalloc-test-fuzz PRIVATE mimalloc ${mi_libraries} "${FUZZING_LINK_FLAGS}")
)
endif() endif()