]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix clang plugin functions on OSX
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 22 Oct 2019 10:21:34 +0000 (11:21 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 22 Oct 2019 10:21:34 +0000 (11:21 +0100)
clang-plugin/CMakeLists.txt
clang-plugin/printf_check.cc
src/CMakeLists.txt
src/libserver/task.c

index 3a0b8ab8b794d6df0b91531a765f0214873bc388..dc5de47178752d5e4f8472ce7ae3817c6157e2e6 100644 (file)
@@ -1,6 +1,5 @@
 
 IF (ENABLE_CLANG_PLUGIN MATCHES "ON")
-    cmake_minimum_required(VERSION 3.9)
     # Clang plugin for static analysis
     PROJECT(RspamdClangPlugin)
     if (NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
@@ -14,6 +13,13 @@ IF (ENABLE_CLANG_PLUGIN MATCHES "ON")
     ADD_DEFINITIONS(${LLVM_DEFINITIONS})
 
     find_package(Clang REQUIRED)
+
+    set(clang_libs
+            clangAST
+            clangBasic
+            clangFrontend)
+
+    message(STATUS "Found LibClang in: ${CLANG_INSTALL_PREFIX}")
     include_directories(${CLANG_INCLUDE_DIRS})
 
     SET(CLANGPLUGINSRC plugin.cc printf_check.cc)
@@ -22,7 +28,9 @@ IF (ENABLE_CLANG_PLUGIN MATCHES "ON")
     SET_TARGET_PROPERTIES(rspamd-clang PROPERTIES
             COMPILE_FLAGS "-O2 -Wall -Wextra -Wno-unused-parameter -Werror"
             LINKER_LANGUAGE CXX)
-       set_property(TARGET rspamd-clang APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--no-undefined -Wl,--as-needed")
+    IF(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+           set_property(TARGET rspamd-clang APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--no-undefined -Wl,--as-needed")
+    ENDIF()
 
     find_library(found_LLVM LLVM HINTS ${LLVM_LIBRARY_DIRS})
     if(found_LLVM)
@@ -33,9 +41,5 @@ IF (ENABLE_CLANG_PLUGIN MATCHES "ON")
         target_link_libraries(rspamd-clang PRIVATE ${llvm_libs})
     endif()
 
-    set(clang_libs
-        clangAST
-        clangBasic
-        clangFrontend)
     target_link_libraries(rspamd-clang PRIVATE ${clang_libs})
 ENDIF()
index 35df5952df00de9433fbc33bd8e292e32604fe67..37042d47abab2f235ce154c1de14b6d1ec756d63 100644 (file)
@@ -590,11 +590,22 @@ namespace rspamd {
        size_arg_handler (const Expr *arg, struct PrintfArgChecker *ctx)
        {
                if (sizeof (size_t) == sizeof (long)) {
-                       return check_builtin_type (arg,
-                                       ctx,
-                                       {BuiltinType::Kind::ULong,
-                                        BuiltinType::Kind::Long},
-                                       "%z");
+                       if (sizeof (long long) == sizeof (long)) {
+                               return check_builtin_type (arg,
+                                               ctx,
+                                               {BuiltinType::Kind::ULong,
+                                                BuiltinType::Kind::Long,
+                                                BuiltinType::Kind::LongLong,
+                                                BuiltinType::Kind::ULongLong},
+                                               "%z");
+                       }
+                       else {
+                               return check_builtin_type (arg,
+                                               ctx,
+                                               {BuiltinType::Kind::ULong,
+                                                BuiltinType::Kind::Long},
+                                               "%z");
+                       }
                }
                else if (sizeof (size_t) == sizeof (int)) {
                        return check_builtin_type (arg,
index 797ae2074c1b8766e84df1131f08f064f3ce3260..1c03b1239ee18e5ecba5a2df8f67bbe9828bdc3e 100644 (file)
@@ -63,7 +63,7 @@ ENDMACRO(AddModules MLIST WLIST)
 # Rspamd core components
 IF (ENABLE_CLANG_PLUGIN MATCHES "ON")
        SET(CMAKE_C_FLAGS
-                       "${CMAKE_C_FLAGS} -Xclang -load -Xclang ${CMAKE_CURRENT_BINARY_DIR}/../clang-plugin/librspamd-clang.so -Xclang -add-plugin -Xclang rspamd-ast")
+                       "${CMAKE_C_FLAGS} -Xclang -load -Xclang ${CMAKE_CURRENT_BINARY_DIR}/../clang-plugin/librspamd-clang${CMAKE_SHARED_LIBRARY_SUFFIX} -Xclang -add-plugin -Xclang rspamd-ast")
        IF(CLANG_EXTRA_PLUGINS_LIBS)
                FOREACH(_lib ${CLANG_EXTRA_PLUGINS_LIBS})
                        SET(CMAKE_C_FLAGS
index 884489821620dfc77ea0d89cba07eca4522862c3..9e87088a2dfab2e177a272ac73a104add4e320e7 100644 (file)
@@ -395,7 +395,7 @@ rspamd_task_load_message (struct rspamd_task *task,
 
                        if (offset > (gulong)st.st_size) {
                                msg_err_task ("invalid offset %ul (%ul available) for shm "
-                                                         "segment %s", offset, st.st_size, fp);
+                                                         "segment %s", offset, (gulong)st.st_size, fp);
                                munmap (map, st.st_size);
                                close (fd);
 
@@ -412,7 +412,7 @@ rspamd_task_load_message (struct rspamd_task *task,
 
                        if (shmem_size > (gulong)st.st_size) {
                                msg_err_task ("invalid length %ul (%ul available) for %s "
-                                                         "segment %s", shmem_size, st.st_size, ft, fp);
+                                                         "segment %s", shmem_size, (gulong)st.st_size, ft, fp);
                                munmap (map, st.st_size);
                                close (fd);