Skip to content

Commit 52f6722

Browse files
committed
cmake: Enable _GLIBCXX_SANITIZE_VECTOR
1 parent 65f75d7 commit 52f6722

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ if(WEVERYTHING)
6666
)
6767
endif()
6868

69+
if(SANITIZE MATCHES address)
70+
# Enables ASan-powered checks in std::vector in libstdc++.
71+
# For sanity, this may be applied for libstdc++ builds, but it is not easy to detect
72+
# what standard library implementation is being used.
73+
add_compile_definitions(_GLIBCXX_SANITIZE_VECTOR)
74+
endif()
75+
6976
# An option to enable assertions in non-Debug build types.
7077
# Disabling assertions in Debug build type has no effect (assertions are still enabled).
7178
option(ENABLE_ASSERTIONS "Enable NDEBUG based assertions" OFF)

cmake/ProjectWabt.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set(wabt_library ${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}wabt${CMAKE_STATIC_
1414
set(flags -fvisibility=hidden)
1515
if(SANITIZE MATCHES address)
1616
# Instrument WABT with ASan - required for container-overflow checks.
17-
set(flags "-fsanitize=address ${flags}")
17+
set(flags "-D_GLIBCXX_SANITIZE_VECTOR -fsanitize=address ${flags}")
1818
endif()
1919

2020
if(CMAKE_GENERATOR MATCHES Ninja)

0 commit comments

Comments
 (0)