Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUILD/CONFIG: Introduce Address Sanitizer flag option #9519

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions config/m4/compiler.m4
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,31 @@ ADD_COMPILER_FLAG_IF_SUPPORTED([-funwind-tables],
[AS_MESSAGE([compiling without unwind tables])])


#
# ASAN support
#
AC_ARG_ENABLE([asan],
AS_HELP_STRING([--enable-asan], [Enable address sanitized check]),
[],
[enable_asan=no])

AS_IF([test "x$enable_asan" = xyes],
[ADD_COMPILER_FLAG_IF_SUPPORTED([-fsanitize=address -fno-omit-frame-pointer],
[-fsanitize=address -fno-omit-frame-pointer],
[AC_LANG_SOURCE([[int main(int argc, char** argv){return 0;}]])],
[AS_MESSAGE([compiling with sanitizer])
BASE_CXXFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASE_CXXFLAGS"
LDFLAGS="-fsanitize=address -fno-omit-frame-pointer $LDFLAGS"],
yosefe marked this conversation as resolved.
Show resolved Hide resolved
[AC_MSG_ERROR([ASAN check is requested but not supported. Check libasan package existance])])

AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]],
[[void *p = malloc(7); return 0;]])],
[AC_MSG_ERROR([ASAN cannot detect simple memory leak, consider installing newer compiler version])],
[AS_MESSAGE([sanitizer runtime leak detection check passed])]
)],
[])


AS_IF([test "x$enable_gcov" = xyes],
[ADD_COMPILER_FLAGS_IF_SUPPORTED([[-ftest-coverage],
[-fprofile-arcs]],
Expand Down
Loading