summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuild.sh4
-rw-r--r--configure.ac60
-rw-r--r--src/Makefile.am22
3 files changed, 66 insertions, 20 deletions
diff --git a/build.sh b/build.sh
index 5cd0a2e..3c05c38 100755
--- a/build.sh
+++ b/build.sh
@@ -12,12 +12,12 @@ mkdir m4
autoreconf -i
cd build
if [[ "${CMD}" == "default" ]]; then
- export CC=gcc-5
+ export CC=gcc
../configure --enable-sanitize
elif [[ "${CMD}" == "old" ]]; then
../configure
elif [[ "${CMD}" == "gprof" ]]; then
- export CC=gcc-5
+ export CC=gcc
../configure --enable-gprof
fi
make -j3
diff --git a/configure.ac b/configure.ac
index 11d8ca1..095716f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -151,6 +151,66 @@ AC_DEFUN([AC_CHECK_COMPILER_WFLAG],
]
)
+AC_DEFUN([AC_CHECK_SANITIZER_FLAG],
+ [
+ AC_MSG_CHECKING([whether $CC supports -fsanitize=$1])
+ OLD_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -fsanitize=$1"
+ OLD_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -fsanitize=$1"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([int foo;])],
+ [
+ AC_MSG_RESULT([yes])
+ ],
+ [
+ AC_MSG_RESULT([no])
+
+ AC_MSG_CHECKING([whether $CC requires -fsanitize-undefined-trap-on-error for -fsanitize=$1])
+ CFLAGS="$CFLAGS -fsanitize-undefined-trap-on-error"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([int foo;])],
+ [
+ AC_MSG_RESULT([yes])
+ ],
+ [
+ AC_MSG_RESULT([no])
+ CFLAGS="$OLD_CFLAGS"
+ LDFLAGS="$OLD_LDFLAGS"
+ ]
+ )
+ ],
+ [
+ AC_MSG_RESULT([guessing no])
+ CFLAGS="$OLD_CFLAGS"
+ LDFLAGS="$OLD_LDFLAGS"
+ ]
+ )
+ ]
+)
+
+if test "$enable_sanitize" != "no" ; then
+ AC_CHECK_SANITIZER_FLAG(address)
+ # skipped because server have multiple issues: -fsanitize=alignment
+ AC_CHECK_SANITIZER_FLAG(shift)
+ AC_CHECK_SANITIZER_FLAG(integer-divide-by-zero)
+ AC_CHECK_SANITIZER_FLAG(unreachable)
+ AC_CHECK_SANITIZER_FLAG(vla-bound)
+ AC_CHECK_SANITIZER_FLAG(null)
+ AC_CHECK_SANITIZER_FLAG(return)
+ AC_CHECK_SANITIZER_FLAG(signed-integer-overflow)
+ AC_CHECK_SANITIZER_FLAG(bounds)
+ AC_CHECK_SANITIZER_FLAG(bounds-strict)
+ AC_CHECK_SANITIZER_FLAG(object-size)
+ AC_CHECK_SANITIZER_FLAG(float-divide-by-zero)
+ AC_CHECK_SANITIZER_FLAG(float-cast-overflow)
+ AC_CHECK_SANITIZER_FLAG(nonnull-attribute)
+ AC_CHECK_SANITIZER_FLAG(returns-nonnull-attribute)
+ AC_CHECK_SANITIZER_FLAG(bool)
+ AC_CHECK_SANITIZER_FLAG(enum)
+ AC_CHECK_SANITIZER_FLAG(vptr)
+fi
+
AC_CHECK_COMPILER_WFLAG(empty-body)
AC_CHECK_COMPILER_WFLAG(newline-eof)
AC_CHECK_COMPILER_WFLAG(int-conversion)
diff --git a/src/Makefile.am b/src/Makefile.am
index 25afa53..c2a6cf6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -116,28 +116,14 @@ SHARED_CFLAGS = ${CFLAGS} -pipe -ffast-math -fvisibility=hidden -std=c99 -Wall -
-DPCRE_SUPPORT -I../../.. -I../../../../3rdparty -DPACKETVER=20150000
SHARED_LDFLAGS = -avoid-version -Wl,--no-undefined
-if ENABLE_SANITIZE
-#skip -fsanitize=alignment
-SHARED_CFLAGS += -fsanitize=address \
--fsanitize=shift -fsanitize=integer-divide-by-zero -fsanitize=unreachable \
--fsanitize=vla-bound -fsanitize=null -fsanitize=return \
--fsanitize=signed-integer-overflow -fsanitize=bounds \
--fsanitize=object-size -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow \
--fsanitize=nonnull-attribute -fsanitize=returns-nonnull-attribute -fsanitize=bool \
--fsanitize=enum -fsanitize=vptr
-SHARED_LDFLAGS += -lasan -lubsan -fsanitize=address \
--fsanitize=shift -fsanitize=integer-divide-by-zero -fsanitize=unreachable \
--fsanitize=vla-bound -fsanitize=null -fsanitize=return \
--fsanitize=signed-integer-overflow -fsanitize=bounds \
--fsanitize=object-size -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow \
--fsanitize=nonnull-attribute -fsanitize=returns-nonnull-attribute -fsanitize=bool \
--fsanitize=enum -fsanitize=vptr
-endif
-
if ENABLE_STATIC_BUILD
SHARED_CFLAGS += "-static-libgcc"
endif
+if ENABLE_SANITIZE
+SHARED_LDFLAGS += -lasan -lubsan
+endif
+
if ENABLE_GPROF
SHARED_CFLAGS += "-pg"
endif