diff -Nru binpac-0.54/CHANGES binpac-0.55/CHANGES --- binpac-0.54/CHANGES 2019-08-08 18:04:34.000000000 +0000 +++ binpac-0.55/CHANGES 2020-02-08 19:30:07.000000000 +0000 @@ -1,4 +1,32 @@ +0.55 | 2020-02-05 21:28:26 -0800 + + * Release 0.55 + +0.54-15 | 2020-01-03 09:57:44 -0700 + + * Disable LeakSanitizer + + https://github.com/zeek/zeek/issues/699 (Jon Siwek, Corelight) + +0.54-12 | 2019-11-15 17:45:29 -0800 + + * Fix Zeek build for multi-config CMake generators (e.g. Xcode) (Jon Siwek, Corelight) + +0.54-11 | 2019-11-06 22:26:54 -0800 + + * Fix shared library versioning to agree with OpenBSD expectations (Jon Siwek, Corelight) + + OpenBSD shared library names are like "libfoo.so.major.minor" and + binpac was previously letting the post-release number into the name + like "libbinpac.so.0.54-7", which isn't compatible with that scheme. + + Related to https://github.com/zeek/zeek/issues/649 + +0.54-7 | 2019-10-28 17:59:21 -0700 + + * Move CMake project() after cmake_minimum_required() (Jon Siwek, Corelight) + 0.54 | 2019-07-03 02:41:46 +0000 * Release 0.54. diff -Nru binpac-0.54/cmake/BifCl.cmake binpac-0.55/cmake/BifCl.cmake --- binpac-0.54/cmake/BifCl.cmake 2019-08-08 18:04:34.000000000 +0000 +++ binpac-0.55/cmake/BifCl.cmake 2020-02-08 19:30:07.000000000 +0000 @@ -35,6 +35,9 @@ set(BIF_OUTPUT_BRO ${CMAKE_BINARY_DIR}/scripts/base/bif/${bifInputBasename}.zeek) set(bro_BASE_BIF_SCRIPTS ${bro_BASE_BIF_SCRIPTS} ${BIF_OUTPUT_BRO} CACHE INTERNAL "Zeek script stubs for BIFs in base distribution of Zeek" FORCE) # Propogate to top-level + # Do this here so that all of the necessary files for each individual BIF get added to clang-tidy + add_clang_tidy_files(${CMAKE_CURRENT_BINARY_DIR}/${bifInputBasename}.func_def) + elseif ( "${ARGV1}" STREQUAL "plugin" ) set(plugin_name ${ARGV2}) set(plugin_name_canon ${ARGV3}) @@ -57,6 +60,11 @@ ${bifInputBasename}.register.cc) endif() + # Do this here so that all of the necessary files for each individual BIF get added to clang-tidy + foreach (bif_cc_file ${BIF_OUTPUT_CC}) + add_clang_tidy_files(${CMAKE_CURRENT_BINARY_DIR}/${bif_cc_file}) + endforeach(bif_cc_file) + set(BIF_OUTPUT_H ${bifInputBasename}.h) if ( NOT ZEEK_PLUGIN_BUILD_DYNAMIC ) @@ -78,6 +86,11 @@ set(BIF_OUTPUT_CC ${bifInputBasename}.cc) set(BIF_OUTPUT_H ${bifInputBasename}.h) + # Do this here so that all of the necessary files for each individual BIF get added to clang-tidy + foreach (bif_cc_file ${BIF_OUTPUT_CC}) + add_clang_tidy_files(${CMAKE_CURRENT_BINARY_DIR}/${bif_cc_file}) + endforeach(bif_cc_file) + # In order be able to run Zeek from the build directory, the # generated Zeek script needs to be inside a directory tree # named the same way it will be referenced from an @load. diff -Nru binpac-0.54/cmake/BinPAC.cmake binpac-0.55/cmake/BinPAC.cmake --- binpac-0.54/cmake/BinPAC.cmake 2019-08-08 18:04:34.000000000 +0000 +++ binpac-0.55/cmake/BinPAC.cmake 2020-02-08 19:30:07.000000000 +0000 @@ -44,6 +44,8 @@ set(pacOutputs ${BINPAC_OUTPUT_H} ${BINPAC_OUTPUT_CC}) set_property(SOURCE ${BINPAC_OUTPUT_CC} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-tautological-compare") + add_clang_tidy_files(${CMAKE_CURRENT_BINARY_DIR}/${basename}_pac.cc) + set(target "pac-${CMAKE_CURRENT_BINARY_DIR}/${pacFile}") string(REGEX REPLACE "${CMAKE_BINARY_DIR}/src/" "" target "${target}") diff -Nru binpac-0.54/cmake/FindBroker.cmake binpac-0.55/cmake/FindBroker.cmake --- binpac-0.54/cmake/FindBroker.cmake 2019-08-08 18:04:34.000000000 +0000 +++ binpac-0.55/cmake/FindBroker.cmake 2020-02-08 19:30:07.000000000 +0000 @@ -17,20 +17,42 @@ # BROKER_LIBRARY The broker library # BROKER_INCLUDE_DIR The broker headers -find_path(BROKER_ROOT_DIR - NAMES include/broker/broker.hh -) +if(NOT BROKER_ROOT_DIR) + find_path(BROKER_ROOT_DIR + NAMES include/broker/broker.hh + ) + set(header_hints + "${BROKER_ROOT_DIR}/include" + ) +else() + set(header_hints + "${BROKER_ROOT_DIR}/include" + "${BROKER_ROOT_DIR}/../include" + "${BROKER_ROOT_DIR}/../../include" + ) +endif() find_library(BROKER_LIBRARY NAMES broker HINTS ${BROKER_ROOT_DIR}/lib ) -find_path(BROKER_INCLUDE_DIR +find_path(broker_hh_dir NAMES broker/broker.hh - HINTS ${BROKER_ROOT_DIR}/include + HINTS ${header_hints} +) + +find_path(config_hh_dir + NAMES broker/config.hh + HINTS ${header_hints} ) +if("${broker_hh_dir}" STREQUAL "${config_hh_dir}") + set(BROKER_INCLUDE_DIR "${broker_hh_dir}") +else() + set(BROKER_INCLUDE_DIR "${broker_hh_dir}" "${config_hh_dir}") +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Broker DEFAULT_MSG BROKER_LIBRARY diff -Nru binpac-0.54/cmake/FindCAF.cmake binpac-0.55/cmake/FindCAF.cmake --- binpac-0.54/cmake/FindCAF.cmake 2019-08-08 18:04:34.000000000 +0000 +++ binpac-0.55/cmake/FindCAF.cmake 2020-02-08 19:30:07.000000000 +0000 @@ -1,8 +1,8 @@ -# Try to find CAF headers and library. +# Try to find CAF headers and libraries. # # Use this module as follows: # -# find_package(CAF) +# find_package(CAF [COMPONENTS *] [REQUIRED]) # # Variables used by this module (they can change the default behaviour and need # to be set before calling find_package): @@ -13,10 +13,13 @@ # Variables defined by this module: # # CAF_FOUND System has CAF headers and library +# CAF_VERSION Found CAF release number # CAF_LIBRARIES List of library files for all components # CAF_INCLUDE_DIRS List of include paths for all components -# CAF_LIBRARY_$C Library file for component $C -# CAF_INCLUDE_DIR_$C Include path for component $C + +if(CAF_FIND_COMPONENTS STREQUAL "") + message(FATAL_ERROR "FindCAF requires at least one COMPONENT.") +endif() # iterate over user-defined components foreach (comp ${CAF_FIND_COMPONENTS}) @@ -32,7 +35,9 @@ if (CAF_ROOT_DIR) set(header_hints "${CAF_ROOT_DIR}/include" - "${CAF_ROOT_DIR}/../libcaf_${comp}") + "${CAF_ROOT_DIR}/libcaf_${comp}" + "${CAF_ROOT_DIR}/../libcaf_${comp}" + "${CAF_ROOT_DIR}/../../libcaf_${comp}") endif () find_path(CAF_INCLUDE_DIR_${UPPERCOMP} NAMES @@ -43,22 +48,34 @@ /usr/local/include /opt/local/include /sw/include - ${CMAKE_INSTALL_PREFIX}/include) + ${CMAKE_INSTALL_PREFIX}/include + ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}) mark_as_advanced(CAF_INCLUDE_DIR_${UPPERCOMP}) if (NOT "${CAF_INCLUDE_DIR_${UPPERCOMP}}" STREQUAL "CAF_INCLUDE_DIR_${UPPERCOMP}-NOTFOUND") - # mark as found (set back to false in case library cannot be found) + # mark as found (set back to false when missing library or build header) set(CAF_${comp}_FOUND true) - # add to CAF_INCLUDE_DIRS only if path isn't already set - set(duplicate false) - foreach (p ${CAF_INCLUDE_DIRS}) - if (${p} STREQUAL ${CAF_INCLUDE_DIR_${UPPERCOMP}}) - set(duplicate true) - endif () - endforeach () - if (NOT duplicate) - set(CAF_INCLUDE_DIRS ${CAF_INCLUDE_DIRS} ${CAF_INCLUDE_DIR_${UPPERCOMP}}) + # check for CMake-generated build header for the core component + if ("${comp}" STREQUAL "core") + find_path(caf_build_header_path + NAMES + caf/detail/build_config.hpp + HINTS + ${header_hints} + /usr/include + /usr/local/include + /opt/local/include + /sw/include + ${CMAKE_INSTALL_PREFIX}/include + ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}) + if ("${caf_build_header_path}" STREQUAL "caf_build_header_path-NOTFOUND") + message(WARNING "Found all.hpp for CAF core, but not build_config.hpp") + set(CAF_${comp}_FOUND false) + else() + list(APPEND CAF_INCLUDE_DIRS "${caf_build_header_path}") + endif() endif() + list(APPEND CAF_INCLUDE_DIRS "${CAF_INCLUDE_DIR_${UPPERCOMP}}") # look for (.dll|.so|.dylib) file, again giving hints for non-installed CAFs # skip probe_event as it is header only if (NOT ${comp} STREQUAL "probe_event" AND NOT ${comp} STREQUAL "test") @@ -75,9 +92,12 @@ /usr/local/lib /opt/local/lib /sw/lib - ${CMAKE_INSTALL_PREFIX}/lib) + ${CMAKE_INSTALL_PREFIX}/lib + ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} + ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_BUILD_TYPE}) mark_as_advanced(CAF_LIBRARY_${UPPERCOMP}) - if ("${CAF_LIBRARY_${UPPERCOMP}}" STREQUAL "CAF_LIBRARY-NOTFOUND") + if ("${CAF_LIBRARY_${UPPERCOMP}}" + STREQUAL "CAF_LIBRARY_${UPPERCOMP}-NOTFOUND") set(CAF_${comp}_FOUND false) else () set(CAF_LIBRARIES ${CAF_LIBRARIES} ${CAF_LIBRARY_${UPPERCOMP}}) @@ -86,14 +106,39 @@ endif () endforeach () +if (DEFINED CAF_INCLUDE_DIRS) + list(REMOVE_DUPLICATES CAF_INCLUDE_DIRS) +endif() + + +if (NOT CAF_INCLUDE_DIR_CORE STREQUAL "CAF_INCLUDE_DIR_CORE-NOTFOUND") + # read content of config.hpp + file(READ "${CAF_INCLUDE_DIR_CORE}/caf/config.hpp" CONFIG_HPP) + # get line containing the version + string(REGEX MATCH "#define CAF_VERSION [0-9]+" VERSION_LINE "${CONFIG_HPP}") + # extract version number from line + string(REGEX MATCH "[0-9]+" VERSION_INT "${VERSION_LINE}") + # calculate major, minor, and patch version + math(EXPR CAF_VERSION_MAJOR "${VERSION_INT} / 10000") + math(EXPR CAF_VERSION_MINOR "( ${VERSION_INT} / 100) % 100") + math(EXPR CAF_VERSION_PATCH "${VERSION_INT} % 100") + # create full version string + set(CAF_VERSION "${CAF_VERSION_MAJOR}.${CAF_VERSION_MINOR}.${CAF_VERSION_PATCH}") + if (NOT CAF_VERSION) + unset(CAF_VERSION) + message(WARNING "Unable to determine CAF version") + endif () +endif () + # let CMake check whether all requested components have been found include(FindPackageHandleStandardArgs) find_package_handle_standard_args(CAF FOUND_VAR CAF_FOUND - REQUIRED_VARS CAF_LIBRARIES CAF_INCLUDE_DIRS + REQUIRED_VARS CAF_VERSION CAF_LIBRARIES CAF_INCLUDE_DIRS HANDLE_COMPONENTS) # final step to tell CMake we're done mark_as_advanced(CAF_ROOT_DIR + CAF_VERSION CAF_LIBRARIES CAF_INCLUDE_DIRS) diff -Nru binpac-0.54/cmake/FindClangTidy.cmake binpac-0.55/cmake/FindClangTidy.cmake --- binpac-0.54/cmake/FindClangTidy.cmake 1970-01-01 00:00:00.000000000 +0000 +++ binpac-0.55/cmake/FindClangTidy.cmake 2020-02-08 19:30:07.000000000 +0000 @@ -0,0 +1,52 @@ +# Common functions to use clang-tidy. This requires you to have clang-tidy in your path. If you also +# have run-clang-tidy.py in your path, it will attempt to use that to run clang-tidy in parallel. + +######################################################################## +# If this hasn't been initialized yet, find the program and then create a global property +# to store the list of sources in. +if (NOT CLANG_TIDY) + find_program(CLANG_TIDY NAMES clang-tidy) + find_program(RUN_CLANG_TIDY NAMES run-clang-tidy.py) + + if (CLANG_TIDY) + define_property(GLOBAL PROPERTY TIDY_SRCS + BRIEF_DOCS "Global list of sources for clang-tidy" + FULL_DOCS "Global list of sources for clang-tidy") + set_property(GLOBAL PROPERTY TIDY_SRCS "") + endif() +endif() + +######################################################################## +# Adds a list of files to the global list of files that will be checked. +function(add_clang_tidy_files) + if (CLANG_TIDY) + foreach(f ${ARGV}) + if (IS_ABSOLUTE ${f}) + set_property(GLOBAL APPEND PROPERTY TIDY_SRCS "${f}") + else() + set_property(GLOBAL APPEND PROPERTY TIDY_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/${f}") + endif() + endforeach(f) + endif() +endfunction() + +######################################################################## +# Creates the final target using the global list of files. +function(create_clang_tidy_target) + if (CLANG_TIDY) + get_property(final_tidy_srcs GLOBAL PROPERTY TIDY_SRCS) + list(REMOVE_DUPLICATES final_tidy_srcs) + + if (RUN_CLANG_TIDY) + add_custom_target(clang-tidy + COMMAND ${RUN_CLANG_TIDY} -p ${CMAKE_BINARY_DIR} -clang-tidy-binary ${CLANG_TIDY} -j 4 -export-fixes ${CMAKE_BINARY_DIR}/clang-tidy.yaml ${final_tidy_srcs} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + else() + add_custom_target(clang-tidy + COMMAND ${CLANG_TIDY} -p ${CMAKE_BINARY_DIR} ${final_tidy_srcs} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + endif() + endif() +endfunction() diff -Nru binpac-0.54/cmake/FindKqueue.cmake binpac-0.55/cmake/FindKqueue.cmake --- binpac-0.54/cmake/FindKqueue.cmake 1970-01-01 00:00:00.000000000 +0000 +++ binpac-0.55/cmake/FindKqueue.cmake 2020-02-08 19:30:07.000000000 +0000 @@ -0,0 +1,147 @@ +include(CheckFunctionExists) + +# First check whether the system has kqueue built-in. Prefer that over everything else. +check_function_exists(kqueue HAVE_KQUEUE) + +if ( NOT HAVE_KQUEUE ) + + # If the user passed in a path for libkqueue, see if we can find a copy of it there. + # If they didn't pass one, build our local copy of it. + if ( LIBKQUEUE_ROOT_DIR ) + + find_path(LIBKQUEUE_ROOT_DIR + NAMES "include/sys/event.h") + + # Prefer linking statically but look for a shared library version too. + find_library(LIBKQUEUE_LIBRARIES + NAMES libkqueue.a libkqueue.so + HINTS ${LIBKQUEUE_ROOT_DIR}/lib) + + find_path(LIBKQUEUE_INCLUDE_DIRS + NAMES "sys/event.h" + HINTS ${LIBKQUEUE_ROOT_DIR}/include/kqueue) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(LIBKQUEUE DEFAULT_MSG + LIBKQUEUE_LIBRARIES + LIBKQUEUE_INCLUDE_DIRS + ) + + mark_as_advanced( + LIBKQUEUE_ROOT_DIR + LIBKQUEUE_LIBRARIES + LIBKQUEUE_INCLUDE_DIRS + ) + + set(HAVE_KQUEUE true) + set(zeekdeps ${zeekdeps} ${LIBKQUEUE_LIBRARIES}) + include_directories(BEFORE ${LIBKQUEUE_INCLUDE_DIRS}) + + else() + + include(ExternalProject) + set(kqueue_src "${CMAKE_CURRENT_SOURCE_DIR}/src/3rdparty/libkqueue") + set(kqueue_ep "${CMAKE_CURRENT_BINARY_DIR}/libkqueue-ep") + set(kqueue_build "${CMAKE_CURRENT_BINARY_DIR}/libkqueue-build") + set(kqueue_static "${kqueue_build}/libkqueue${CMAKE_STATIC_LIBRARY_SUFFIX}") + + if ( ${CMAKE_VERSION} VERSION_LESS "3.2.0" ) + # Build byproducts is just required by the Ninja generator + # though it's not available before CMake 3.2 ... + if ( ${CMAKE_GENERATOR} STREQUAL Ninja ) + message(FATAL_ERROR "Ninja generator requires CMake >= 3.2") + endif () + + set(build_byproducts_arg) + else () + set(build_byproducts_arg BUILD_BYPRODUCTS ${kqueue_static}) + endif () + + ExternalProject_Add(project_kqueue + PREFIX "${kqueue_ep}" + BINARY_DIR "${kqueue_build}" + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ${build_byproducts_arg} + ) + + if ( ${CMAKE_VERSION} VERSION_LESS "3.4.0" ) + set(use_terminal_arg) + else () + set(use_terminal_arg USES_TERMINAL 1) + endif () + + ExternalProject_Add_Step(project_kqueue project_kqueue_build_step + COMMAND ${CMAKE_MAKE_PROGRAM} + COMMENT "Building libkqueue" + WORKING_DIRECTORY ${kqueue_build} + ALWAYS 1 + ${use_terminal_arg} + ) + + if ( CMAKE_TOOLCHAIN_FILE ) + set(toolchain_arg -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + else () + set(toolchain_arg) + endif () + + if ( CMAKE_C_COMPILER_LAUNCHER ) + set(cmake_c_compiler_launcher_arg + -DCMAKE_C_COMPILER_LAUNCHER:path=${CMAKE_C_COMPILER_LAUNCHER}) + else () + set(cmake_c_compiler_launcher_arg) + endif () + + if ( CMAKE_CXX_COMPILER_LAUNCHER ) + set(cmake_cxx_compiler_launcher_arg + -DCMAKE_CXX_COMPILER_LAUNCHER:path=${CMAKE_CXX_COMPILER_LAUNCHER}) + else () + set(cmake_cxx_compiler_launcher_arg) + endif () + + execute_process( + COMMAND + ${CMAKE_COMMAND} + -G${CMAKE_GENERATOR} + ${toolchain_arg} + ${cmake_c_compiler_launcher_arg} + ${cmake_cxx_compiler_launcher_arg} + -DCMAKE_BUILD_TYPE:string=${CMAKE_BUILD_TYPE} + -DSTATIC_KQUEUE=yes + ${kqueue_src} + WORKING_DIRECTORY ${kqueue_build} + RESULT_VARIABLE kqueue_cmake_result + ERROR_VARIABLE KQUEUE_CMAKE_OUTPUT + OUTPUT_VARIABLE KQUEUE_CMAKE_OUTPUT + ERROR_STRIP_TRAILING_WHITESPACE + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + message("\n********** Begin libkqueue External Project CMake Output ************") + message("\n${KQUEUE_CMAKE_OUTPUT}") + message("\n*********** End libkqueue External Project CMake Output *************") + message("\n") + + if (kqueue_cmake_result) + message(FATAL_ERROR "libkqueue CMake configuration failed") + endif () + + add_library(libkqueue_a STATIC IMPORTED) + set_property(TARGET libkqueue_a PROPERTY IMPORTED_LOCATION ${kqueue_static}) + add_dependencies(libkqueue_a project_kqueue) + + set(HAVE_KQUEUE true) + set(LIBKQUEUE_LIBRARIES libkqueue_a CACHE STRING "libkqueue libs" FORCE) + set(LIBKQUEUE_INCLUDE_DIRS "${kqueue_src}/include" CACHE STRING "libkqueue includes" FORCE) + + include_directories(BEFORE ${LIBKQUEUE_INCLUDE_DIRS}) + set(zeekdeps ${zeekdeps} ${LIBKQUEUE_LIBRARIES}) + + endif() +endif() + +if ( NOT HAVE_KQUEUE ) + message(FATAL_ERROR "Failed to find a working version of kqueue.") +endif() diff -Nru binpac-0.54/cmake/PCAPTests.cmake binpac-0.55/cmake/PCAPTests.cmake --- binpac-0.54/cmake/PCAPTests.cmake 2019-08-08 18:04:34.000000000 +0000 +++ binpac-0.55/cmake/PCAPTests.cmake 2020-02-08 19:30:07.000000000 +0000 @@ -74,5 +74,10 @@ set(DLT_PPP_SERIAL 50) endif () +check_symbol_exists(DLT_NFLOG pcap.h HAVE_DLT_NFLOG) +if (NOT HAVE_DLT_NFLOG) + set(DLT_NFLOG 239) +endif () + set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_LIBRARIES) diff -Nru binpac-0.54/cmake/RequireCXX17.cmake binpac-0.55/cmake/RequireCXX17.cmake --- binpac-0.54/cmake/RequireCXX17.cmake 1970-01-01 00:00:00.000000000 +0000 +++ binpac-0.55/cmake/RequireCXX17.cmake 2020-02-08 19:30:07.000000000 +0000 @@ -0,0 +1,62 @@ +# Detect if compiler version is sufficient for supporting C++17. +# If it is, CMAKE_CXX_FLAGS are modified appropriately and HAVE_CXX17 +# is set to a true value. Else, CMake exits with a fatal error message. +# This currently only works for GCC and Clang compilers. +# In Cmake 3.8+, CMAKE_CXX_STANDARD_REQUIRED should be able to replace +# all the logic below. + +if ( DEFINED HAVE_CXX17 ) + return() +endif () + +include(CheckCXXSourceCompiles) + +set(required_gcc_version 7.0) +set(required_clang_version 4.0) +set(required_apple_clang_version 6.0) + +set(cxx17_flag "-std=c++17") + +macro(cxx17_compile_test) + check_cxx_source_compiles(" + #include + int main() { std::optional a; }" + cxx17_works) + + if (NOT cxx17_works) + message(FATAL_ERROR "failed using C++17 for compilation") + endif () +endmacro() + +if ( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" ) + if ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${required_gcc_version} ) + message(FATAL_ERROR "GCC version must be at least " + "${required_gcc_version} for C++17 support, detected: " + "${CMAKE_CXX_COMPILER_VERSION}") + endif () +elseif ( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) + if ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${required_clang_version} ) + message(FATAL_ERROR "Clang version must be at least " + "${required_clang_version} for C++17 support, detected: " + "${CMAKE_CXX_COMPILER_VERSION}") + endif () + if ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5 ) + set(cxx17_flag "-std=c++1z") + endif () +elseif ( CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" ) + if ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${required_apple_clang_version} ) + message(FATAL_ERROR "Apple Clang version must be at least " + "${required_apple_clang_version} for C++17 support, detected: " + "${CMAKE_CXX_COMPILER_VERSION}") + endif () +else() + # Unrecognized compiler: fine to be permissive of other compilers as long + # as they are able to support C++17 and can compile the test program, but + # we just won't be able to give specific advice on what compiler version a + # user needs in the case it actually doesn't support C++17. +endif () + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cxx17_flag}") +cxx17_compile_test() + +set(HAVE_CXX17 true) diff -Nru binpac-0.54/cmake/SetDefaultCompileFlags.cmake binpac-0.55/cmake/SetDefaultCompileFlags.cmake --- binpac-0.54/cmake/SetDefaultCompileFlags.cmake 2019-08-08 18:04:34.000000000 +0000 +++ binpac-0.55/cmake/SetDefaultCompileFlags.cmake 2020-02-08 19:30:07.000000000 +0000 @@ -1,7 +1,8 @@ # Set up the default flags and CMake build type once during the configuration # of the top-level CMake project. if ("${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") - set(EXTRA_COMPILE_FLAGS "-Wall -Wno-unused") + set(EXTRA_COMPILE_FLAGS "-Wall -Wno-unused") + set(EXTRA_COMPILE_FLAGS_CXX "-Wno-register") if ( NOT CMAKE_BUILD_TYPE ) if ( ENABLE_DEBUG ) @@ -25,5 +26,5 @@ # Compiler flags may already exist in CMake cache (e.g. when specifying # CFLAGS environment variable before running cmake for the the first time) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_COMPILE_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_COMPILE_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_COMPILE_FLAGS} ${EXTRA_COMPILE_FLAGS_CXX}") endif () diff -Nru binpac-0.54/cmake/ZeekPluginCommon.cmake binpac-0.55/cmake/ZeekPluginCommon.cmake --- binpac-0.54/cmake/ZeekPluginCommon.cmake 2019-08-08 18:04:34.000000000 +0000 +++ binpac-0.55/cmake/ZeekPluginCommon.cmake 2020-02-08 19:30:07.000000000 +0000 @@ -3,7 +3,8 @@ ## This set is used by both static and dynamic plugins via ## ZeekPluginStatic and ZeekPluginDynamic, respectively. -include(RequireCXX11) +include(RequireCXX17) +include(FindClangTidy) include(BifCl) include(BinPAC) @@ -27,8 +28,9 @@ # Adds *.cc files to a plugin. function(zeek_plugin_cc) - list(APPEND _plugin_objs ${ARGV}) - set(_plugin_objs "${_plugin_objs}" PARENT_SCOPE) + list(APPEND _plugin_objs ${ARGV}) + set(_plugin_objs "${_plugin_objs}" PARENT_SCOPE) + add_clang_tidy_files(${ARGV}) endfunction() # This is needed to support legacy Bro plugins. diff -Nru binpac-0.54/cmake/ZeekPluginDynamic.cmake binpac-0.55/cmake/ZeekPluginDynamic.cmake --- binpac-0.54/cmake/ZeekPluginDynamic.cmake 2019-08-08 18:04:34.000000000 +0000 +++ binpac-0.55/cmake/ZeekPluginDynamic.cmake 2020-02-08 19:30:07.000000000 +0000 @@ -57,17 +57,17 @@ include_directories(BEFORE ${BRO_PLUGIN_BRO_SRC}/src ${BRO_PLUGIN_BRO_SRC}/aux/binpac/lib - ${BRO_PLUGIN_BRO_SRC}/aux/broker + ${BRO_PLUGIN_BRO_SRC}/aux/broker/include + ${BRO_PLUGIN_BRO_SRC}/aux/paraglob/include ${BRO_PLUGIN_BRO_BUILD} ${BRO_PLUGIN_BRO_BUILD}/src ${BRO_PLUGIN_BRO_BUILD}/aux/binpac/lib - ${BRO_PLUGIN_BRO_BUILD}/aux/broker + ${BRO_PLUGIN_BRO_BUILD}/aux/broker/include ${bro_cache_CAF_INCLUDE_DIR_CORE} ${bro_cache_CAF_INCLUDE_DIR_IO} ${bro_cache_CAF_INCLUDE_DIR_OPENSSL} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/src - ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src ) @@ -127,7 +127,6 @@ ${CAF_INCLUDE_DIR_OPENSSL} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/src - ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src ) endif () diff -Nru binpac-0.54/cmake/ZeekPluginStatic.cmake binpac-0.55/cmake/ZeekPluginStatic.cmake --- binpac-0.54/cmake/ZeekPluginStatic.cmake 2019-08-08 18:04:34.000000000 +0000 +++ binpac-0.55/cmake/ZeekPluginStatic.cmake 2020-02-08 19:30:07.000000000 +0000 @@ -20,13 +20,7 @@ endfunction() function(bro_plugin_end_static) - if ( bro_HAVE_OBJECT_LIBRARIES ) - add_library(${_plugin_lib} OBJECT ${_plugin_objs}) - set(_target "$") - else () - add_library(${_plugin_lib} STATIC ${_plugin_objs}) - set(_target "${_plugin_lib}") - endif () + add_library(${_plugin_lib} OBJECT ${_plugin_objs}) if ( NOT "${_plugin_deps}" STREQUAL "" ) add_dependencies(${_plugin_lib} ${_plugin_deps}) @@ -34,7 +28,8 @@ add_dependencies(${_plugin_lib} generate_outputs) - set(bro_PLUGIN_LIBS ${bro_PLUGIN_LIBS} "${_target}" CACHE INTERNAL "plugin libraries") + set(bro_PLUGIN_LIBS ${bro_PLUGIN_LIBS} "$" CACHE INTERNAL "plugin libraries") + set(bro_PLUGIN_DEPS ${bro_PLUGIN_DEPS} "${_plugin_lib}" CACHE INTERNAL "plugin dependencies") endfunction() macro(_plugin_target_name_static target ns name) diff -Nru binpac-0.54/cmake/ZeekSubdir.cmake binpac-0.55/cmake/ZeekSubdir.cmake --- binpac-0.54/cmake/ZeekSubdir.cmake 2019-08-08 18:04:34.000000000 +0000 +++ binpac-0.55/cmake/ZeekSubdir.cmake 2020-02-08 19:30:07.000000000 +0000 @@ -2,13 +2,8 @@ # Creates a target for a library of objects file in a subdirectory, # and adds to the global bro_SUBDIR_LIBS. function(bro_add_subdir_library name) - if ( bro_HAVE_OBJECT_LIBRARIES ) - add_library("bro_${name}" OBJECT ${ARGN}) - set(_target "$") - else () - add_library("bro_${name}" STATIC ${ARGN}) - set(_target "bro_${name}") - endif () - - set(bro_SUBDIR_LIBS "${_target}" ${bro_SUBDIR_LIBS} CACHE INTERNAL "subdir libraries") + add_library("bro_${name}" OBJECT ${ARGN}) + set(bro_SUBDIR_LIBS "$" ${bro_SUBDIR_LIBS} CACHE INTERNAL "subdir libraries") + set(bro_SUBDIR_DEPS "bro_${name}" ${bro_SUBDIR_DEPS} CACHE INTERNAL "subdir dependencies") + add_clang_tidy_files(${ARGN}) endfunction() diff -Nru binpac-0.54/CMakeLists.txt binpac-0.55/CMakeLists.txt --- binpac-0.54/CMakeLists.txt 2019-08-08 18:04:34.000000000 +0000 +++ binpac-0.55/CMakeLists.txt 2020-02-08 19:30:07.000000000 +0000 @@ -1,5 +1,5 @@ -project(BinPAC C CXX) cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) +project(BinPAC C CXX) include(cmake/CommonCMakeConfig.cmake) file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" BINPAC_VERSION LIMIT_COUNT 1) @@ -7,6 +7,7 @@ separate_arguments(_version_numbers) list(GET _version_numbers 0 BINPAC_VERSION_MAJOR) list(GET _version_numbers 1 BINPAC_VERSION_MINOR) +string(REGEX REPLACE "-[0-9]*$" "" BINPAC_VERSION_MINOR ${BINPAC_VERSION_MINOR}) # The SO number shall increase only if binary interface changes. set(BINPAC_SOVERSION 0) diff -Nru binpac-0.54/debian/changelog binpac-0.55/debian/changelog --- binpac-0.54/debian/changelog 2019-09-03 20:51:08.000000000 +0000 +++ binpac-0.55/debian/changelog 2020-02-13 15:50:11.000000000 +0000 @@ -1,3 +1,9 @@ +binpac (0.55-1) unstable; urgency=medium + + * New upstream version 0.55 + + -- Hilko Bengen Thu, 13 Feb 2020 16:50:11 +0100 + binpac (0.54-2) unstable; urgency=medium * Build static instead of shared library diff -Nru binpac-0.54/README binpac-0.55/README --- binpac-0.54/README 2019-08-08 18:04:34.000000000 +0000 +++ binpac-0.55/README 2020-02-08 19:30:07.000000000 +0000 @@ -1,7 +1,7 @@ .. -*- mode: rst-mode -*- .. .. Version number is filled in automatically. -.. |version| replace:: 0.54 +.. |version| replace:: 0.55 ====== BinPAC @@ -300,7 +300,7 @@ = withcontext (); }; -When "flow" is added to top level context analyzer, it enables use of &online +When "flow" is added to top level context analyzer, it enables use of &oneline and &length in "record" type. flow buffers data when there is not enough to evaluate the record and dispatchs data for evaluation when the threshold is reached. diff -Nru binpac-0.54/README.rst binpac-0.55/README.rst --- binpac-0.54/README.rst 2019-08-08 18:04:34.000000000 +0000 +++ binpac-0.55/README.rst 2020-02-08 19:30:07.000000000 +0000 @@ -1,7 +1,7 @@ .. -*- mode: rst-mode -*- .. .. Version number is filled in automatically. -.. |version| replace:: 0.54 +.. |version| replace:: 0.55 ====== BinPAC @@ -300,7 +300,7 @@ = withcontext (); }; -When "flow" is added to top level context analyzer, it enables use of &online +When "flow" is added to top level context analyzer, it enables use of &oneline and &length in "record" type. flow buffers data when there is not enough to evaluate the record and dispatchs data for evaluation when the threshold is reached. diff -Nru binpac-0.54/src/CMakeLists.txt binpac-0.55/src/CMakeLists.txt --- binpac-0.54/src/CMakeLists.txt 2019-08-08 18:04:34.000000000 +0000 +++ binpac-0.55/src/CMakeLists.txt 2020-02-08 19:30:07.000000000 +0000 @@ -104,5 +104,5 @@ # This is set to assist superprojects that want to build BinPac # from source and rely on it as a target -set(BinPAC_EXE ${CMAKE_CURRENT_BINARY_DIR}/binpac +set(BinPAC_EXE ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/binpac CACHE STRING "BinPAC executable" FORCE) diff -Nru binpac-0.54/src/pac_main.cc binpac-0.55/src/pac_main.cc --- binpac-0.54/src/pac_main.cc 2019-08-08 18:04:34.000000000 +0000 +++ binpac-0.55/src/pac_main.cc 2020-02-08 19:30:07.000000000 +0000 @@ -209,8 +209,30 @@ exit(1); } +// GCC uses __SANITIZE_ADDRESS__, Clang uses __has_feature +#if defined(__SANITIZE_ADDRESS__) + #define USING_ASAN +#endif + +#if defined(__has_feature) + #if __has_feature(address_sanitizer) + #define USING_ASAN + #endif +#endif + +#if defined(USING_ASAN) + #include +#endif + int main(int argc, char* argv[]) { + #if defined(USING_ASAN) + // We generally do not care at all if binpac is leaking and other + // projects that use it, like Zeek, only have their build tripped up + // by the default behavior of LSAN to treat leaks as errors. + __lsan_disable(); + #endif + #ifdef HAVE_MALLOC_OPTIONS extern char *malloc_options; #endif diff -Nru binpac-0.54/VERSION binpac-0.55/VERSION --- binpac-0.54/VERSION 2019-08-08 18:04:34.000000000 +0000 +++ binpac-0.55/VERSION 2020-02-08 19:30:07.000000000 +0000 @@ -1 +1 @@ -0.54 +0.55