diff options
| author | Thomas Holder <thomas@thomas-holder.de> | 2019-07-02 07:28:45 +0000 |
|---|---|---|
| committer | Thomas Holder <thomas@thomas-holder.de> | 2019-07-02 07:28:45 +0000 |
| commit | 56cc79a8137b33423fc0a6ac3dae2a3c4769c77c (patch) | |
| tree | 72d513a11ea717dfb8bef65789b4633e0965c995 /CMakeScripts | |
| parent | Fix various minor typos (diff) | |
| download | inkscape-56cc79a8137b33423fc0a6ac3dae2a3c4769c77c.tar.gz inkscape-56cc79a8137b33423fc0a6ac3dae2a3c4769c77c.zip | |
WITH_ASAN AddressSanitizer compile option
Diffstat (limited to 'CMakeScripts')
| -rw-r--r-- | CMakeScripts/DefineDependsandFlags.cmake | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/CMakeScripts/DefineDependsandFlags.cmake b/CMakeScripts/DefineDependsandFlags.cmake index 3be793621..e38eaef4a 100644 --- a/CMakeScripts/DefineDependsandFlags.cmake +++ b/CMakeScripts/DefineDependsandFlags.cmake @@ -10,13 +10,28 @@ list(APPEND INKSCAPE_INCS ${PROJECT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/include ) +# AddressSanitizer +# Clang's AddressSanitizer can detect more memory errors and is more powerful +# than compiling with _FORTIFY_SOURCE but has a performance impact (approx. 2x +# slower), so it's not suitable for release builds. +if(WITH_ASAN) + if(NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) + message(FATAL_ERROR "Compiler must be Clang for WITH_ASAN=ON") + endif() + list(APPEND INKSCAPE_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer") + list(APPEND INKSCAPE_LIBS "-fsanitize=address") +else() + # Undefine first, to suppress 'warning: "_FORTIFY_SOURCE" redefined' + list(APPEND INKSCAPE_CXX_FLAGS "-U_FORTIFY_SOURCE") + list(APPEND INKSCAPE_CXX_FLAGS "-D_FORTIFY_SOURCE=2") +endif() + # Errors for common mistakes list(APPEND INKSCAPE_CXX_FLAGS "-Werror=format") # e.g.: printf("%s", std::string("foo")) list(APPEND INKSCAPE_CXX_FLAGS "-Werror=format-security") # e.g.: printf(variable); -list(APPEND INKSCAPE_CXX_FLAGS "-D_FORTIFY_SOURCE=2") +list(APPEND INKSCAPE_CXX_FLAGS_DEBUG "-Og") # for _FORTIFY_SOURCE list(APPEND INKSCAPE_CXX_FLAGS_DEBUG "-D_GLIBCXX_ASSERTIONS") if (CMAKE_COMPILER_IS_GNUCC) - list(APPEND INKSCAPE_CXX_FLAGS_DEBUG "-Og") # for _FORTIFY_SOURCE list(APPEND INKSCAPE_CXX_FLAGS_DEBUG "-fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables") if(CXX_COMPILER_VERSION VERSION_GREATER 8.0) list(APPEND INKSCAPE_CXX_FLAGS_DEBUG "-fstack-clash-protection -fcf-protection") |
