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