From 901d0eeeb8044c17f277977a780a69d800b6e590 Mon Sep 17 00:00:00 2001 From: Stephan Hageboeck Date: Tue, 30 Jun 2026 16:58:13 +0200 Subject: [PATCH 1/7] Fix a buffer overflow in TLatex. Since the \0 character was missing in the dynamically allocated buffer, the strlen function can run past the end of the buffer. Therefore, the buffer was replaced with a TString directly constructed from char* and length. --- graf2d/graf/src/TLatex.cxx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/graf2d/graf/src/TLatex.cxx b/graf2d/graf/src/TLatex.cxx index 94379764f6f36..0a09a75fb41b1 100644 --- a/graf2d/graf/src/TLatex.cxx +++ b/graf2d/graf/src/TLatex.cxx @@ -1778,10 +1778,7 @@ TLatex::TLatexFormSize TLatex::Analyse(Double_t x, Double_t y, const TextSpec_t return TLatexFormSize(0,0,0); } TextSpec_t newSpec = spec; - Char_t *url = new Char_t[opSquareCurly-opUrl-4]; - strncpy(url,text+opUrl+5,opSquareCurly-opUrl-5); - fName = url; - delete[] url; + fName = TString(text + opUrl + 5, opSquareCurly - opUrl - 5); if (!fShow) { result = Anal1(newSpec,text+opSquareCurly+1,length-opSquareCurly-1); } else { From 21fdf8addaa19772efec9b9bf433ec62d6c824eb Mon Sep 17 00:00:00 2001 From: Stephan Hageboeck Date: Tue, 30 Jun 2026 17:08:32 +0200 Subject: [PATCH 2/7] [pyroot] Allow libasan to be loaded when running with gcc sanitizer. --- bindings/pyroot/pythonizations/test/import_load_libs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bindings/pyroot/pythonizations/test/import_load_libs.py b/bindings/pyroot/pythonizations/test/import_load_libs.py index 4212812a54853..2dcae3efa7e59 100644 --- a/bindings/pyroot/pythonizations/test/import_load_libs.py +++ b/bindings/pyroot/pythonizations/test/import_load_libs.py @@ -80,6 +80,7 @@ class ImportLoadLibs(unittest.TestCase): "libatomic", # AddressSanitizer runtime and ROOT configuration "libclang_rt.asan-.*", + "libasan", "libROOTSanitizerConfig", "libjitterentropy", # by libssl on openSUSE "libsandbox", # Gentoo portage test environment From 444a978c750b8e2c76161945961954be782619cc Mon Sep 17 00:00:00 2001 From: Stephan Hageboeck Date: Tue, 30 Jun 2026 17:09:07 +0200 Subject: [PATCH 3/7] [clad] Fix compilation failure when TMVA is off. --- math/mathcore/inc/Math/CladDerivator.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/math/mathcore/inc/Math/CladDerivator.h b/math/mathcore/inc/Math/CladDerivator.h index 0eedbbca9889f..f8f7359d75bf3 100644 --- a/math/mathcore/inc/Math/CladDerivator.h +++ b/math/mathcore/inc/Math/CladDerivator.h @@ -1074,6 +1074,7 @@ extern "C" void sgemm_(const char *transa, const char *transb, const int *m, con namespace clad::custom_derivatives { +#ifdef R__HAS_TMVACPU namespace TMVA::Experimental::SOFIE { inline void Gemm_Call_pullback(float *output, bool transa, bool transb, int m, int n, int k, float alpha, @@ -1156,6 +1157,8 @@ inline void Relu_pullback(float *output, const float *input, int size, float *_d } // namespace TMVA::Experimental::SOFIE +#endif // R__HAS_TMVACPU + } // namespace clad::custom_derivatives #endif // CLAD_DERIVATOR From 76622253229932060d4e771d304d0cc5123a10f5 Mon Sep 17 00:00:00 2001 From: Stephan Hageboeck Date: Fri, 3 Jul 2026 15:00:22 +0200 Subject: [PATCH 4/7] [PyROOT] Correct size of the argv array. Asan detected an overflow of the argv array, because it violated the convention to contain an extra element == nullptr. --- bindings/pyroot/pythonizations/src/RPyROOTApplication.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bindings/pyroot/pythonizations/src/RPyROOTApplication.cxx b/bindings/pyroot/pythonizations/src/RPyROOTApplication.cxx index 67f11364399e3..6be2f786898f9 100644 --- a/bindings/pyroot/pythonizations/src/RPyROOTApplication.cxx +++ b/bindings/pyroot/pythonizations/src/RPyROOTApplication.cxx @@ -46,7 +46,8 @@ bool PyROOT::RPyROOTApplication::CreateApplication(int ignoreCmdLineOpts) char **argv = nullptr; if (ignoreCmdLineOpts) { - argv = new char *[argc]; + // Last argv must be null (see https://en.cppreference.com/cpp/language/main_function) + argv = new char *[argc + 1]{}; } else { // Retrieve sys.argv list from Python PyObject *argl = PySys_GetObject("argv"); @@ -57,7 +58,8 @@ bool PyROOT::RPyROOTApplication::CreateApplication(int ignoreCmdLineOpts) argc = static_cast(size); } - argv = new char *[argc]; + // Last argv must be null (see https://en.cppreference.com/cpp/language/main_function) + argv = new char *[argc + 1]{}; for (int i = 1; i < argc; ++i) { PyObject *item = PyList_GetItem(argl, i); From 60aab86dae63e183a7c54ae0ab4acde230a1bdc0 Mon Sep 17 00:00:00 2001 From: Stephan Hageboeck Date: Mon, 29 Jun 2026 13:43:13 +0200 Subject: [PATCH 5/7] [asan] Correct file name of the gcc asan runtime library. Fix #7968 --- cmake/modules/RootBuildOptions.cmake | 2 +- cmake/modules/SetUpLinux.cmake | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/cmake/modules/RootBuildOptions.cmake b/cmake/modules/RootBuildOptions.cmake index a365b15ee6b4f..0ca0070f40da7 100644 --- a/cmake/modules/RootBuildOptions.cmake +++ b/cmake/modules/RootBuildOptions.cmake @@ -191,7 +191,7 @@ option(rootbench "Build rootbench if rootbench exists in root or if it is a sibl option(roottest "Build roottest (implies testing=ON)" OFF) option(test_roofit_hs3testsuite "Setup and use the HS3 conformance test suite (requires network)" OFF) option(testing "Enable testing with CTest" OFF) -option(asan "Build ROOT with address sanitizer instrumentation (only GCC is currently supported)" OFF) +option(asan "Build ROOT with address sanitizer instrumentation (see core/sanitizer for details)" OFF) option(_wheel_build "ROOT is being packaged as a wheel, do not install .dist-info metadata" OFF) set(gcctoolchain "" CACHE PATH "Set path to GCC toolchain used to build llvm/clang") diff --git a/cmake/modules/SetUpLinux.cmake b/cmake/modules/SetUpLinux.cmake index 8f276487f3c47..3d6725d16e601 100644 --- a/cmake/modules/SetUpLinux.cmake +++ b/cmake/modules/SetUpLinux.cmake @@ -86,7 +86,10 @@ if(CMAKE_COMPILER_IS_GNUCXX) if(asan) # See also core/sanitizer/README.md for what's happening. - execute_process(COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.asan-x86_64.so OUTPUT_VARIABLE ASAN_RUNTIME_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=libasan.so OUTPUT_VARIABLE ASAN_RUNTIME_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT EXISTS "${ASAN_RUNTIME_LIBRARY}") + message(WARNING "'${ASAN_RUNTIME_LIBRARY}' does not seem to be a valid sanitizer library. ROOT's Python tests cannot be sanitised.") + endif() set(ASAN_EXTRA_CXX_FLAGS -fsanitize=address -fno-omit-frame-pointer -fsanitize-recover=address) set(ASAN_EXTRA_SHARED_LINKER_FLAGS "-fsanitize=address -z undefs") set(ASAN_EXTRA_EXE_LINKER_FLAGS "-fsanitize=address -z undefs -Wl,--undefined=__asan_default_options -Wl,--undefined=__lsan_default_options -Wl,--undefined=__lsan_default_suppressions") @@ -105,10 +108,14 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) if(asan) # See also core/sanitizer/README.md for what's happening. - execute_process(COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.asan-x86_64.so OUTPUT_VARIABLE ASAN_RUNTIME_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE) - # Since a while now, Clang installs libclang_rt.asan.so in an architecture dependent directory. - if(ASAN_RUNTIME_LIBRARY STREQUAL "libclang_rt.asan-x86_64.so") - execute_process(COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.asan.so OUTPUT_VARIABLE ASAN_RUNTIME_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE) + foreach(libname libclang_rt.asan-x86_64.so libclang_rt.asan.so) + execute_process(COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=${libname} OUTPUT_VARIABLE ASAN_RUNTIME_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE) + if(EXISTS ${ASAN_RUNTIME_LIBRARY}) + break() + endif() + endforeach() + if(NOT EXISTS "${ASAN_RUNTIME_LIBRARY}") + message(WARNING "'${ASAN_RUNTIME_LIBRARY}' does not seem to be a valid sanitizer library. ROOT's Python tests cannot be sanitized.") endif() set(ASAN_EXTRA_CXX_FLAGS -fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope) set(ASAN_EXTRA_SHARED_LINKER_FLAGS "-fsanitize=address -static-libsan -z undefs") From b1a18aaaf19fe48901b393d083a4cf053e45009c Mon Sep 17 00:00:00 2001 From: Stephan Hageboeck Date: Tue, 30 Jun 2026 14:21:35 +0200 Subject: [PATCH 6/7] [asan] Move address sanitizer flags into CMAKE_CXX_FLAGS. - Convert the flags from a list into a string. - Append the string to CMAKE_CXX_FLAGS and CMAKE_C_FLAGS. - Activate use-after-scope sanitisation also in gcc. In this way, the flags are observable at configure time, they propagate into builtins and tools like clad which are initialised with ROOT's CMAKE_CXX_FLAGS. This also allowed for removing two special cases for gtest and clad. --- CMakeLists.txt | 6 ++---- builtins/gtest/CMakeLists.txt | 1 - cmake/modules/RootConfiguration.cmake | 4 +--- cmake/modules/SetUpFreeBSD.cmake | 4 ++-- cmake/modules/SetUpLinux.cmake | 4 ++-- cmake/modules/SetUpMacOS.cmake | 2 +- cmake/modules/SetUpWindows.cmake | 2 +- interpreter/cling/tools/plugins/clad/CMakeLists.txt | 3 --- 8 files changed, 9 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7945ee63a3078..182a0225d77a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -297,10 +297,8 @@ if(asan) set(ASAN_EXTRA_LD_PRELOAD "${CMAKE_BINARY_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}ROOTSanitizerConfig${CMAKE_SHARED_LIBRARY_SUFFIX}:${ASAN_RUNTIME_LIBRARY}") endif() - foreach(item IN LISTS ASAN_EXTRA_CXX_FLAGS) - add_compile_options($<$:${item}>) - endforeach() - #add_link_options() not available in our CMake version: + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ASAN_EXTRA_CXX_FLAGS}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ASAN_EXTRA_CXX_FLAGS}") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${ASAN_EXTRA_SHARED_LINKER_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${ASAN_EXTRA_EXE_LINKER_FLAGS}") endif() diff --git a/builtins/gtest/CMakeLists.txt b/builtins/gtest/CMakeLists.txt index 2492a05cb0cdb..3db2993c80d2c 100644 --- a/builtins/gtest/CMakeLists.txt +++ b/builtins/gtest/CMakeLists.txt @@ -32,7 +32,6 @@ if(MSVC) if(NOT winrtdebug) set(gtestbuild "RelWithDebInfo") endif() - set(GTEST_CXX_FLAGS "${ROOT_EXTERNAL_CXX_FLAGS} ${ASAN_EXTRA_CXX_FLAGS}") endif() set(EXTRA_GTEST_OPTS -DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG} diff --git a/cmake/modules/RootConfiguration.cmake b/cmake/modules/RootConfiguration.cmake index d51f69846b7d2..7055457189e9d 100644 --- a/cmake/modules/RootConfiguration.cmake +++ b/cmake/modules/RootConfiguration.cmake @@ -713,9 +713,7 @@ else() # Needed by ACLIC, while in ROOT we are using everywhere C++ standard via CMake features that are requested to build target set(CMAKE_CXX_ACLIC_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION}") if(asan) - # Replace the semicolon with space so that the produced compiler invokation still makes sense - string (REPLACE ";" " " ASAN_EXTRA_CXX_FLAGS_STR "${ASAN_EXTRA_CXX_FLAGS}") - set(CMAKE_CXX_ACLIC_FLAGS "${CMAKE_CXX_ACLIC_FLAGS} ${ASAN_EXTRA_CXX_FLAGS_STR}") + set(CMAKE_CXX_ACLIC_FLAGS "${CMAKE_CXX_ACLIC_FLAGS} ${ASAN_EXTRA_CXX_FLAGS}") endif() if(ROOT_COMPILEDATA_IGNORE_BUILD_NODE_CHANGES) # Only set the compiledata parameter if the CMake variable is 'true' diff --git a/cmake/modules/SetUpFreeBSD.cmake b/cmake/modules/SetUpFreeBSD.cmake index ac368effac46e..53a061e6d5ce7 100644 --- a/cmake/modules/SetUpFreeBSD.cmake +++ b/cmake/modules/SetUpFreeBSD.cmake @@ -74,7 +74,7 @@ if(CMAKE_COMPILER_IS_GNUCXX) if(asan) # See also core/sanitizer/README.md for what's happening. execute_process(COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.asan-x86_64.so OUTPUT_VARIABLE ASAN_RUNTIME_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE) - set(ASAN_EXTRA_CXX_FLAGS -fsanitize=address -fno-omit-frame-pointer -fsanitize-recover=address) + set(ASAN_EXTRA_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fsanitize-recover=address") set(ASAN_EXTRA_SHARED_LINKER_FLAGS "-fsanitize=address -z undefs") set(ASAN_EXTRA_EXE_LINKER_FLAGS "-fsanitize=address -z undefs -Wl,--undefined=__asan_default_options -Wl,--undefined=__lsan_default_options -Wl,--undefined=__lsan_default_suppressions") endif() @@ -97,7 +97,7 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) if(ASAN_RUNTIME_LIBRARY STREQUAL "libclang_rt.asan-x86_64.so") execute_process(COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.asan.so OUTPUT_VARIABLE ASAN_RUNTIME_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE) endif() - set(ASAN_EXTRA_CXX_FLAGS -fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope) + set(ASAN_EXTRA_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope") set(ASAN_EXTRA_SHARED_LINKER_FLAGS "-fsanitize=address -static-libsan -z undefs") set(ASAN_EXTRA_EXE_LINKER_FLAGS "-fsanitize=address -static-libsan -z undefs -Wl,--undefined=__asan_default_options -Wl,--undefined=__lsan_default_options -Wl,--undefined=__lsan_default_suppressions") endif() diff --git a/cmake/modules/SetUpLinux.cmake b/cmake/modules/SetUpLinux.cmake index 3d6725d16e601..acb1e24c4b1f7 100644 --- a/cmake/modules/SetUpLinux.cmake +++ b/cmake/modules/SetUpLinux.cmake @@ -90,7 +90,7 @@ if(CMAKE_COMPILER_IS_GNUCXX) if(NOT EXISTS "${ASAN_RUNTIME_LIBRARY}") message(WARNING "'${ASAN_RUNTIME_LIBRARY}' does not seem to be a valid sanitizer library. ROOT's Python tests cannot be sanitised.") endif() - set(ASAN_EXTRA_CXX_FLAGS -fsanitize=address -fno-omit-frame-pointer -fsanitize-recover=address) + set(ASAN_EXTRA_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope") set(ASAN_EXTRA_SHARED_LINKER_FLAGS "-fsanitize=address -z undefs") set(ASAN_EXTRA_EXE_LINKER_FLAGS "-fsanitize=address -z undefs -Wl,--undefined=__asan_default_options -Wl,--undefined=__lsan_default_options -Wl,--undefined=__lsan_default_suppressions") endif() @@ -117,7 +117,7 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) if(NOT EXISTS "${ASAN_RUNTIME_LIBRARY}") message(WARNING "'${ASAN_RUNTIME_LIBRARY}' does not seem to be a valid sanitizer library. ROOT's Python tests cannot be sanitized.") endif() - set(ASAN_EXTRA_CXX_FLAGS -fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope) + set(ASAN_EXTRA_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope") set(ASAN_EXTRA_SHARED_LINKER_FLAGS "-fsanitize=address -static-libsan -z undefs") set(ASAN_EXTRA_EXE_LINKER_FLAGS "-fsanitize=address -static-libsan -z undefs -Wl,--undefined=__asan_default_options -Wl,--undefined=__lsan_default_options -Wl,--undefined=__lsan_default_suppressions") endif() diff --git a/cmake/modules/SetUpMacOS.cmake b/cmake/modules/SetUpMacOS.cmake index e69ed179b0b5d..73297065cd08e 100644 --- a/cmake/modules/SetUpMacOS.cmake +++ b/cmake/modules/SetUpMacOS.cmake @@ -63,7 +63,7 @@ if (CMAKE_SYSTEM_NAME MATCHES Darwin) if(asan) # See also core/sanitizer/README.md for what's happening. execute_process(COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.asan_osx_dynamic.dylib OUTPUT_VARIABLE ASAN_RUNTIME_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE) - set(ASAN_EXTRA_CXX_FLAGS -fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope) + set(ASAN_EXTRA_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope") set(ASAN_EXTRA_SHARED_LINKER_FLAGS "-fsanitize=address") set(ASAN_EXTRA_EXE_LINKER_FLAGS "-fsanitize=address -Wl,-U,__asan_default_options -Wl,-U,__lsan_default_options -Wl,-U,__lsan_default_suppressions") endif() diff --git a/cmake/modules/SetUpWindows.cmake b/cmake/modules/SetUpWindows.cmake index 43b5a71cf8942..e21aab51573d3 100644 --- a/cmake/modules/SetUpWindows.cmake +++ b/cmake/modules/SetUpWindows.cmake @@ -69,7 +69,7 @@ elseif(MSVC) endif() if(asan) - set(ASAN_EXTRA_CXX_FLAGS /fsanitize=address /wd5072) + set(ASAN_EXTRA_CXX_FLAGS "/fsanitize=address /wd5072") set(ASAN_EXTRA_SHARED_LINKER_FLAGS "/InferASanLibs /incremental:no /DEBUG") set(ASAN_EXTRA_EXE_LINKER_FLAGS "/InferASanLibs /incremental:no /DEBUG") endif() diff --git a/interpreter/cling/tools/plugins/clad/CMakeLists.txt b/interpreter/cling/tools/plugins/clad/CMakeLists.txt index d601c383d049a..cb2db29dad99d 100644 --- a/interpreter/cling/tools/plugins/clad/CMakeLists.txt +++ b/interpreter/cling/tools/plugins/clad/CMakeLists.txt @@ -20,9 +20,6 @@ if(MSVC AND NOT CMAKE_GENERATOR MATCHES Ninja) else() set(_clad_build_type Release) endif() - if(asan) - set(CLAD_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ASAN_EXTRA_CXX_FLAGS}") - endif() set(EXTRA_BUILD_ARGS --config ${_clad_build_type}) endif() if(NOT _clad_build_type STREQUAL "" AND NOT _clad_build_type STREQUAL ".") From c1897f9f34a8b7f8f4879e01377a7e1c39d4c11f Mon Sep 17 00:00:00 2001 From: Stephan Hageboeck Date: Wed, 1 Jul 2026 13:34:12 +0200 Subject: [PATCH 7/7] [asan] Sanitize all executables defined in ROOT's build system. Instead of sanitizing only a few hand-picked executables, recursively search all executables defined in the build system. Sanitize all that don't link to ROOTStaticSanitizerConfig. Since roottest is part of ROOT, several special cases could be removed. --- CMakeLists.txt | 22 ++++++++++++++++++++++ cmake/modules/RootMacros.cmake | 28 ++++++++-------------------- core/sanitizer/CMakeLists.txt | 7 ------- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 182a0225d77a7..40c88e00050b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -729,6 +729,28 @@ if(LLVM_LINKER_IS_MOLD) endif() endif() +if(asan) + # Now sanitize all executables that are not created with ROOT_EXECUTABLE() + # See core/sanitizer for details + function(sanitize_all_targets DIR_TO_SEARCH) + get_property(subdirs DIRECTORY "${DIR_TO_SEARCH}" PROPERTY SUBDIRECTORIES) + foreach(subdir IN LISTS subdirs) + sanitize_all_targets("${subdir}") + endforeach() + + get_directory_property(directory_targets DIRECTORY "${DIR_TO_SEARCH}" BUILDSYSTEM_TARGETS) + foreach(target IN LISTS directory_targets) + get_target_property(target_type ${target} TYPE) + get_target_property(target_libs ${target} LINK_LIBRARIES) + if(target_type STREQUAL EXECUTABLE AND NOT target STREQUAL ROOTStaticSanitizerConfig AND NOT target_libs MATCHES "ROOTStaticSanitizerConfig") + target_link_libraries(${target} PRIVATE ROOTStaticSanitizerConfig) + message(VERBOSE "Adding sanitizer library to ${target} (not created via a ROOT macro): ${target_libs}") + endif() + endforeach() + endfunction() + sanitize_all_targets(${CMAKE_CURRENT_SOURCE_DIR}) +endif() + cmake_host_system_information(RESULT PROCESSOR QUERY PROCESSOR_DESCRIPTION) message(STATUS "ROOT Configuration \n diff --git a/cmake/modules/RootMacros.cmake b/cmake/modules/RootMacros.cmake index 567aaf8bc3a00..6163a9ce814cb 100644 --- a/cmake/modules/RootMacros.cmake +++ b/cmake/modules/RootMacros.cmake @@ -1477,9 +1477,9 @@ function(ROOT_EXECUTABLE executable) endif() endforeach() endif() - if(TARGET ROOT::ROOTStaticSanitizerConfig) + if(TARGET ROOTStaticSanitizerConfig) set_property(TARGET ${executable} - APPEND PROPERTY LINK_LIBRARIES ROOT::ROOTStaticSanitizerConfig) + APPEND PROPERTY LINK_LIBRARIES ROOTStaticSanitizerConfig) endif() #----Installation details------------------------------------------------------ if(NOT ARG_NOINSTALL AND CMAKE_RUNTIME_OUTPUT_DIRECTORY) @@ -2872,19 +2872,13 @@ macro(ROOTTEST_GENERATE_EXECUTABLE executable) set(libraries ${libraries} ${library}) endif() endforeach() - target_link_libraries(${executable} ${libraries}) + target_link_libraries(${executable} PUBLIC ${libraries}) else() - target_link_libraries(${executable} ${ARG_LIBRARIES}) + target_link_libraries(${executable} PUBLIC ${ARG_LIBRARIES}) endif() endif() - if(MSVC AND DEFINED ROOT_SOURCE_DIR) - if(TARGET ROOTStaticSanitizerConfig) - target_link_libraries(${executable} ROOTStaticSanitizerConfig) - endif() - else() - if(TARGET ROOT::ROOTStaticSanitizerConfig) - target_link_libraries(${executable} ROOT::ROOTStaticSanitizerConfig) - endif() + if(TARGET ROOTStaticSanitizerConfig) + target_link_libraries(${executable} PRIVATE ROOTStaticSanitizerConfig) endif() if(ARG_COMPILE_FLAGS) @@ -3493,14 +3487,8 @@ function(ROOTTEST_ADD_UNITTEST_DIR) target_link_libraries(${binary} PRIVATE GTest::gtest GTest::gtest_main ${libraries}) set_property(TARGET ${binary} PROPERTY BUILD_WITH_INSTALL_RPATH OFF) # will never be installed anyway - if(MSVC AND DEFINED ROOT_SOURCE_DIR) - if(TARGET ROOTStaticSanitizerConfig) - target_link_libraries(${binary} ROOTStaticSanitizerConfig) - endif() - else() - if(TARGET ROOT::ROOTStaticSanitizerConfig) - target_link_libraries(${binary} PRIVATE ROOT::ROOTStaticSanitizerConfig) - endif() + if(TARGET ROOTStaticSanitizerConfig) + target_link_libraries(${binary} PRIVATE ROOTStaticSanitizerConfig) endif() # Mark the test as known to fail. diff --git a/core/sanitizer/CMakeLists.txt b/core/sanitizer/CMakeLists.txt index 6c79d72e6206b..aa8481f37e486 100644 --- a/core/sanitizer/CMakeLists.txt +++ b/core/sanitizer/CMakeLists.txt @@ -18,10 +18,3 @@ target_link_libraries(${library} INTERFACE ${ASAN_EXTRA_EXE_LINKER_FLAGS}) # Make it visible to the outside to sanitize e.g. roottest executables set_property(GLOBAL APPEND PROPERTY ROOT_EXPORTED_TARGETS ${library}) add_library(ROOT::${library} ALIAS ${library}) - -# Now sanitize executables that are not created with ROOT_EXECUTABLE(): -foreach(target llvm-min-tblgen llvm-tblgen clang-tblgen cppinterop-tblgen) - if(TARGET ${target}) - target_link_libraries(${target} PRIVATE ${library}) - endif() -endforeach()