From 8795741615e463cb2f4da92a94fe081e9adda138 Mon Sep 17 00:00:00 2001
From: "Kirill A. Korinsky" <kirill@korins.ky>
Date: Sun, 20 Feb 2022 02:28:51 +0100
Subject: [PATCH] Force to use C++11 on macOS 11+

The root cause is fixing linking issue on build like:

Undefined symbols for architecture x86_64:
  "_cfun", referenced from:
      ___cxx_global_var_init.101 in gencondmd.o
  "_const_int_rtx", referenced from:
      ___cxx_global_var_init.101 in gencondmd.o
  "_const_tiny_rtx", referenced from:
      ___cxx_global_var_init.101 in gencondmd.o
  "_epilogue_completed", referenced from:

See: https://trac.macports.org/ticket/64316
Signed-off-by: Kirill A. Korinsky <kirill@korins.ky>
---
 configure    | 8 +++++++-
 configure.ac | 8 +++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git configure configure
index 049090f755e..c9eadc536cf 100755
--- configure
+++ configure
@@ -5536,8 +5536,14 @@ esac
 
 # When bootstrapping with GCC, build stage 1 in C++98 mode to ensure that a
 # C++98 compiler can still start the bootstrap.
+# Anyway, for macOS 11+ force to use C++11.
 if test "$enable_bootstrap:$GXX" = "yes:yes"; then
-  CXX="$CXX -std=gnu++98"
+  case "${target}" in
+    *-*-darwin2*)
+      CXX="$CXX -std=c++11" ;;
+    *)
+      CXX="$CXX -std=gnu++98" ;;
+  esac
 fi
 
 # Used for setting $lt_cv_objdir
diff --git configure.ac configure.ac
index 292bdeab64b..4e0a79f3756 100644
--- configure.ac
+++ configure.ac
@@ -1467,8 +1467,14 @@ esac
 
 # When bootstrapping with GCC, build stage 1 in C++98 mode to ensure that a
 # C++98 compiler can still start the bootstrap.
+# Anyway, for macOS 11+ force to use C++11.
 if test "$enable_bootstrap:$GXX" = "yes:yes"; then
-  CXX="$CXX -std=gnu++98"
+  case "${target}" in
+    *-*-darwin2*)
+      CXX="$CXX -std=c++11" ;;
+    *)
+      CXX="$CXX -std=gnu++98" ;;
+  esac
 fi
 
 # Used for setting $lt_cv_objdir
-- 
2.42.1

