include tools/cmake/test_prog/prog_makecontext.c
include tools/cmake/test_prog/prog_stackgrowth.c
include tools/cmake/test_prog/prog_stacksetup.c
+include tools/cmake/test_prog/prog_tsan.cpp
include tools/doxygen/fig2dev_postprocessor.pl
include tools/doxygen/list_routing_models_examples.sh
include tools/doxygen/xbt_log_extract_hierarchy.pl
/* Address Sanitizer */
#cmakedefine01 HAVE_SANITIZER_THREAD
+#cmakedefine01 HAVE_SANITIZER_THREAD_FIBER_SUPPORT
#cmakedefine01 HAVE_SANITIZER_ADDRESS
#cmakedefine01 HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
tools/cmake/test_prog/prog_makecontext.c
tools/cmake/test_prog/prog_stackgrowth.c
tools/cmake/test_prog/prog_stacksetup.c
+ tools/cmake/test_prog/prog_tsan.cpp
tools/cmake/cross-mingw.cmake
tools/smpi/generate_smpi_defines.pl
tools/stack-cleaner/as
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -fno-omit-frame-pointer -no-pie")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer -no-pie")
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -fsanitize=thread -no-pie")
- set(HAVE_SANITIZER_THREAD TRUE CACHE INTERNAL "")
+ try_compile(HAVE_SANITIZER_THREAD ${CMAKE_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_tsan.cpp)
+ try_compile(HAVE_SANITIZER_THREAD_FIBER_SUPPORT ${CMAKE_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_tsan.cpp
+ COMPILE_DEFINITIONS -DCHECK_FIBER_SUPPORT)
else()
set(HAVE_SANITIZER_THREAD FALSE CACHE INTERNAL "")
+ set(HAVE_SANITIZER_THREAD_FIBER_SUPPORT FALSE CACHE INTERNAL "")
endif()
if(enable_undefined_sanitizer)
--- /dev/null
+/* Copyright (c) 2020. The SimGrid Team.
+ * All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+/* Check availability of ThreadSanitizer */
+
+#if defined(__has_feature)
+#define HAS_FEATURE(x) __has_feature(x)
+#else
+#define HAS_FEATURE(x) 0
+#endif
+
+#if not HAS_FEATURE(thread_sanitizer) && not defined(__SANITIZE_THREAD__)
+#error "TSan feature not found."
+#endif
+
+#if defined(CHECK_FIBER_SUPPORT)
+#include <sanitizer/tsan_interface.h>
+// Verify the existence of the fiber annotation interface, with the expected signature
+void* (*create_fiber)(unsigned) = __tsan_create_fiber;
+void (*destroy_fiber)(void*) = __tsan_destroy_fiber;
+void (*switch_fiber)(void*, unsigned) = __tsan_switch_to_fiber;
+#endif
+
+int main(void) {}