diff --git a/.gcc.metadata b/.gcc.metadata
index 68a6e2e..23ba6a7 100644
--- a/.gcc.metadata
+++ b/.gcc.metadata
@@ -1,4 +1,4 @@
-c4e8551566b16e8189657d1cb7739b477ee7af6a SOURCES/gcc-11.2.1-20211019.tar.xz
+2e5c6969d43215a06ef6f85e547291cd58bcbbeb SOURCES/gcc-11.2.1-20211203.tar.xz
 bbffc5a2b05e4f0c97e882f96c448504491dc4ed SOURCES/isl-0.18.tar.bz2
 6ec33952e824e837fef0e829c93d39d6a507082f SOURCES/newlib-cygwin-50e2a63b04bdd018484605fbb954fd1bd5147fa0.tar.xz
 0e0c6f8d68ab0878f02287ac082c1077c831cd81 SOURCES/nvptx-tools-5f6f343a302d620b0868edab376c00b15741e39e.tar.xz
diff --git a/.gitignore b/.gitignore
index 88a989a..e96d345 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-SOURCES/gcc-11.2.1-20211019.tar.xz
+SOURCES/gcc-11.2.1-20211203.tar.xz
 SOURCES/isl-0.18.tar.bz2
 SOURCES/newlib-cygwin-50e2a63b04bdd018484605fbb954fd1bd5147fa0.tar.xz
 SOURCES/nvptx-tools-5f6f343a302d620b0868edab376c00b15741e39e.tar.xz
