Blame SOURCES/libva-2.11.0-fstack-protector-strong.patch

93f5fa
diff --git a/configure.ac b/configure.ac
93f5fa
index 878284d..9e2ba4d 100644
93f5fa
--- a/configure.ac
93f5fa
+++ b/configure.ac
93f5fa
@@ -214,21 +214,46 @@ AC_SEARCH_LIBS([dlopen], [dl], [], [
93f5fa
   AC_MSG_ERROR([unable to find the dlopen() function])
93f5fa
 ])
93f5fa
 
93f5fa
-# Check for -fstack-protector
93f5fa
-ssp_cc=yes
93f5fa
+# Check for -fstack-protector and -fstack-protector-strong
93f5fa
+SSP_CC_FLAG=""
93f5fa
 if test "X$CC-cc" != "X"; then
93f5fa
-    AC_MSG_CHECKING([whether ${CC-cc} accepts -fstack-protector])
93f5fa
+    # Do not duplicate options in CFLAGS
93f5fa
+    ssp_sp_set=no
93f5fa
+    ssp_sps_set=no
93f5fa
+    for ssp_x in $CFLAGS; do
93f5fa
+        case "X$ssp_x" in
93f5fa
+            X-fstack-protector) ssp_sp_set=yes ;;
93f5fa
+            X-fstack-protector-strong) ssp_sps_set=yes ;;
93f5fa
+        esac
93f5fa
+    done
93f5fa
     ssp_old_cflags="$CFLAGS"
93f5fa
-    CFLAGS="$CFLAGS -fstack-protector"
93f5fa
-    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[alloca(100);]])], [], [ssp_cc=no])
93f5fa
+    # Prefer -fstack-protector-strong over -fstack-protector
93f5fa
+    if test "X$ssp_sps_set" = "Xno"; then
93f5fa
+        SSP_CC_FLAG="-fstack-protector-strong"
93f5fa
+    fi
93f5fa
+    AC_MSG_CHECKING([whether ${CC-cc} accepts -fstack-protector-strong])
93f5fa
+    CFLAGS="$ssp_old_cflags $SSP_CC_FLAG"
93f5fa
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[alloca(100);]])], [ssp_cc=yes], [ssp_cc=no])
93f5fa
     AC_MSG_RESULT([$ssp_cc])
93f5fa
     if test "X$ssp_cc" = "Xno"; then
93f5fa
-        CFLAGS="$ssp_old_cflags"
93f5fa
-    else
93f5fa
+        # Fallback to -fstack-protector
93f5fa
+        if test "X$ssp_sp_set" = "Xno"; then
93f5fa
+            SSP_CC_FLAG="-fstack-protector"
93f5fa
+        fi
93f5fa
+        AC_MSG_CHECKING([whether ${CC-cc} accepts -fstack-protector])
93f5fa
+        CFLAGS="$ssp_old_cflags $SSP_CC_FLAG"
93f5fa
+        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[alloca(100);]])], [ssp_cc=yes], [ssp_cc=no])
93f5fa
+        AC_MSG_RESULT([$ssp_cc])
93f5fa
+        if test "X$ssp_cc" = "Xno"; then
93f5fa
+            SSP_CC_FLAG=""
93f5fa
+        fi
93f5fa
+    fi
93f5fa
+    CFLAGS="$ssp_old_cflags $SSP_CC_FLAG"
93f5fa
+    if test "X$ssp_cc" = "Xyes"; then
93f5fa
         AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
93f5fa
     fi
93f5fa
 fi
93f5fa
-AM_CONDITIONAL(USE_SSP, test "$ssp_cc" = "yes")
93f5fa
+AC_SUBST(SSP_CC_FLAG)
93f5fa
 
93f5fa
 # Check for DRM (mandatory)
93f5fa
 LIBDRM_VERSION=libdrm_version
93f5fa
diff --git a/va/Makefile.am b/va/Makefile.am
93f5fa
index 0d8eff1..5ee49c4 100644
93f5fa
--- a/va/Makefile.am
93f5fa
+++ b/va/Makefile.am
93f5fa
@@ -83,9 +83,7 @@ libva_cflags = \
93f5fa
 	-Wall			\
93f5fa
 	$(NULL)
93f5fa
 
93f5fa
-if USE_SSP
93f5fa
-libva_cflags += -fstack-protector
93f5fa
-endif
93f5fa
+libva_cflags += $(SSP_CC_FLAG)
93f5fa
 
93f5fa
 lib_LTLIBRARIES			= libva.la
93f5fa
 libvaincludedir			= ${includedir}/va