Skip to content

Commit a358f59

Browse files
committed
configure: Add --enable-sanitizer config option
... for easy enabling of the sanitizer for a build. Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
1 parent 3d30f6f commit a358f59

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

configure.ac

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ else
2525
CFLAGS="$CFLAGS -O2 -Wall"
2626
fi
2727

28+
AC_ARG_ENABLE([sanitizer],
29+
AS_HELP_STRING([--enable-sanitizer],[enable sanitizer build (may not work in all environments) @<:@default=no@:>@]),
30+
[],
31+
[enable_sanitizer=no])
32+
2833
AC_ARG_ENABLE([engine],
2934
[AS_HELP_STRING([--enable-engine], [build IBMCA engine (OpenSSL 1.1.1, default is yes)])],
3035
[if test "x$enableval" = "xyes" ; then
@@ -152,6 +157,19 @@ fi
152157

153158
AC_CHECK_DECLS([ica_cleanup],,,[#include <ica_api.h>])
154159

160+
if test "x$enable_sanitizer" = "xyes"; then
161+
AC_CHECK_LIB([asan], [strcpy], [LDFLAGS="-lasan $LDFLAGS"],
162+
[AC_MSG_ERROR(['libasan' library is missing on your system. Please install 'libasan'.])])
163+
AC_CHECK_LIB([ubsan], [strcpy], [LDFLAGS="-lubsan $LDFLAGS"],
164+
[AC_MSG_ERROR(['libubsan' library is missing on your system. Please install 'libubsan'.])])
165+
if test "x$enable_debug" = "xyes"; then
166+
CFLAGS="$CFLAGS -O2 -g3 -DDEBUG"
167+
fi
168+
CFLAGS="$CFLAGS -fstack-protector-all -fsanitize=address,signed-integer-overflow,undefined -Wformat -Wformat-security -Werror=format-security -Warray-bounds -Werror=array-bounds -D_FORTIFY_SOURCE=2"
169+
AC_DEFINE([WITH_SANITIZER])
170+
AC_MSG_RESULT([*** Enabling sanitizer at user request ***])
171+
fi
172+
155173
AC_CONFIG_FILES([
156174
Makefile
157175
src/Makefile

0 commit comments

Comments
 (0)