diff --git a/SOURCES/gcc11-dg-ice-fixes.patch b/SOURCES/gcc11-dg-ice-fixes.patch
new file mode 100644
index 0000000..33d0bc4
--- /dev/null
+++ b/SOURCES/gcc11-dg-ice-fixes.patch
@@ -0,0 +1,83 @@
+diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-ice-1.c b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-ice-1.c
+index 8c3884bdc00..141f089d4f8 100644
+--- a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-ice-1.c
++++ b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-ice-1.c
+@@ -1,7 +1,7 @@
+ /* Test OpenACC 'kernels' construct decomposition.  */
+ 
+ /* { dg-additional-options "-fopt-info-omp-all" } */
+-/* { dg-additional-options "-fchecking --param=openacc-kernels=decompose" } */
++/* { dg-additional-options "-fno-report-bug -fchecking --param=openacc-kernels=decompose" } */
+ /* { dg-ice "TODO" }
+    { dg-prune-output "during GIMPLE pass: omplower" } */
+ 
+diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-ice-2.c b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-ice-2.c
+index 8bf60a9a509..a07e0a42116 100644
+--- a/gcc/testsuite/c-c++-common/goacc/kernels-decompose-ice-2.c
++++ b/gcc/testsuite/c-c++-common/goacc/kernels-decompose-ice-2.c
+@@ -1,6 +1,6 @@
+ /* Test OpenACC 'kernels' construct decomposition.  */
+ 
+-/* { dg-additional-options "-fchecking --param=openacc-kernels=decompose" } */
++/* { dg-additional-options "-fno-report-bug -fchecking --param=openacc-kernels=decompose" } */
+ /* { dg-ice "TODO" }
+    { dg-prune-output "during GIMPLE pass: omplower" } */
+ 
+diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-52830.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-52830.C
+index eae0d8c377b..ed37f95e865 100644
+--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-52830.C
++++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-52830.C
+@@ -1,6 +1,6 @@
+ // PR c++/52830
+ // { dg-do compile { target c++11 } }
+-// { dg-additional-options "-fchecking" }
++// { dg-additional-options "-fchecking -fno-report-bug" }
+ // { dg-ice "comptypes" }
+ 
+ template<bool b> struct eif { typedef void type; };
+diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-88982.C b/gcc/testsuite/g++.dg/cpp0x/vt-88982.C
+index 7a868233d73..45307a63483 100644
+--- a/gcc/testsuite/g++.dg/cpp0x/vt-88982.C
++++ b/gcc/testsuite/g++.dg/cpp0x/vt-88982.C
+@@ -1,6 +1,6 @@
+ // PR c++/88982
+ // { dg-do compile { target c++11 } }
+-// { dg-additional-options "-fchecking" }
++// { dg-additional-options "-fchecking -fno-report-bug" }
+ // { dg-ice "tsubst_pack_expansion" }
+ 
+ template<typename...Ts> struct A {
+diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn61.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn61.C
+index bed5ea0cfc0..cb235bf891a 100644
+--- a/gcc/testsuite/g++.dg/cpp1y/auto-fn61.C
++++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn61.C
+@@ -1,6 +1,6 @@
+ // PR c++/88003
+ // { dg-do compile { target c++14 } }
+-// { dg-additional-options "-fchecking" }
++// { dg-additional-options "-fchecking -fno-report-bug" }
+ // { dg-ice "poplevel_class" }
+ 
+ auto test() {
+diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda26.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda26.C
+index 0cdb400d21c..8f17cca31dd 100644
+--- a/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda26.C
++++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda26.C
+@@ -1,6 +1,6 @@
+ // PR c++/87765
+ // { dg-do compile { target c++17 } }
+-// { dg-additional-options "-fchecking" }
++// { dg-additional-options "-fchecking -fno-report-bug" }
+ // { dg-ice "cxx_eval_constant_expression" }
+ 
+ template <int N>
+diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/declare-vla-kernels-decompose-ice-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/declare-vla-kernels-decompose-ice-1.c
+index 0777b612b63..53abbe2db83 100644
+--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/declare-vla-kernels-decompose-ice-1.c
++++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/declare-vla-kernels-decompose-ice-1.c
+@@ -1,4 +1,4 @@
+-/* { dg-additional-options "--param=openacc-kernels=decompose" } */
++/* { dg-additional-options "--param=openacc-kernels=decompose -fno-report-bug" } */
+ /* Hopefully, this is the same issue as '../../../gcc/testsuite/c-c++-common/goacc/kernels-decompose-ice-1.c'.
+    { dg-ice "TODO" }
+    TODO { dg-prune-output "during GIMPLE pass: omplower" }
diff --git a/SOURCES/gcc11-pr102642.patch b/SOURCES/gcc11-pr102642.patch
deleted file mode 100644
index 598794b..0000000
--- a/SOURCES/gcc11-pr102642.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-2021-10-11  Jakub Jelinek  <jakub@redhat.com>
-
-	PR c++/102642
-	* name-lookup.c (push_local_extern_decl_alias): Don't call
-	set_decl_tls_model on error_mark_node.
-	* parser.c (cp_parser_omp_declare_target): Likewise.
-
-	* g++.dg/tls/pr102642.C: New test.
-
---- gcc/cp/name-lookup.c.jj	2021-10-01 10:30:07.674588541 +0200
-+++ gcc/cp/name-lookup.c	2021-10-11 12:43:39.261051228 +0200
-@@ -3474,7 +3474,9 @@ push_local_extern_decl_alias (tree decl)
- 	  push_nested_namespace (ns);
- 	  alias = do_pushdecl (alias, /* hiding= */true);
- 	  pop_nested_namespace (ns);
--	  if (VAR_P (decl) && CP_DECL_THREAD_LOCAL_P (decl))
-+	  if (VAR_P (decl)
-+	      && CP_DECL_THREAD_LOCAL_P (decl)
-+	      && alias != error_mark_node)
- 	    set_decl_tls_model (alias, DECL_TLS_MODEL (decl));
- 	}
-     }
---- gcc/cp/parser.c.jj	2021-10-09 10:14:24.043098112 +0200
-+++ gcc/cp/parser.c	2021-10-11 12:47:21.220874667 +0200
-@@ -45665,7 +45666,8 @@ cp_parser_omp_declare_target (cp_parser
-       if (VAR_OR_FUNCTION_DECL_P (t)
- 	  && DECL_LOCAL_DECL_P (t)
- 	  && DECL_LANG_SPECIFIC (t)
--	  && DECL_LOCAL_DECL_ALIAS (t))
-+	  && DECL_LOCAL_DECL_ALIAS (t)
-+	  && DECL_LOCAL_DECL_ALIAS (t) != error_mark_node)
- 	handle_omp_declare_target_clause (c, DECL_LOCAL_DECL_ALIAS (t),
- 					  device_type);
-     }
---- gcc/testsuite/g++.dg/tls/pr102642.C.jj	2021-10-11 13:00:35.889503002 +0200
-+++ gcc/testsuite/g++.dg/tls/pr102642.C	2021-10-11 13:00:20.388724721 +0200
-@@ -0,0 +1,10 @@
-+// PR c++/102642
-+// { dg-do compile { target c++11 } }
-+
-+thread_local int *z;		// { dg-message "previous declaration" }
-+
-+void
-+foo ()
-+{
-+  extern thread_local int z;	// { dg-error "conflicting declaration" }
-+}
diff --git a/SOURCES/gcc11-stringify-__VA_OPT__-2.patch b/SOURCES/gcc11-stringify-__VA_OPT__-2.patch
new file mode 100644
index 0000000..987f738
--- /dev/null
+++ b/SOURCES/gcc11-stringify-__VA_OPT__-2.patch
@@ -0,0 +1,197 @@
+libcpp: Fix up #__VA_OPT__ handling [PR103415]
+
+stringify_arg uses pfile->u_buff to create the string literal.
+Unfortunately, paste_tokens -> _cpp_lex_direct -> lex_number -> _cpp_unaligned_alloc
+can in some cases use pfile->u_buff too, which results in losing everything
+prepared for the string literal until the token pasting.
+
+The following patch fixes that by not calling paste_token during the
+construction of the string literal, but doing that before.  All the tokens
+we are processing have been pushed into a token buffer using
+tokens_buff_add_token so it is fine if we paste some of them in that buffer
+(successful pasting creates a new token in that buffer), move following
+tokens if any to make it contiguous, pop (throw away) the extra tokens at
+the end and then do stringify_arg.
+
+Also, paste_tokens now copies over PREV_WHITE and PREV_FALLTHROUGH flags
+from the original lhs token to the replacement token.  Copying that way
+the PREV_WHITE flag is needed for the #__VA_OPT__ handling and copying
+over PREV_FALLTHROUGH fixes the new Wimplicit-fallthrough-38.c test.
+
+2021-12-01  Jakub Jelinek  <jakub@redhat.com>
+
+	PR preprocessor/103415
+libcpp/
+	* macro.c (stringify_arg): Remove va_opt argument and va_opt handling.
+	(paste_tokens): On successful paste or in PREV_WHITE and
+	PREV_FALLTHROUGH flags from the *plhs token to the new token.
+	(replace_args): Adjust stringify_arg callers.  For #__VA_OPT__,
+	perform token pasting in a separate loop before stringify_arg call.
+gcc/testsuite/
+	* c-c++-common/cpp/va-opt-8.c: New test.
+	* c-c++-common/Wimplicit-fallthrough-38.c: New test.
+
+--- libcpp/macro.c.jj
++++ libcpp/macro.c
+@@ -295,7 +295,7 @@ static cpp_context *next_context (cpp_reader *);
+ static const cpp_token *padding_token (cpp_reader *, const cpp_token *);
+ static const cpp_token *new_string_token (cpp_reader *, uchar *, unsigned int);
+ static const cpp_token *stringify_arg (cpp_reader *, const cpp_token **,
+-				       unsigned int, bool);
++				       unsigned int);
+ static void paste_all_tokens (cpp_reader *, const cpp_token *);
+ static bool paste_tokens (cpp_reader *, location_t,
+ 			  const cpp_token **, const cpp_token *);
+@@ -834,8 +834,7 @@ cpp_quote_string (uchar *dest, const uchar *src, unsigned int len)
+ /* Convert a token sequence FIRST to FIRST+COUNT-1 to a single string token
+    according to the rules of the ISO C #-operator.  */
+ static const cpp_token *
+-stringify_arg (cpp_reader *pfile, const cpp_token **first, unsigned int count,
+-	       bool va_opt)
++stringify_arg (cpp_reader *pfile, const cpp_token **first, unsigned int count)
+ {
+   unsigned char *dest;
+   unsigned int i, escape_it, backslash_count = 0;
+@@ -852,24 +851,6 @@ stringify_arg (cpp_reader *pfile, const cpp_token **first, unsigned int count,
+     {
+       const cpp_token *token = first[i];
+ 
+-      if (va_opt && (token->flags & PASTE_LEFT))
+-	{
+-	  location_t virt_loc = pfile->invocation_location;
+-	  const cpp_token *rhs;
+-	  do
+-	    {
+-	      if (i == count)
+-		abort ();
+-	      rhs = first[++i];
+-	      if (!paste_tokens (pfile, virt_loc, &token, rhs))
+-		{
+-		  --i;
+-		  break;
+-		}
+-	    }
+-	  while (rhs->flags & PASTE_LEFT);
+-	}
+-
+       if (token->type == CPP_PADDING)
+ 	{
+ 	  if (source == NULL
+@@ -1003,6 +984,7 @@ paste_tokens (cpp_reader *pfile, location_t location,
+       return false;
+     }
+ 
++  lhs->flags |= (*plhs)->flags & (PREV_WHITE | PREV_FALLTHROUGH);
+   *plhs = lhs;
+   _cpp_pop_buffer (pfile);
+   return true;
+@@ -1945,8 +1927,7 @@ replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro,
+ 	if (src->flags & STRINGIFY_ARG)
+ 	  {
+ 	    if (!arg->stringified)
+-	      arg->stringified = stringify_arg (pfile, arg->first, arg->count,
+-						false);
++	      arg->stringified = stringify_arg (pfile, arg->first, arg->count);
+ 	  }
+ 	else if ((src->flags & PASTE_LEFT)
+ 		 || (src != macro->exp.tokens && (src[-1].flags & PASTE_LEFT)))
+@@ -2066,11 +2047,46 @@ replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro,
+ 		{
+ 		  unsigned int count
+ 		    = start ? paste_flag - start : tokens_buff_count (buff);
+-		  const cpp_token *t
+-		    = stringify_arg (pfile,
+-				     start ? start + 1
+-				     : (const cpp_token **) (buff->base),
+-				     count, true);
++		  const cpp_token **first
++		    = start ? start + 1
++			    : (const cpp_token **) (buff->base);
++		  unsigned int i, j;
++
++		  /* Paste any tokens that need to be pasted before calling
++		     stringify_arg, because stringify_arg uses pfile->u_buff
++		     which paste_tokens can use as well.  */
++		  for (i = 0, j = 0; i < count; i++, j++)
++		    {
++		      const cpp_token *token = first[i];
++
++		      if (token->flags & PASTE_LEFT)
++			{
++			  location_t virt_loc = pfile->invocation_location;
++			  const cpp_token *rhs;
++			  do
++			    {
++			      if (i == count)
++				abort ();
++			      rhs = first[++i];
++			      if (!paste_tokens (pfile, virt_loc, &token, rhs))
++				{
++				  --i;
++				  break;
++				}
++			    }
++			  while (rhs->flags & PASTE_LEFT);
++			}
++
++		      first[j] = token;
++		    }
++		  if (j != i)
++		    {
++		      while (i-- != j)
++			tokens_buff_remove_last_token (buff);
++		      count = j;
++		    }
++
++		  const cpp_token *t = stringify_arg (pfile, first, count);
+ 		  while (count--)
+ 		    tokens_buff_remove_last_token (buff);
+ 		  if (src->flags & PASTE_LEFT)
+--- gcc/testsuite/c-c++-common/cpp/va-opt-8.c.jj
++++ gcc/testsuite/c-c++-common/cpp/va-opt-8.c
+@@ -0,0 +1,18 @@
++/* PR preprocessor/103415 */
++/* { dg-do run } */
++/* { dg-options "-std=gnu99" { target c } } */
++/* { dg-options "-std=c++20" { target c++ } } */
++
++#define n(x, ...) = #__VA_OPT__(x##3)
++#define o(x, ...) #__VA_OPT__(x##__VA_ARGS__##9)
++const char *c n(1 2, 4);
++const char *d = o(5  6, 7	8);
++
++int
++main ()
++{
++  if (__builtin_strcmp (c, "1 23")
++      || __builtin_strcmp (d, "5 67 89"))
++    __builtin_abort ();
++  return 0;
++}
+--- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-38.c.jj
++++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-38.c
+@@ -0,0 +1,24 @@
++/* { dg-do compile } */
++/* { dg-options "-Wimplicit-fallthrough=3" } */
++
++#define FOO \
++int				\
++foo (int a)			\
++{				\
++  switch (a)			\
++    {				\
++    case 1:			\
++      ++a;			\
++      /* FALLTHRU */		\
++    case 2:			\
++      ++a;			\
++      /* FALLTHRU */		\
++    ca##se 3:			\
++      ++a;			\
++    default:			\
++      break;			\
++    }				\
++  return a;			\
++}
++
++FOO
diff --git a/SPECS/gcc.spec b/SPECS/gcc.spec
index 919bb56..e82c055 100644
--- a/SPECS/gcc.spec
+++ b/SPECS/gcc.spec
@@ -1,10 +1,10 @@
-%global DATE 20211019
-%global gitrev 0990a48aaf68b56a3737fdb290328df1da9095cc
+%global DATE 20211203
+%global gitrev e41308252e835ddedcabfd4a98240080c6583a43
 %global gcc_version 11.2.1
 %global gcc_major 11
 # Note, gcc_release must be integer, if you want to add suffixes to
 # %%{release}, append them after %%{gcc_release} on Release: line.
-%global gcc_release 6
+%global gcc_release 7
 %global nvptx_tools_gitrev 5f6f343a302d620b0868edab376c00b15741e39e
 %global newlib_cygwin_gitrev 50e2a63b04bdd018484605fbb954fd1bd5147fa0
 %global _unpackaged_files_terminate_build 0
@@ -115,10 +115,29 @@
 %ifarch x86_64
 %global multilib_32_arch i686
 %endif
+
+# Use "--without annobin-plugin" to disable the building of the annobin plugin for GCC.
+%bcond_without annobin_plugin
+
+# Use "--without tests" to disable the testsuite.
+# Not technically needed for building the annobin plugin, but this has been added
+# because not running the testsuites makes building the gcc rpms a *lot* faster.
+%bcond_without tests
+
+# The next line has been stolen from redhat-rpm-config.spec.
+# We install the version info into a file in this directory, rather than
+# gcc's plugin directory, because there is no reliable way for redhat-rpm-config
+# to determine the name of gcc's plugin directory.
+# FIXME: We need a way to cope if more than one version of gcc is installed.
+%global rrcdir /usr/lib/rpm/redhat
+
+# A file that records information about the built gcc-annobin plugin.
+%global gver %{rrcdir}/gcc-annobin-plugin-version-info
+
 Summary: Various compilers (C, C++, Objective-C, ...)
 Name: gcc
 Version: %{gcc_version}
-Release: %{gcc_release}.1%{?dist}
+Release: %{gcc_release}.4%{?dist}
 # libgcc, libgfortran, libgomp, libstdc++ and crtstuff have
 # GCC Runtime Exception.
 License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
@@ -205,6 +224,14 @@ BuildRequires: libunwind >= 0.98
 BuildRequires: doxygen >= 1.7.1
 BuildRequires: graphviz, dblatex, texlive-collection-latex, docbook5-style-xsl
 %endif
+
+%if %{with annobin_plugin}
+# Starting with release 10.01 annobin fixed a bug in its configure scripts which prevented them from working with a built but not installed compiler
+BuildRequires: annobin >= 10.01
+# See The %%install phase for why we need xz.
+BuildRequires: xz
+%endif
+
 Requires: cpp = %{version}-%{release}
 # Need .eh_frame ld optimizations
 # Need proper visibility support
@@ -268,8 +295,9 @@ Patch12: gcc11-d-shared-libphobos.patch
 Patch14: gcc11-libgcc-link.patch
 Patch15: gcc11-pr101786.patch
 Patch16: gcc11-stringify-__VA_OPT__.patch
-Patch17: gcc11-pr102642.patch
+Patch17: gcc11-stringify-__VA_OPT__-2.patch
 Patch18: gcc11-Wbidi-chars.patch
+Patch19: gcc11-dg-ice-fixes.patch
 
 Patch100: gcc11-fortran-fdec-duplicates.patch
 Patch101: gcc11-fortran-flogical-as-integer.patch
@@ -795,8 +823,9 @@ to NVidia PTX capable devices if available.
 %patch14 -p0 -b .libgcc-link~
 %patch15 -p0 -b .pr101786~
 %patch16 -p0 -b .stringify-__VA_OPT__~
-%patch17 -p0 -b .pr102642~
+%patch17 -p0 -b .stringify-__VA_OPT__-2~
 %patch18 -p1 -b .bidi~
+%patch19 -p1 -b .ice~
 
 %if 0%{?rhel} >= 9
 %patch100 -p1 -b .fortran-fdec-duplicates~
@@ -1205,6 +1234,82 @@ done)
 rm -f rpm.doc/changelogs/gcc/ChangeLog.[1-9]
 find rpm.doc -name \*ChangeLog\* | xargs bzip2 -9
 
+%if %{with annobin_plugin}
+# Get the annobin sources.  Note these are not added to the rpm as SOURCE4
+# because if they were the build phase would try to include them as part of
+# gcc itself, and this causes problems.  Instead we locate the sources in
+# the buildroot.  They should have been put there when annobin was installed.
+
+pushd %{_builddir}
+
+%global annobin_source_dir %{_usrsrc}/annobin
+
+if [ -d %{annobin_source_dir} ]
+then
+    # Unpack the sources.
+    echo "Unpacking annobin sources"
+    rm -fr annobin-*
+    tar xvf %{annobin_source_dir}/latest-annobin.tar.xz
+else
+    echo "Unable to locate annobin sources (expected to find: %{annobin_source_dir}/latest-annobin.tar.xz)"
+    echo "These should be provided by installing the annobin-plugin-gcc package"
+    exit 1
+fi
+
+# Setting this as a local symbol because using %%global does not appear to work.
+annobin_dir=$(find . -maxdepth 1 -type d -name "annobin*")
+
+# Now build the annobin plugin using the just built compiler.
+echo "annobin directory = ${annobin_dir}"
+cd ${annobin_dir}
+
+# Work out where this version of gcc stores its plugins.
+%global ANNOBIN_GCC_PLUGIN_DIR  %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/plugin
+
+CONFIG_ARGS="--quiet"
+CONFIG_ARGS="$CONFIG_ARGS --with-gcc-plugin-dir=%{ANNOBIN_GCC_PLUGIN_DIR}"
+CONFIG_ARGS="$CONFIG_ARGS --without-annocheck"
+CONFIG_ARGS="$CONFIG_ARGS --without-tests"
+
+comp_dir="%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/gcc/"
+ccompiler="%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/gcc/xgcc -B $comp_dir"
+cxxcompiler="%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/gcc/xg++ -B $comp_dir"
+
+comp_flags="%build_cflags"
+comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/gcc"
+comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/gcc/"
+comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/%{gcc_target_platform}/libstdc++-v3/include"
+comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/%{gcc_target_platform}/libstdc++-v3/include/%{gcc_target_platform}"
+comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/libstdc++-v3/libsupc++"
+comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/include"
+comp_flags="$comp_flags -I %{_builddir}/gcc-%{version}-%{DATE}/libcpp/include"
+
+ld_flags="%build_ldflags"
+ld_flags="$ld_flags -L%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/libstdc++-v3/.libs"
+ld_flags="$ld_flags -L%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/%{gcc_target_platform}/libstdc++-v3/.libs"
+ld_flags="$ld_flags -L%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/%{gcc_target_platform}/libstdc++-v3/src/.libs"
+ld_flags="$ld_flags -L%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/libstdc++-v3/libsupc++/.libs"
+ld_flags="$ld_flags -L%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/%{gcc_target_platform}/libstdc++-v3/libsupc++/.libs"
+ld_flags="$ld_flags -L%{_builddir}/gcc-%{version}-%{DATE}/obj-%{gcc_target_platform}/%{gcc_target_platform}/libgcc/.libs"
+ld_flags="$ld_flags -Wl,-rpath,/usr/%{_lib}"
+
+# libtool works with CFLAGS but ignores LDFLAGS, so we have to combine them.
+comp_flags="$comp_flags $ld_flags"
+
+echo "Configuring the annobin plugin"
+CC="${ccompiler}" CFLAGS="${comp_flags}" \
+  CXX="${cxxcompiler}" CXXFLAGS="${comp_flags}" \
+  LDFLAGS="${ld_flags}" \
+  ./configure ${CONFIG_ARGS}  || cat config.log
+
+echo "Building the annobin plugin"
+make
+
+echo "Annobin plugin build complete"
+popd
+# endif for %{with annobin_plugin}
+%endif
+
 %install
 rm -rf %{buildroot}
 mkdir -p %{buildroot}
@@ -2001,6 +2106,74 @@ echo gcc-%{version}-%{release}.%{_arch} > $FULLPATH/rpmver
 ln -s ../../libexec/gcc/%{gcc_target_platform}/%{gcc_major}/liblto_plugin.so \
   %{buildroot}%{_libdir}/bfd-plugins/
 
+%if %{with annobin_plugin}
+
+# Rename the plugin to gcc-annobin.
+mkdir -p %{buildroot}%{ANNOBIN_GCC_PLUGIN_DIR}
+pushd    %{buildroot}%{ANNOBIN_GCC_PLUGIN_DIR}
+
+annobin_dir=$(find %{_builddir} -maxdepth 1 -type d -name "annobin*")
+echo "annobin directory = ${annobin_dir}"
+
+cp ${annobin_dir}/gcc-plugin/.libs/annobin.so.0.0.0 gcc-annobin.so.0.0.0
+# Compress the plugin so that it cannot be stripped or examined by check-rpath.
+# The problem with check-rpath is that the plugin contains a path to the built
+# but not installed version of the libstdc++ library, and this is insecure.
+# In practice this is not a problem as the plugin does not load the library, but
+# there is no way to tell check-rpath this fact.
+xz -9 gcc-annobin.so.0.0.0
+
+rm -f gcc-annobin.so.0 gcc-annobin.so
+ln -s gcc-annobin.so.0.0.0 gcc-annobin.so.0
+ln -s gcc-annobin.so.0.0.0 gcc-annobin.so
+
+# Record information about the version of the compiler that built the plugin.
+#
+# Note - we cannot just store %%{gcc_version} and %%{gcc_release} as sometimes
+# the gcc rpm version changes without the NVR being altered.  See BZ #2030671
+# for more discussion on this.
+#
+# Note that when performing a scratch build %%{release} will not contain
+# a distribution tag.  Ie it would be "1-7" rather than "1-7.fc36".  This means
+# that if a scratch build is installed, eg into a mock chroot, then the logic
+# in redhat-rpm-config's redhat-annobin-plugin-select.sh script will always
+# select the gcc built plugin no matter what.  (Since the version string for
+# the gcc built plugin can never match the version string for the annobin
+# built plugin, as the annobin version string always includes a distribution
+# tag).  Sadly this is unavoidable.
+
+mkdir -p %{buildroot}%{rrcdir}
+echo "%{version}-%{release}" >  %{buildroot}%{gver}
+
+# Provide a more complete version information string on the second line.
+# This is not used by the comparison logic in the redhat-annobin-plugin-select.sh
+# script, but it does make the file more useful to humans.
+echo "%{ANNOBIN_GCC_PLUGIN_DIR}/gcc-annobin.so.0.0.0 was built by gcc version %{gcc_version}-%{gcc_release} from the ${annobin_dir} sources" >> %{buildroot}%{gver}
+popd
+# endif for %{with annobin_plugin}
+%endif
+
+%if %{with annobin_plugin}
+%post
+pushd %{ANNOBIN_GCC_PLUGIN_DIR} > /dev/null
+# Uncompress the annobin plugin now that the %%install phase is over.
+xz -d gcc-annobin.so.0.0.0.xz
+rm -f gcc-annobin.so.0 gcc-annobin.so
+ln -s gcc-annobin.so.0.0.0 gcc-annobin.so.0
+ln -s gcc-annobin.so.0.0.0 gcc-annobin.so
+popd > /dev/null
+%endif
+
+%if %{with annobin_plugin}
+%preun
+pushd %{ANNOBIN_GCC_PLUGIN_DIR} > /dev/null
+# Compress the annobin plugin before it is removed.  This avoids a warning from rpm.
+rm -f gcc-annobin.so.0 gcc-annobin.so
+xz -9 gcc-annobin.so.0.0.0
+popd > /dev/null
+%endif
+
+%if %{with tests}
 %check
 cd obj-%{gcc_target_platform}
 
@@ -2053,6 +2226,9 @@ tar cf - testlogs-%{_target_platform}-%{version}-%{release} | xz -9e \
   | uuencode testlogs-%{_target_platform}.tar.xz || :
 rm -rf testlogs-%{_target_platform}-%{version}-%{release}
 
+# endif for the if {with tests} above.
+%endif
+
 %post go
 %{_sbindir}/update-alternatives --install \
   %{_prefix}/bin/go go %{_prefix}/bin/go.gcc 92 \
@@ -2119,6 +2295,10 @@ end
 %ldconfig_scriptlets -n libgo
 
 %files -f %{name}.lang
+%if %{with annobin_plugin}
+%{ANNOBIN_GCC_PLUGIN_DIR}
+%{gver}
+%endif
 %{_prefix}/bin/cc
 %{_prefix}/bin/c89
 %{_prefix}/bin/c99
@@ -3145,6 +3325,45 @@ end
 %endif
 
 %changelog
+* Fri Jan  7 2022 Marek Polacek <polacek@redhat.com> 11.2.1-7.4
+- update annobin plugin patch (#2030667)
+
+* Tue Jan  4 2022 Marek Polacek <polacek@redhat.com> 11.2.1-7.3
+- fix dg-ice tests (#1996047)
+
+* Tue Jan  4 2022 Marek Polacek <polacek@redhat.com> 11.2.1-7.2
+- update annobin plugin patch (#2030667)
+
+* Thu Dec 16 2021 Marek Polacek <polacek@redhat.com> 11.2.1-7.1
+- build annobin plugin (patch by Nick Clifton) (#2030667)
+
+* Tue Dec  7 2021 Marek Polacek <polacek@redhat.com> 11.2.1-7
+- update from releases/gcc-11-branch (#1996858)
+  - PRs ada/100486, c++/70796, c++/92746, c++/93286, c++/94490, c++/102642,
+	c++/102786, debug/101378, debug/103046, debug/103315, fortran/87711,
+	fortran/87851, fortran/97896, fortran/99061, fortran/99348,
+	fortran/102521, fortran/102685, fortran/102715, fortran/102745,
+	fortran/102816, fortran/102817, fortran/102917, fortran/103137,
+	fortran/103138, fortran/103392, gcov-profile/100520, ipa/102714,
+	ipa/102762, ipa/103052, ipa/103246, ipa/103267, libstdc++/96416,
+	libstdc++/98421, libstdc++/100117, libstdc++/100153, libstdc++/100748,
+	libstdc++/101571, libstdc++/101608, libstdc++/102894,
+	libstdc++/103022, libstdc++/103086, libstdc++/103133,
+	libstdc++/103240, libstdc++/103381, middle-end/64888,
+	middle-end/101480, middle-end/102431, middle-end/102518,
+	middle-end/103059, middle-end/103181, middle-end/103248,
+	middle-end/103384, preprocessor/103130, rtl-optimization/102356,
+	rtl-optimization/102842, target/101985, target/102976, target/102991,
+	target/103205, target/103274, target/103275, testsuite/102690,
+	tree-optimization/100393, tree-optimization/102139,
+	tree-optimization/102505, tree-optimization/102572,
+	tree-optimization/102788, tree-optimization/102789,
+	tree-optimization/102798, tree-optimization/102970,
+	tree-optimization/103192, tree-optimization/103204,
+	tree-optimization/103237, tree-optimization/103255,
+	tree-optimization/103435
+- fix up #__VA_OPT__ handling (PR preprocessor/103415)
+
 * Mon Nov 29 2021 Marek Polacek <polacek@redhat.com> 11.2.1-6.1
 - add -Wbidi-chars patch (#2008393)