summaryrefslogtreecommitdiff
path: root/acinclude.m4
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2012-07-03 21:40:36 +0200
committerMarc-André Lureau <marcandre.lureau@gmail.com>2012-07-03 23:02:41 +0200
commit8d9a9ca521fc791eef1a503b95b68ab22ffaf4e1 (patch)
tree84810cbc961f4170fecc3719fceecc47f4d5a808 /acinclude.m4
parent4b310b03e9a4ad99ee8e941885117cbca5605acd (diff)
build: allow building with newer glibc-headers and -O0
Fix copied from libvirt, commit by Eric Blake. glibc 2.15 (on Fedora 17) coupled with explicit disabling of optimization during development dies a painful death: /usr/include/features.h:314:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] Work around this by only conditionally defining _FORTIFY_SOURCE, in the case where glibc can actually use it. The trick is using AH_VERBATIM instead of AC_DEFINE.
Diffstat (limited to 'acinclude.m4')
-rw-r--r--acinclude.m49
1 files changed, 8 insertions, 1 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 73b5a7b..0c308bc 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -19,7 +19,7 @@ AC_DEFUN([VIRT_VIEWER_COMPILE_WARNINGS],[
warnCFLAGS=
- try_compiler_flags="-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables"
+ try_compiler_flags="-fexceptions -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables"
case "$enable_compile_warnings" in
no)
@@ -44,6 +44,13 @@ AC_DEFUN([VIRT_VIEWER_COMPILE_WARNINGS],[
;;
esac
+ AH_VERBATIM([FORTIFY_SOURCE],
+ [/* Enable compile-time and run-time bounds-checking, and some warnings. */
+ #if defined __OPTIMIZE__ && __OPTIMIZE__
+ # define _FORTIFY_SOURCE 2
+ #endif
+ ])
+
compiler_flags=
for option in $try_compiler_flags; do
SAVE_CFLAGS="$CFLAGS"