[Libvir] PATCH 4/5: Change compiler flags detection

Daniel P. Berrange berrange at redhat.com
Tue Sep 18 01:40:19 UTC 2007


We previously added a --disable-stack-protector arg to explicitly disable
the use of GCC's stack protector which is enabled when the FORTIFY_SOURCE
flag is used.

This is sub-optimal since the user will still get compile failures when 
running configure for first time, and if they're lucky will they find out
about the precense of the --disable-stack-protector arg & infer what it
might do.

There were a couple of problems I identified

 - Even if giving  --enable-compiler-warnings=no we would still set
   FORTIFY_SOURCE and related flags.
 - Our test for compiler flags only tried compiling, but not linking. The
   latter is what seemed to fail on Debian.

The attached patch removes the --disable-stack-protector arg to configure,
instead allowing use of --enable-compiler-warnings=no. It also makes sure 
to test linking with the desired flags, so that the default behaviour ought
to work correctly.

I'd appreciate someone with a Debian box verifying this theory...

Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 
-------------- next part --------------
diff -r a952a78759d7 acinclude.m4
--- a/acinclude.m4	Mon Sep 17 04:15:38 2007 -0400
+++ b/acinclude.m4	Mon Sep 17 04:22:28 2007 -0400
@@ -19,21 +19,22 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
 
     warnCFLAGS=
 
-    try_compiler_flags="-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fasynchronous-unwind-tables"
+    common_flags="-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fasynchronous-unwind-tables"
 
     case "$enable_compile_warnings" in
     no)
 	;;
     minimum)
-	try_compiler_flags="$try_compiler_flags -Wall"
+	try_compiler_flags="$try_compiler_flags -Wall $common_flags"
 	;;
     yes)
-	try_compiler_flags="$try_compiler_flags -Wall -Wmissing-prototypes"
+	try_compiler_flags="$try_compiler_flags -Wall -Wmissing-prototypes $common_flags"
 	;;
     maximum|error)
 	try_compiler_flags="$try_compiler_flags -Wall -Wmissing-prototypes -Wnested-externs -Wpointer-arith"
         try_compiler_flags="$try_compiler_flags -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return"
 	try_compiler_flags="$try_compiler_flags -Wstrict-prototypes -Winline -Wredundant-decls -Wno-sign-compare"
+        try_compiler_flags="$try_compiler_flags $common_flags"
 	if test "$enable_compile_warnings" = "error" ; then
 	    try_compiler_flags="$try_compiler_flags -Werror"
 	fi
@@ -48,7 +49,7 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
 	SAVE_CFLAGS="$CFLAGS"
 	CFLAGS="$CFLAGS $option"
 	AC_MSG_CHECKING([whether gcc understands $option])
-	AC_TRY_COMPILE([], [],
+	AC_TRY_LINK([], [],
 		has_option=yes,
 		has_option=no,)
 	CFLAGS="$SAVE_CFLAGS"
diff -r a952a78759d7 configure.in
--- a/configure.in	Mon Sep 17 04:15:38 2007 -0400
+++ b/configure.in	Mon Sep 17 04:23:03 2007 -0400
@@ -101,16 +101,6 @@ AC_ARG_ENABLE(debug,
                              [enable debugging output]),[],[enable_debug=no])
 if test x"$enable_debug" = x"yes"; then
    AC_DEFINE(ENABLE_DEBUG, [], [whether debugging is enabled])
-fi
-
-dnl --disable-stack-protector
-AC_ARG_ENABLE(stack-protector,
-	      AC_HELP_STRING([--disable-stack-protector],
-			     [disable stack protector]),
-			     [],
-			     [enable_stack_protector=yes])
-if test x"$enable_stack_protector" = x"yes"; then
-    CFLAGS="$CFLAGS -fstack-protector --param=ssp-buffer-size=4"
 fi
 
 


More information about the libvir-list mailing list