summaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2019-11-04 19:56:51 +0000
committerRoy Marples <roy@marples.name>2019-11-04 19:56:51 +0000
commita9b87bc9660f2516a3e4a2febfda24036c4b6e79 (patch)
tree26bce2e395ec608e3f2cc24d48ca047dfb3c5365 /configure
parent8c94248fe45c03f0e03f418f5d4bf2dea68cb41f (diff)
downloaddhcpcd-a9b87bc9660f2516a3e4a2febfda24036c4b6e79.tar.xz
build: Check compiler actually supports address sanitisation.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure20
1 files changed, 16 insertions, 4 deletions
diff --git a/configure b/configure
index 146aedec..bbc71db8 100755
--- 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