Use add_link_options. Also add USE_MSAN
And define the macros stacktrace.amalgamation.cpp expects
This commit is contained in:
parent
68de888fb4
commit
62d3b1c674
|
@ -9,7 +9,8 @@ env_set(ALLOC_INSTRUMENTATION OFF BOOL "Instrument alloc")
|
|||
env_set(WITH_UNDODB OFF BOOL "Use rr or undodb")
|
||||
env_set(USE_ASAN OFF BOOL "Compile with address sanitizer")
|
||||
env_set(USE_GCOV OFF BOOL "Compile with gcov instrumentation")
|
||||
env_set(USE_TSAN OFF BOOL "Compile with thread sanitizer")
|
||||
env_set(USE_MSAN OFF BOOL "Compile with memory sanitizer. To avoid false positives you need to dynamically link to a msan-instrumented libc++ and libc++abi, which you must compile separately.")
|
||||
env_set(USE_TSAN OFF BOOL "Compile with thread sanitizer. It is recommended to dynamically link to a tsan-instrumented libc++ and libc++abi, which you can compile separately.")
|
||||
env_set(USE_UBSAN OFF BOOL "Compile with undefined behavior sanitizer")
|
||||
env_set(FDB_RELEASE OFF BOOL "This is a building of a final release")
|
||||
env_set(USE_CCACHE OFF BOOL "Use ccache for compilation if available")
|
||||
|
@ -29,6 +30,9 @@ endif()
|
|||
if(STATIC_LINK_LIBCXX AND USE_TSAN)
|
||||
message(FATAL_ERROR "Unsupported configuration: STATIC_LINK_LIBCXX doesn't work with tsan")
|
||||
endif()
|
||||
if(STATIC_LINK_LIBCXX AND USE_MSAN)
|
||||
message(FATAL_ERROR "Unsupported configuration: STATIC_LINK_LIBCXX doesn't work with msan")
|
||||
endif()
|
||||
|
||||
set(rel_debug_paths OFF)
|
||||
if(RELATIVE_DEBUG_PATHS)
|
||||
|
@ -165,10 +169,23 @@ else()
|
|||
if(USE_ASAN)
|
||||
add_compile_options(
|
||||
-fsanitize=address
|
||||
-DUSE_SANITIZER)
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=address")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address ${CMAKE_THREAD_LIBS_INIT}")
|
||||
-DUSE_SANITIZER
|
||||
-DADDRESS_SANITIZER
|
||||
)
|
||||
add_link_options(-fsanitize=address)
|
||||
endif()
|
||||
|
||||
if(USE_MSAN)
|
||||
if(NOT CLANG)
|
||||
message(FATAL_ERROR "Unsupported configuration: USE_MSAN only works with Clang")
|
||||
endif()
|
||||
add_compile_options(
|
||||
-fsanitize=memory
|
||||
-fsanitize-memory-track-origins=2
|
||||
-DUSE_SANITIZER
|
||||
-DMEMORY_SANITIZER
|
||||
)
|
||||
add_link_options(-fsanitize=memory)
|
||||
endif()
|
||||
|
||||
if(USE_GCOV)
|
||||
|
@ -183,19 +200,20 @@ else()
|
|||
-fsanitize=undefined
|
||||
# TODO(atn34) Re-enable -fsanitize=alignment once https://github.com/apple/foundationdb/issues/1434 is resolved
|
||||
-fno-sanitize=alignment
|
||||
-DUSE_SANITIZER)
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=undefined")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=undefined")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined ${CMAKE_THREAD_LIBS_INIT}")
|
||||
-DUSE_SANITIZER
|
||||
-DUNDEFINED_BEHAVIOR_SANITIZER
|
||||
)
|
||||
add_link_options(-fsanitize=undefined)
|
||||
endif()
|
||||
|
||||
if(USE_TSAN)
|
||||
add_compile_options(
|
||||
-fsanitize=thread
|
||||
-DUSE_SANITIZER)
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=thread")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=thread")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread ${CMAKE_THREAD_LIBS_INIT}")
|
||||
-DUSE_SANITIZER
|
||||
-DTHREAD_SANITIZER
|
||||
-DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL=1
|
||||
)
|
||||
add_link_options(-fsanitize=thread)
|
||||
endif()
|
||||
|
||||
if(PORTABLE_BINARY)
|
||||
|
|
|
@ -3010,7 +3010,7 @@ ImageInfo getImageInfo(const void *symbol) {
|
|||
ImageInfo imageInfo;
|
||||
|
||||
#ifdef __linux__
|
||||
link_map *linkMap;
|
||||
link_map* linkMap = nullptr;
|
||||
int res = dladdr1(symbol, &info, (void**)&linkMap, RTLD_DL_LINKMAP);
|
||||
#else
|
||||
int res = dladdr(symbol, &info);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <stdarg.h>
|
||||
#include <cinttypes>
|
||||
|
||||
#if (defined (__linux__) || defined (__FreeBSD__)) && defined(__AVX__)
|
||||
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__AVX__) && !defined(MEMORY_SANITIZER)
|
||||
// For benchmarking; need a version of rte_memcpy that doesn't live in the same compilation unit as the test.
|
||||
void * rte_memcpy_noinline(void *__restrict __dest, const void *__restrict __src, size_t __n) {
|
||||
return rte_memcpy(__dest, __src, __n);
|
||||
|
@ -41,7 +41,7 @@ __attribute__((visibility ("default"))) void *memcpy (void *__restrict __dest, c
|
|||
void * rte_memcpy_noinline(void *__restrict __dest, const void *__restrict __src, size_t __n) {
|
||||
return memcpy(__dest, __src, __n);
|
||||
}
|
||||
#endif // (defined (__linux__) || defined (__FreeBSD__)) && defined(__AVX__)
|
||||
#endif // (defined (__linux__) || defined (__FreeBSD__)) && defined(__AVX__) && !defined(MEMORY_SANITIZER)
|
||||
|
||||
INetwork *g_network = 0;
|
||||
|
||||
|
|
|
@ -2926,7 +2926,7 @@ static class VDSOInitHelper {
|
|||
/* Each function is empty and called (via a macro) only in debug mode.
|
||||
The arguments are captured by dynamic tools at runtime. */
|
||||
|
||||
#if DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL == 0 && !defined(__native_client__) && !__has_feature(thread_sanitizer)
|
||||
#if DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL == 0 && !defined(__native_client__)
|
||||
|
||||
#if __has_feature(memory_sanitizer)
|
||||
#include <sanitizer/msan_interface.h>
|
||||
|
|
Loading…
Reference in New Issue