1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

build: prefer -fstack-protector-strong to -all

Try -fstack-protector-strong first on Linux. If that fails,
fall back to -fstack-protector-all.
This commit is contained in:
Ján Tomko 2014-06-11 10:46:55 +02:00
parent 5567baa973
commit 046a441f3d

View File

@ -164,13 +164,14 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
dnl "error: -fstack-protector not supported for this target [-Werror]" dnl "error: -fstack-protector not supported for this target [-Werror]"
;; ;;
*-*-linux*) *-*-linux*)
dnl Fedora only uses -fstack-protector, but doesn't seem to dnl Prefer -fstack-protector-strong if it's available.
dnl be great overhead in adding -fstack-protector-all instead dnl There doesn't seem to be great overhead in adding
dnl -fstack-protector-all instead of -fstack-protector.
dnl dnl
dnl We also don't need ssp-buffer-size with -all, dnl We also don't need ssp-buffer-size with -all or -strong,
dnl since functions are protected regardless of buffer size. dnl since functions are protected regardless of buffer size.
dnl wantwarn="$wantwarn --param=ssp-buffer-size=4" dnl wantwarn="$wantwarn --param=ssp-buffer-size=4"
wantwarn="$wantwarn -fstack-protector-all" wantwarn="$wantwarn -fstack-protector-strong"
;; ;;
*-*-freebsd*) *-*-freebsd*)
dnl FreeBSD ships old gcc 4.2.1 which doesn't handle dnl FreeBSD ships old gcc 4.2.1 which doesn't handle
@ -201,6 +202,19 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
gl_WARN_ADD([$w]) gl_WARN_ADD([$w])
done done
case $host in
*-*-linux*)
dnl Fall back to -fstack-protector-all if -strong is not available
case $WARN_CFLAGS in
*-fstack-protector-strong*)
;;
*)
gl_WARN_ADD(["-fstack-protector-all"])
;;
esac
;;
esac
# Silence certain warnings in gnulib, and use improved glibc headers # Silence certain warnings in gnulib, and use improved glibc headers
AC_DEFINE([lint], [1], AC_DEFINE([lint], [1],
[Define to 1 if the compiler is checking for lint.]) [Define to 1 if the compiler is checking for lint.])