aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang-plugin/CMakeLists.txt14
-rw-r--r--cmake/Sanitizer.cmake7
2 files changed, 11 insertions, 10 deletions
diff --git a/clang-plugin/CMakeLists.txt b/clang-plugin/CMakeLists.txt
index dc5de4717..80fa54eed 100644
--- a/clang-plugin/CMakeLists.txt
+++ b/clang-plugin/CMakeLists.txt
@@ -1,7 +1,7 @@
IF (ENABLE_CLANG_PLUGIN MATCHES "ON")
# Clang plugin for static analysis
- PROJECT(RspamdClangPlugin)
+ PROJECT(RspamdClangPlugin CXX)
if (NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
MESSAGE(FATAL_ERROR "Cannot build clang plugin when compiler is not clang")
endif ()
@@ -25,16 +25,16 @@ IF (ENABLE_CLANG_PLUGIN MATCHES "ON")
SET(CLANGPLUGINSRC plugin.cc printf_check.cc)
ADD_LIBRARY(rspamd-clang SHARED ${CLANGPLUGINSRC})
- SET_TARGET_PROPERTIES(rspamd-clang PROPERTIES
- COMPILE_FLAGS "-O2 -Wall -Wextra -Wno-unused-parameter -Werror"
- LINKER_LANGUAGE CXX)
- IF(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
- set_property(TARGET rspamd-clang APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--no-undefined -Wl,--as-needed")
+ IF (SANITIZE)
+ set (CMAKE_C_FLAGS "")
+ set (CMAKE_CXX_FLAGS "")
+ set (CMAKE_EXE_LINKER_FLAGS "")
ENDIF()
+
find_library(found_LLVM LLVM HINTS ${LLVM_LIBRARY_DIRS})
if(found_LLVM)
- target_link_libraries(rspamd-clang PRIVATE LLVM)
+ target_link_libraries(rspamd-clang PRIVATE ${LLVM})
else()
# XXX not tested yet
llvm_map_components_to_libnames(llvm_libs support core)
diff --git a/cmake/Sanitizer.cmake b/cmake/Sanitizer.cmake
index f955024e6..4b4df9fae 100644
--- a/cmake/Sanitizer.cmake
+++ b/cmake/Sanitizer.cmake
@@ -16,10 +16,10 @@ if (SANITIZE)
if (SANITIZE STREQUAL "address")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SAN_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SAN_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope")
+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope")
if (COMPILER_GCC)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libasan")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libasan")
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libasan")
endif ()
@@ -28,21 +28,22 @@ if (SANITIZE)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SAN_FLAGS} ${MSAN_FLAGS}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SAN_FLAGS} ${MSAN_FLAGS}")
+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=memory")
if (COMPILER_GCC)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libmsan")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libmsan")
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=memory")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libmsan")
endif ()
elseif (SANITIZE STREQUAL "undefined")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SAN_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SAN_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all")
+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined")
+
if (COMPILER_GCC)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libubsan")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libubsan")
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libubsan")
endif ()