[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [PATCH virt-viewer 01/25] 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.
---
 acinclude.m4 |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

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"
-- 
1.7.10.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]