From dc16c1161cf9dcc5153fcbe1b1649ad209f49a9e Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 21 Feb 2020 09:11:47 -0800 Subject: Make ASAN=1 affect the HOSTCC-built tools too. Bug: https://github.com/landley/toybox/issues/169 --- scripts/make.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/make.sh b/scripts/make.sh index 538ba121..e4333ba2 100755 --- a/scripts/make.sh +++ b/scripts/make.sh @@ -3,10 +3,15 @@ # Grab default values for $CFLAGS and such. if [ ! -z "$ASAN" ]; then - # Turn ASan on. - CFLAGS="-fsanitize=address $CFLAGS" - # Optional, but effectively necessary if you want useful backtraces. - CFLAGS="-O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls $CFLAGS" + echo "Enabling ASan..." + # Turn ASan on. Everything except -fsanitize=address is optional, but + # but effectively required for useful backtraces. + 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 export LANG=c -- cgit v1.2.3