dd2565
From c8ccdbfe1e45cb3b832109d644296c0a3b3e0b59 Mon Sep 17 00:00:00 2001
dd2565
From: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
dd2565
Date: Sun, 2 Sep 2018 03:49:31 +0000
dd2565
Subject: [PATCH] configure.ac: -fstack-protector-strong
dd2565
dd2565
* configure.ac: use -fstack-protector-strong if available instead of
dd2565
  -fstack-protector conditionally.  [ruby-core:88788] [Misc #15053]
dd2565
dd2565
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
dd2565
---
dd2565
 configure.ac | 17 ++++++++++-------
dd2565
 1 file changed, 10 insertions(+), 7 deletions(-)
dd2565
dd2565
diff --git a/configure.ac b/configure.ac
dd2565
index 9328fa532de0..b8ee57239215 100644
dd2565
--- a/configure.ac
dd2565
+++ b/configure.ac
dd2565
@@ -837,15 +837,18 @@ AS_IF([test "$GCC" = yes], [
dd2565
 	stack_protector=no
dd2565
     ])
dd2565
     AS_IF([test -z "${stack_protector+set}"], [
dd2565
-	RUBY_TRY_CFLAGS(-fstack-protector, [stack_protector=yes], [stack_protector=no])
dd2565
-	AS_IF([test "x$stack_protector" = xyes], [
dd2565
-	    RUBY_TRY_LDFLAGS(-fstack-protector, [], [stack_protector=broken])
dd2565
+	AS_FOR(option, opt, [-fstack-protector-strong -fstack-protector], [
dd2565
+	    RUBY_TRY_CFLAGS(option, [stack_protector=yes])
dd2565
+	    AS_IF([test "x$stack_protector" = xyes], [
dd2565
+		RUBY_TRY_LDFLAGS(option, [], [stack_protector=])
dd2565
+	    ])
dd2565
+	    AS_IF([test "x$stack_protector" = xyes], [stack_protector=option; break])
dd2565
 	])
dd2565
     ])
dd2565
-    AS_IF([test "x$stack_protector" = xyes], [
dd2565
-	RUBY_APPEND_OPTION(XCFLAGS, -fstack-protector)
dd2565
-	RUBY_APPEND_OPTION(XLDFLAGS, -fstack-protector)
dd2565
-	RUBY_APPEND_OPTION(LDFLAGS, -fstack-protector)
dd2565
+    AS_CASE(["$stack_protector"], [-*], [
dd2565
+	RUBY_APPEND_OPTION(XCFLAGS, $stack_protector)
dd2565
+	RUBY_APPEND_OPTION(XLDFLAGS, $stack_protector)
dd2565
+	RUBY_APPEND_OPTION(LDFLAGS, $stack_protector)
dd2565
     ])
dd2565
 
dd2565
     AS_CASE("${compress_debug_sections:-zlib}",