Skip to contentSkip to conversation

configure: Make stack-protector test check both compile and link

PATCH In review Peter Maydell 2 participants 2 messages Apr 11, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configure: Make stack-protector test check both compile and link

Since we use the -fstack-protector argument at both compile and link time in the build, we must check that it works with both a compile and a link:
* MacOSX only fails in the compile step, not linking
* some gcc cross environments only fail at the link stage (if they require a libssp and it's not present for some reason)

---
 configure | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
configure +4 -1
index c85475f..69b9f56 100755
@@ -1448,7 +1448,10 @@ done
 if test "$stack_protector" != "no" ; then
   gcc_flags="-fstack-protector-strong -fstack-protector-all"
   for flag in $gcc_flags; do
-    if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC ; then
+    # We need to check both a compile and a link, since some compiler
+    # setups fail only on a .c->.o compile and some only at link time
+    if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
+       compile_prog "-Werror $flag" ""; then
       QEMU_CFLAGS="$QEMU_CFLAGS $flag"
       LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,$flag"
       break
Signature · 1 line
1.9.1
Tested-by on v1 1/1
#1 lore raw
Quoted 8 lines · Peter Maydell

Since we use the -fstack-protector argument at both compile and link time in the build, we must check that it works with both a compile and a link:
* MacOSX only fails in the compile step, not linking
* some gcc cross environments only fail at the link stage (if they require a libssp and it's not present for some reason)

yay! thanks!

Quoted 21 lines
---
 configure | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
configure +4 -1
index c85475f..69b9f56 100755
@@ -1448,7 +1448,10 @@ done
 if test "$stack_protector" != "no" ; then
   gcc_flags="-fstack-protector-strong -fstack-protector-all"
   for flag in $gcc_flags; do
-    if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC ; then
+    # We need to check both a compile and a link, since some compiler
+    # setups fail only on a .c->.o compile and some only at link time
+    if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
+       compile_prog "-Werror $flag" ""; then
       QEMU_CFLAGS="$QEMU_CFLAGS $flag"
       LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,$flag"
       break
Signature · 1 line
Alexey