chiark / gitweb /
build-sys: use _FORTIFY_SOURCE only if optimizing
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 11 Jan 2013 15:03:04 +0000 (10:03 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 11 Jan 2013 15:03:16 +0000 (10:03 -0500)
Rather then force the user to undefine _FORTIFY_SOURCE,
don't define it in the first place if it cannot be used.

I'm assuming that -O* can only be sensibly specified in $CFLAGS.

autogen.sh
configure.ac

index 33d8fcda2342ad7cb91deba510f6fd24b54f4a26..86fe9b3785a27453e4808ed861aeff82a970005b 100755 (executable)
@@ -54,7 +54,7 @@ args="$args \
 fi
 
 if [ "x$1" = "xc" ]; then
 fi
 
 if [ "x$1" = "xc" ]; then
-        ./configure CFLAGS='-g -O0 -Wp,-U_FORTIFY_SOURCE' $args
+        ./configure CFLAGS='-g -O0' $args
         make clean
 else
         echo
         make clean
 else
         echo
@@ -62,6 +62,6 @@ else
         echo "Initialized build system. For a common configuration please run:"
         echo "----------------------------------------------------------------"
         echo
         echo "Initialized build system. For a common configuration please run:"
         echo "----------------------------------------------------------------"
         echo
-        echo "./configure CFLAGS='-g -O0 -Wp,-U_FORTIFY_SOURCE' $args"
+        echo "./configure CFLAGS='-g -O0' $args"
         echo
 fi
         echo
 fi
index 7a3cd8751123a90439b8d1e9d9b35e2fecc7a68a..3566dac830a1d00bfc4eb24f3f0a535950c76015 100644 (file)
@@ -167,8 +167,10 @@ CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
         --param=ssp-buffer-size=4])
 AC_SUBST([OUR_CFLAGS], $with_cflags)
 
         --param=ssp-buffer-size=4])
 AC_SUBST([OUR_CFLAGS], $with_cflags)
 
-CC_CHECK_FLAGS_APPEND([with_cppflags], [CPPFLAGS], [\
-        -Wp,-D_FORTIFY_SOURCE=2])
+AS_CASE([$CFLAGS], [*-O[[12345\ ]]*], [
+        CC_CHECK_FLAGS_APPEND([with_cppflags], [CPPFLAGS], [\
+               -Wp,-D_FORTIFY_SOURCE=2])], [
+        AC_MSG_RESULT([skipping -D_FORTIFY_SOURCE, optimization not enabled])])
 AC_SUBST([OUR_CPPFLAGS], $with_cppflags)
 
 CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
 AC_SUBST([OUR_CPPFLAGS], $with_cppflags)
 
 CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\