From b182c357628af2fad8b149be0c79aca6d5a6b373 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Fri, 8 Nov 2019 12:30:56 -0800 Subject: [PATCH] Fix undefined symbols loading libbroker on OpenBSD python3.7:/usr/local/lib/libbroker.so.2: undefined symbol '__inet_ntop' python3.7:/usr/local/lib/libbroker.so.2: undefined symbol '__inet_pton' An independent Broker build doesn't have that problem because it usually picks up those functions from libc. But when building Broker as part of Zeek, include search paths were already modified to reflect Zeek's libbind dependency and Broker ends up using libbind headers which defines its own version of these, but then does not link to libbind (since it's a dependency of Zeek, not Broker) to actually get those symbols (e.g. when dlopen'ing independently from Zeek, like for the Python bindings). Solution is to re-order include_directories() for Zeek dependencies such that they won't effect sub-projects. --- CMakeLists.txt | 84 ++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c786f5ee59..df596c7433 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -181,6 +181,46 @@ if (MISSING_PREREQS) message(FATAL_ERROR "Configuration aborted due to missing prerequisites") endif () +if ( CAF_ROOT_DIR ) + find_package(CAF COMPONENTS core io openssl REQUIRED) +endif () + +add_subdirectory(aux/paraglob) +set(zeekdeps ${zeekdeps} paraglob) + +if ( BROKER_ROOT_DIR ) + # Avoid calling find_package(CAF) twice. + if ( NOT CAF_ROOT_DIR ) + find_package(CAF COMPONENTS core io openssl REQUIRED) + endif () + find_package(Broker REQUIRED) + set(zeekdeps ${zeekdeps} ${BROKER_LIBRARY}) + set(broker_includes ${BROKER_INCLUDE_DIR}) +else () + set(ENABLE_STATIC_ONLY_SAVED ${ENABLE_STATIC_ONLY}) + + if ( BUILD_STATIC_BROKER ) + set(ENABLE_STATIC_ONLY true) + endif() + + add_subdirectory(aux/broker) + set(ENABLE_STATIC_ONLY ${ENABLE_STATIC_ONLY_SAVED}) + + if ( BUILD_STATIC_BROKER ) + set(zeekdeps ${zeekdeps} broker_static) + else() + set(zeekdeps ${zeekdeps} broker) + endif() + set(broker_includes ${CMAKE_CURRENT_SOURCE_DIR}/aux/broker/include ${CMAKE_CURRENT_BINARY_DIR}/aux/broker/include) +endif () + +# CAF_LIBRARIES and CAF_INCLUDE_DIRS are defined either by calling +# find_package(CAF) or by calling add_subdirectory(aux/broker). In either case, +# we have to care about CAF here because Broker headers can pull in CAF +# headers. +set(zeekdeps ${zeekdeps} ${CAF_LIBRARIES}) +include_directories(BEFORE ${broker_includes} ${CAF_INCLUDE_DIRS}) +include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/aux/paraglob/include) include_directories(BEFORE ${PCAP_INCLUDE_DIR} ${BIND_INCLUDE_DIR} @@ -254,7 +294,7 @@ if ( ${CMAKE_SYSTEM_NAME} MATCHES Linux AND EXISTS /etc/os-release ) endif () endif () -set(zeekdeps +set(zeekdeps ${zeekdeps} ${BinPAC_LIBRARY} ${PCAP_LIBRARY} ${OPENSSL_LIBRARIES} @@ -339,48 +379,6 @@ InstallSymlink("${CMAKE_INSTALL_PREFIX}/bin/zeek-wrapper" "${CMAKE_INSTALL_PREFI ######################################################################## ## Recurse on sub-directories -if ( CAF_ROOT_DIR ) - find_package(CAF COMPONENTS core io openssl REQUIRED) -endif () - -if ( BROKER_ROOT_DIR ) - # Avoid calling find_package(CAF) twice. - if ( NOT CAF_ROOT_DIR ) - find_package(CAF COMPONENTS core io openssl REQUIRED) - endif () - find_package(Broker REQUIRED) - set(zeekdeps ${zeekdeps} ${BROKER_LIBRARY}) - include_directories(BEFORE ${BROKER_INCLUDE_DIR}) -else () - set(ENABLE_STATIC_ONLY_SAVED ${ENABLE_STATIC_ONLY}) - - if ( BUILD_STATIC_BROKER ) - set(ENABLE_STATIC_ONLY true) - endif() - - add_subdirectory(aux/broker) - set(ENABLE_STATIC_ONLY ${ENABLE_STATIC_ONLY_SAVED}) - - if ( BUILD_STATIC_BROKER ) - set(zeekdeps ${zeekdeps} broker_static) - else() - set(zeekdeps ${zeekdeps} broker) - endif() - include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/aux/broker/include - ${CMAKE_CURRENT_BINARY_DIR}/aux/broker/include) -endif () - -# CAF_LIBRARIES and CAF_INCLUDE_DIRS are defined either by calling -# find_package(CAF) or by calling add_subdirectory(aux/broker). In either case, -# we have to care about CAF here because Broker headers can pull in CAF -# headers. -set(zeekdeps ${zeekdeps} ${CAF_LIBRARIES}) -include_directories(BEFORE ${CAF_INCLUDE_DIRS}) - -add_subdirectory(aux/paraglob) -set(zeekdeps ${zeekdeps} paraglob) -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/aux/paraglob/include) - add_subdirectory(src) add_subdirectory(scripts) add_subdirectory(man)