Skip to content
Permalink
Browse files

Turn ASAN by default to -O0 again and add ASANOPT mode for -Og

  • Loading branch information...
milot-mirdita committed Aug 28, 2019
1 parent 3d3f2a4 commit b5a5285687ee59afb0a8db59b05df7a0c9158fe8
Showing with 25 additions and 10 deletions.
  1. +1 −1 azure-pipelines.yml
  2. +24 −9 cmake/FindASan.cmake
@@ -80,7 +80,7 @@ jobs:
SIMD: 'AVX2'
STATIC: 0
MPI: 0
BUILD_TYPE: ASan
BUILD_TYPE: ASanOpt

steps:
- checkout: self
@@ -47,19 +47,12 @@ else(NOT ADDRESS_SANITIZER_FLAG)
set(HAVE_ADDRESS_SANITIZER FALSE)
endif()

check_cxx_compiler_flag("-Og" HAVE_OPTIMIZE_DEBUG)
if(HAVE_OPTIMIZE_DEBUG)
set(OPTIMIZE_DEBUG_FLAG "-Og")
else()
set(OPTIMIZE_DEBUG_FLAG "-O0")
endif()

set(HAVE_ADDRESS_SANITIZER TRUE)

set(CMAKE_C_FLAGS_ASAN "${OPTIMIZE_DEBUG_FLAG} -g ${ADDRESS_SANITIZER_FLAG} -fno-omit-frame-pointer -fno-optimize-sibling-calls"
set(CMAKE_C_FLAGS_ASAN "-O0 -g ${ADDRESS_SANITIZER_FLAG} -fno-omit-frame-pointer -fno-optimize-sibling-calls"
CACHE STRING "Flags used by the C compiler during ASan builds."
FORCE)
set(CMAKE_CXX_FLAGS_ASAN "${OPTIMIZE_DEBUG_FLAG} -g ${ADDRESS_SANITIZER_FLAG} -fno-omit-frame-pointer -fno-optimize-sibling-calls"
set(CMAKE_CXX_FLAGS_ASAN "-O0 -g ${ADDRESS_SANITIZER_FLAG} -fno-omit-frame-pointer -fno-optimize-sibling-calls"
CACHE STRING "Flags used by the C++ compiler during ASan builds."
FORCE)
set(CMAKE_EXE_LINKER_FLAGS_ASAN "${ADDRESS_SANITIZER_FLAG}"
@@ -73,3 +66,25 @@ mark_as_advanced(CMAKE_C_FLAGS_ASAN
CMAKE_CXX_FLAGS_ASAN
CMAKE_EXE_LINKER_FLAGS_ASAN
CMAKE_SHARED_LINKER_FLAGS_ASAN)


check_cxx_compiler_flag("-Og" HAVE_OPTIMIZE_DEBUG)
if(HAVE_OPTIMIZE_DEBUG)
set(CMAKE_C_FLAGS_ASANOPT "-Og -g ${ADDRESS_SANITIZER_FLAG} -fno-omit-frame-pointer -fno-optimize-sibling-calls"
CACHE STRING "Flags used by the C compiler during ASan Optimized builds."
FORCE)
set(CMAKE_CXX_FLAGS_ASANOPT "-Og -g ${ADDRESS_SANITIZER_FLAG} -fno-omit-frame-pointer -fno-optimize-sibling-calls"
CACHE STRING "Flags used by the C++ compiler during ASan Optimized builds."
FORCE)
set(CMAKE_EXE_LINKER_FLAGS_ASANOPT "${ADDRESS_SANITIZER_FLAG}"
CACHE STRING "Flags used for linking binaries during ASan Optimized builds."
FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_ASANOPT "${ADDRESS_SANITIZER_FLAG}"
CACHE STRING "Flags used by the shared libraries linker during ASan Optimized builds."
FORCE)

mark_as_advanced(CMAKE_C_FLAGS_ASANOPT
CMAKE_CXX_FLAGS_ASANOPT
CMAKE_EXE_LINKER_FLAGS_ASANOPT
CMAKE_SHARED_LINKER_FLAGS_ASANOPT)
endif()

0 comments on commit b5a5285

Please sign in to comment.
You can’t perform that action at this time.