Skip to content

Commit

Permalink
Add memory sanitizer to configure (--memory).
Browse files Browse the repository at this point in the history
This also adds --address for the address sanitizer, in addition to
the existing --sanitizer. -fno-omit-frame-pointer has been added
for both sanitizers to improve the error reporting.
  • Loading branch information
madler committed Aug 12, 2023
1 parent 7dd6aa7 commit 1411cca
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ build64=0
gcc=0
warn=0
debug=0
sanitize=0
address=0
memory=0
old_cc="$CC"
old_cflags="$CFLAGS"
OBJC='$(OBJZ) $(OBJG)'
Expand All @@ -102,7 +103,7 @@ leave()
if test "$*" != "0"; then
echo "** $0 aborting." | tee -a configure.log
fi
rm -f $test.[co] $test $test$shared_ext $test.gcno ./--version
rm -rf $test.[co] $test $test$shared_ext $test.gcno $test.dSYM ./--version
echo -------------------- >> configure.log
echo >> configure.log
echo >> configure.log
Expand Down Expand Up @@ -141,7 +142,9 @@ case "$1" in
-c* | --const) zconst=1; shift ;;
-w* | --warn) warn=1; shift ;;
-d* | --debug) debug=1; shift ;;
--sanitize) sanitize=1; shift ;;
--sanitize) address=1; shift ;;
--address) address=1; shift ;;
--memory) memory=1; shift ;;
*)
echo "unknown option: $1" | tee -a configure.log
echo "$0 --help for help" | tee -a configure.log
Expand Down Expand Up @@ -211,8 +214,11 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
CFLAGS="${CFLAGS} -Wall -Wextra"
fi
fi
if test $sanitize -eq 1; then
CFLAGS="${CFLAGS} -g -fsanitize=address"
if test $address -eq 1; then
CFLAGS="${CFLAGS} -g -fsanitize=address -fno-omit-frame-pointer"
fi
if test $memory -eq 1; then
CFLAGS="${CFLAGS} -g -fsanitize=memory -fno-omit-frame-pointer"
fi
if test $debug -eq 1; then
CFLAGS="${CFLAGS} -DZLIB_DEBUG"
Expand Down

0 comments on commit 1411cca

Please sign in to comment.