Skip to content

Commit

Permalink
Merge r228134 - [CMake] Add ENABLE_ADDRESS_SANITIZER to make it easie…
Browse files Browse the repository at this point in the history
…r to build with asan support

https://bugs.webkit.org/show_bug.cgi?id=182400

Reviewed by Konstantin Tokarev.

* Source/cmake/OptionsGTK.cmake:
* Source/cmake/WebKitCompilerFlags.cmake:
  • Loading branch information
mcatanzaro authored and carlosgcampos committed Feb 19, 2018
1 parent b690e18 commit 3667cfc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ChangeLog
@@ -1,3 +1,13 @@
2018-02-05 Michael Catanzaro <mcatanzaro@igalia.com>

[CMake] Add ENABLE_ADDRESS_SANITIZER to make it easier to build with asan support
https://bugs.webkit.org/show_bug.cgi?id=182400

Reviewed by Konstantin Tokarev.

* Source/cmake/OptionsGTK.cmake:
* Source/cmake/WebKitCompilerFlags.cmake:

2018-02-05 Carlos Garcia Campos <cgarcia@igalia.com>

Unreviewed. Update OptionsGTK.cmake and NEWS for 2.19.90 release.
Expand Down
5 changes: 5 additions & 0 deletions Source/cmake/OptionsGTK.cmake
Expand Up @@ -355,6 +355,11 @@ if (USE_WOFF2)
endif ()
endif ()

# https://bugs.webkit.org/show_bug.cgi?id=182247
if (ENABLED_COMPILER_SANITIZERS)
set(ENABLE_INTROSPECTION OFF)
endif ()

# Override the cached variables, gtk-doc and gobject-introspection do not really work when cross-building.
if (CMAKE_CROSSCOMPILING)
set(ENABLE_GTKDOC OFF)
Expand Down
15 changes: 15 additions & 0 deletions Source/cmake/WebKitCompilerFlags.cmake
Expand Up @@ -155,6 +155,21 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT "${LOWERCASE_CMAKE_HOST_SY
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "-Wl,--no-keep-memory ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
endif ()

if (COMPILER_IS_GCC_OR_CLANG)
# Careful: this needs to be above where ENABLED_COMPILER_SANITIZERS is set.
# Also, it's not possible to use the normal prepend/append macros for
# -fsanitize=address, because check_cxx_compiler_flag will report it's
# unsupported, because it causes the build to fail if not used when linking.
option(ENABLE_ADDRESS_SANITIZER "Enable address sanitizer" OFF)
if (ENABLE_ADDRESS_SANITIZER)
WEBKIT_PREPEND_GLOBAL_COMPILER_FLAGS(-fno-omit-frame-pointer
-fno-optimize-sibling-calls)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_THREAD_LIBS_INIT} ${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_THREAD_LIBS_INIT} ${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address")
endif ()
endif ()

if (NOT MSVC)
string(REGEX MATCHALL "-fsanitize=[^ ]*" ENABLED_COMPILER_SANITIZERS ${CMAKE_CXX_FLAGS})
Expand Down

0 comments on commit 3667cfc

Please sign in to comment.