Skip to content

Commit

Permalink
Out-factor DebugSan in PHASAR_ENABLE_SANITIZERS
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianbs96 committed Oct 4, 2023
1 parent 4052d1e commit 319d22b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 .
Expand Down
1 change: 1 addition & 0 deletions BreakingChanges.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
28 changes: 13 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,19 @@ 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})
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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 319d22b

Please sign in to comment.