Make ASAN=1 affect the HOSTCC-built tools too.

Bug: https://github.com/landley/toybox/issues/169
This commit is contained in:
Elliott Hughes 2020-02-21 09:11:47 -08:00 committed by Rob Landley
parent f428c2cc6f
commit dc16c1161c

View File

@ -3,10 +3,15 @@
# Grab default values for $CFLAGS and such. # Grab default values for $CFLAGS and such.
if [ ! -z "$ASAN" ]; then if [ ! -z "$ASAN" ]; then
# Turn ASan on. echo "Enabling ASan..."
CFLAGS="-fsanitize=address $CFLAGS" # Turn ASan on. Everything except -fsanitize=address is optional, but
# Optional, but effectively necessary if you want useful backtraces. # but effectively required for useful backtraces.
CFLAGS="-O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls $CFLAGS" asan_flags="-fsanitize=address \
-O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls"
CFLAGS="$asan_flags $CFLAGS"
HOSTCC="$HOSTCC $asan_flags"
# Ignore leaks on exit.
export ASAN_OPTIONS="detect_leaks=0"
fi fi
export LANG=c export LANG=c