mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Improve --sanitizers configure option
* Rename SANITIZERS CMake variable to ZEEK_SANITIZERS for clarity * Use -O1 by default to improve speed (set NO_OPTIMIZATIONS env. var. to override and use -O0). Uses -fno-optimize-sibling-calls with -O1 to still get "perfect stack traces". * Updates various sub-projects with sanitizer improvements: binpac and bifcl, by default, now ignore leaks reported by LeakSanitizer so that it doesn't interfere with the Zeek build
This commit is contained in:
parent
f6a1a7053b
commit
4735165d31
5 changed files with 34 additions and 10 deletions
|
@ -121,10 +121,30 @@ if ( NOT BINARY_PACKAGING_MODE )
|
||||||
_make_install_dir_symlink("${CMAKE_INSTALL_PREFIX}/lib/bro" "${CMAKE_INSTALL_PREFIX}/lib/zeek")
|
_make_install_dir_symlink("${CMAKE_INSTALL_PREFIX}/lib/bro" "${CMAKE_INSTALL_PREFIX}/lib/zeek")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if ( SANITIZERS )
|
if ( ZEEK_SANITIZERS )
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${SANITIZERS} -fno-omit-frame-pointer")
|
# Check the thread library info early as setting compiler flags seems to
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${SANITIZERS} -fno-omit-frame-pointer")
|
# interfere with the detection and cause CMAKE_THREAD_LIBS_INIT to not
|
||||||
set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -fsanitize=${SANITIZERS} -fno-omit-frame-pointer")
|
# include -lpthread when it should.
|
||||||
|
find_package(Threads)
|
||||||
|
set(_sanitizer_flags "-fsanitize=${ZEEK_SANITIZERS}")
|
||||||
|
set(_sanitizer_flags "${_sanitizer_flags} -fno-omit-frame-pointer")
|
||||||
|
set(_sanitizer_flags "${_sanitizer_flags} -fno-optimize-sibling-calls")
|
||||||
|
|
||||||
|
if ( NOT DEFINED ENV{NO_OPTIMIZATIONS} )
|
||||||
|
# Using -O1 is generally the suggestion to get more reasonable
|
||||||
|
# performance. The one downside is it that the compiler may optimize out
|
||||||
|
# code that otherwise generates an error/leak in a -O0 build, but that
|
||||||
|
# should be rare and users mostly will not be running unoptimized builds
|
||||||
|
# in production anyway.
|
||||||
|
set(_sanitizer_flags "${_sanitizer_flags} -O1")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Technically, the we also need to use the compiler to drive linking and
|
||||||
|
# give the sanitizer flags there, too. However, CMake, by default, uses
|
||||||
|
# the compiler for linking and so the automatically flags get used. See
|
||||||
|
# https://cmake.org/pipermail/cmake/2014-August/058268.html
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_sanitizer_flags}")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_sanitizer_flags}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
@ -205,6 +225,10 @@ if ( BROKER_ROOT_DIR )
|
||||||
set(zeekdeps ${zeekdeps} ${BROKER_LIBRARY})
|
set(zeekdeps ${zeekdeps} ${BROKER_LIBRARY})
|
||||||
set(broker_includes ${BROKER_INCLUDE_DIR})
|
set(broker_includes ${BROKER_INCLUDE_DIR})
|
||||||
else ()
|
else ()
|
||||||
|
if ( ZEEK_SANITIZERS )
|
||||||
|
set(BROKER_SANITIZERS ${ZEEK_SANITIZERS})
|
||||||
|
endif ()
|
||||||
|
|
||||||
set(ENABLE_STATIC_ONLY_SAVED ${ENABLE_STATIC_ONLY})
|
set(ENABLE_STATIC_ONLY_SAVED ${ENABLE_STATIC_ONLY})
|
||||||
|
|
||||||
if ( BUILD_STATIC_BROKER )
|
if ( BUILD_STATIC_BROKER )
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit e5b1940850d486e3989f6a55615140a16bd1b9d2
|
Subproject commit 9cc1f0dfcd7c9d7c7a4031d45732268e0d68206f
|
|
@ -1 +1 @@
|
||||||
Subproject commit c02d6ff7be6bcee097d668f4f667f83c82a28cc6
|
Subproject commit 71f815a22027bef47fa46459a1010013bd4f59e3
|
|
@ -1 +1 @@
|
||||||
Subproject commit 237c3cd2d87d467a5b9ac0517c6461ac00c7b85c
|
Subproject commit 5156ba056e1747b31466a29898564065d20d30a1
|
6
configure
vendored
6
configure
vendored
|
@ -27,6 +27,7 @@ Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||||
ccache installation and CMake 3.10+)
|
ccache installation and CMake 3.10+)
|
||||||
--toolchain=PATH path to a CMAKE_TOOLCHAIN_FILE
|
--toolchain=PATH path to a CMAKE_TOOLCHAIN_FILE
|
||||||
(useful for cross-compiling)
|
(useful for cross-compiling)
|
||||||
|
--sanitizers=LIST comma-separated list of sanitizer names to enable
|
||||||
|
|
||||||
Installation Directories:
|
Installation Directories:
|
||||||
--prefix=PREFIX installation directory [/usr/local/zeek]
|
--prefix=PREFIX installation directory [/usr/local/zeek]
|
||||||
|
@ -57,7 +58,6 @@ Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||||
--disable-auxtools don't build or install auxiliary tools
|
--disable-auxtools don't build or install auxiliary tools
|
||||||
--disable-python don't try to build python bindings for Broker
|
--disable-python don't try to build python bindings for Broker
|
||||||
--disable-broker-tests don't try to build Broker unit tests
|
--disable-broker-tests don't try to build Broker unit tests
|
||||||
--sanitizers=SANITIZERS comma-separated list of Clang sanitizers to enable
|
|
||||||
|
|
||||||
Required Packages in Non-Standard Locations:
|
Required Packages in Non-Standard Locations:
|
||||||
--with-openssl=PATH path to OpenSSL install root
|
--with-openssl=PATH path to OpenSSL install root
|
||||||
|
@ -154,7 +154,7 @@ append_cache_entry INSTALL_AUX_TOOLS BOOL true
|
||||||
append_cache_entry INSTALL_ZEEKCTL BOOL true
|
append_cache_entry INSTALL_ZEEKCTL BOOL true
|
||||||
append_cache_entry CPACK_SOURCE_IGNORE_FILES STRING
|
append_cache_entry CPACK_SOURCE_IGNORE_FILES STRING
|
||||||
append_cache_entry ENABLE_MOBILE_IPV6 BOOL false
|
append_cache_entry ENABLE_MOBILE_IPV6 BOOL false
|
||||||
append_cache_entry SANITIZERS STRING ""
|
append_cache_entry ZEEK_SANITIZERS STRING ""
|
||||||
|
|
||||||
# parse arguments
|
# parse arguments
|
||||||
while [ $# -ne 0 ]; do
|
while [ $# -ne 0 ]; do
|
||||||
|
@ -240,7 +240,7 @@ while [ $# -ne 0 ]; do
|
||||||
append_cache_entry ENABLE_PERFTOOLS_DEBUG BOOL true
|
append_cache_entry ENABLE_PERFTOOLS_DEBUG BOOL true
|
||||||
;;
|
;;
|
||||||
--sanitizers=*)
|
--sanitizers=*)
|
||||||
append_cache_entry SANITIZERS STRING $optarg
|
append_cache_entry ZEEK_SANITIZERS STRING $optarg
|
||||||
;;
|
;;
|
||||||
--enable-jemalloc)
|
--enable-jemalloc)
|
||||||
append_cache_entry ENABLE_JEMALLOC BOOL true
|
append_cache_entry ENABLE_JEMALLOC BOOL true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue