]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
build: Check compiler actually supports address sanitisation.
authorRoy Marples <roy@marples.name>
Mon, 4 Nov 2019 19:56:51 +0000 (19:56 +0000)
committerRoy Marples <roy@marples.name>
Mon, 4 Nov 2019 19:56:51 +0000 (19:56 +0000)
configure

index 146aedec83d3538fa1019806c93419741ff368dd..bbc71db8b91193d8fb061ed0ed6b828b742a6c52 100755 (executable)
--- a/configure
+++ b/configure
@@ -373,12 +373,24 @@ if [ -z "$DEBUG" -a -d .git ]; then
        DEBUG=yes
 fi
 if [ -n "$DEBUG" -a "$DEBUG" != no -a "$DEBUG" != false ]; then
+       printf "Testing compiler supports address sanitisation ..."
+       cat <<EOF >_test.c
+int main(void) {
+       return 0;
+}
+EOF
+       if $CC -fsanitize=address _test.c -o _test 2>&3; then
+               echo "yes"
+               echo "# Compiler supports address sanitisation" >>$CONFIG_MK
+               echo "CFLAGS+=          -fsanitize=address" >>$CONFIG_MK
+               echo "LDFLAGS+=         -fsanitize=address" >>$CONFIG_MK
+       else
+               echo "no"
+       fi
+       rm -rf _test.c _test
+
        echo "Adding debugging CFLAGS"
        cat <<EOF >>$CONFIG_MK
-# Enforce address sanitization
-CFLAGS+=       -fsanitize=address
-LDFLAGS+=      -fsanitize=address
-
 CFLAGS+=       -g -Wall -Wextra
 CFLAGS+=       -Wmissing-prototypes -Wmissing-declarations
 CFLAGS+=       -Wmissing-format-attribute -Wnested-externs