From 319d22bd71f3f5e389e43e660dcac1b918d0e18f Mon Sep 17 00:00:00 2001 From: Fabian Schiebel Date: Wed, 4 Oct 2023 19:12:26 +0200 Subject: [PATCH] Out-factor DebugSan in PHASAR_ENABLE_SANITIZERS --- .github/workflows/ci.yml | 5 +++-- BreakingChanges.md | 1 + CMakeLists.txt | 28 +++++++++++++--------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c41945f9c..ad77d9d32 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,9 +13,9 @@ jobs: fail-fast: true matrix: compiler: [ [clang++-14, clang-14] ] - build: [ DebugSan, Release ] + build: [ Debug, Release ] include: - - build: DebugSan + - build: Debug flags: -DPHASAR_BUILD_DYNLIB=ON - build: Release flags: -DPHASAR_ENABLE_DYNAMIC_LOG=OFF @@ -74,6 +74,7 @@ jobs: -DCMAKE_BUILD_TYPE=${{ matrix.build }} \ -DBUILD_SWIFT_TESTS=ON \ -DPHASAR_DEBUG_LIBDEPS=ON \ + -DPHASAR_ENABLE_SANITIZERS=ON \ ${{ matrix.flags }} \ -G Ninja cmake --build . diff --git a/BreakingChanges.md b/BreakingChanges.md index 477de93b7..ad40d45f6 100644 --- a/BreakingChanges.md +++ b/BreakingChanges.md @@ -3,6 +3,7 @@ ## Development HEAD - Default build mode is no longer `SHARED` but `STATIC`. To build in shared mode, use the cmake option `BUILD_SHARED_LIBS` which we don't recommend anymore. Consider using `PHASAR_BUILD_DYNLIB` instead to build one big libphasar.so. +- Build type `DebugSan` has been removed in favor of a new CMake option `PHASAR_ENABLE_SANITIZERS` that not only works in `Debug` mode. ## v0323 diff --git a/CMakeLists.txt b/CMakeLists.txt index 12fa6f3aa..a0ffe8e33 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,9 +38,11 @@ include(GNUInstallDirs) set_property(GLOBAL PROPERTY TARGET_MESSAGES OFF) -set(CMAKE_CONFIGURATION_TYPES DebugSan Debug RelWithDebInfo Release CACHE STRING "Configuration types: DebugSan, Debug, RelWithDebInfo and Release" FORCE) +set(CMAKE_CONFIGURATION_TYPES Debug RelWithDebInfo Release CACHE STRING "Configuration types: Debug, RelWithDebInfo and Release" FORCE) -set(DEBUG_CONFIGURATIONS DEBUG DEBUGSAN CACHE INTERNAL "" FORCE) +option(PHASAR_ENABLE_SANITIZERS "Build PhASAR with AddressSanitizer and UBSanitizer (default is OFF)" OFF) + +set(DEBUG_CONFIGURATIONS DEBUG CACHE INTERNAL "" FORCE) set(RELEASE_CONFIGURATIONS RELWITHDEBINFO RELEASE CACHE INTERNAL "" FORCE) set(PHASAR_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}) @@ -48,7 +50,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PHASAR_SRC_DIR}/cmake") include("phasar_macros") if (NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build mode ('DebugSan' or 'Debug' or 'Release', default is 'Debug')" FORCE) + set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build mode ('Debug' or 'Release', default is 'Debug')" FORCE) endif () option(CMAKE_VISIBILITY_INLINES_HIDDEN "Hide inlined functions from the DSO table (default ON)" ON) @@ -70,21 +72,22 @@ if (NOT PHASAR_TARGET_ARCH STREQUAL "") endif() endif() -# TODO: Once available, we may want to use -fextend-lifetimes on Debug- and RelWithDebInfo builds to improve debugging experience -# https://reviews.llvm.org/D157613 -if(CMAKE_BUILD_TYPE STREQUAL "DebugSan") - message(STATUS "Selected Debug Build with Sanitizers") +if (PHASAR_ENABLE_SANITIZERS) + message(STATUS "Selected ${CMAKE_BUILD_TYPE} Build with Sanitizers") add_cxx_compile_options( -fno-omit-frame-pointer -fsanitize=address,undefined - -g - -O1 ) add_cxx_link_options( -fsanitize=address,undefined ) -elseif(CMAKE_BUILD_TYPE STREQUAL "Debug") +endif() + +# TODO: Once available, we may want to use -fextend-lifetimes on Debug- and RelWithDebInfo builds to improve debugging experience +# https://reviews.llvm.org/D157613 + +if(CMAKE_BUILD_TYPE STREQUAL "Debug") message(STATUS "Selected Debug Build") add_cxx_compile_options( -Og @@ -117,11 +120,6 @@ add_cxx_compile_definitions(PHASAR_BUILD_DIR="${CMAKE_BINARY_DIR}") # Enable testing enable_testing() -# TODO: allow Phasar to be build as a llvm drop-in as well -# if (NOT DEFINED LLVM_MAIN_SRC_DIR) -# message(FATAL_ERROR "Phasar is not a llvm drop-in, abort!") -# endif() - file(STRINGS ${PHASAR_SRC_DIR}/include/phasar/Config/Version.h VERSION_NUMBER_FILE) string(REPLACE " " ";" VERSION_NUMBER_FILE ${VERSION_NUMBER_FILE}) list(GET VERSION_NUMBER_FILE 2 VERSION_NUMBER_PHASAR)