diff --git a/.gcc.metadata b/.gcc.metadata
index fba4cb1..68a6e2e 100644
--- a/.gcc.metadata
+++ b/.gcc.metadata
@@ -1,4 +1,4 @@
-8bb88a8a2cc72b6e4563e0e5e19f53ff09d72ee1 SOURCES/gcc-11.2.1-20210728.tar.xz
+c4e8551566b16e8189657d1cb7739b477ee7af6a SOURCES/gcc-11.2.1-20211019.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 200d9bb..88a989a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-SOURCES/gcc-11.2.1-20210728.tar.xz
+SOURCES/gcc-11.2.1-20211019.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-libgcc-hardened.patch b/SOURCES/gcc11-libgcc-hardened.patch
deleted file mode 100644
index 51f6c39..0000000
--- a/SOURCES/gcc11-libgcc-hardened.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- libgcc/config/t-slibgcc.mp	2018-10-03 16:07:00.336990246 -0400
-+++ libgcc/config/t-slibgcc	2018-10-03 16:06:26.719946740 -0400
-@@ -30,9 +30,10 @@ SHLIB_LC = -lc
- SHLIB_MAKE_SOLINK = $(LN_S) $(SHLIB_SONAME) $(SHLIB_DIR)/$(SHLIB_SOLINK)
- SHLIB_INSTALL_SOLINK = $(LN_S) $(SHLIB_SONAME) \
- 	$(DESTDIR)$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK)
-+SHLIB_EXTRA_LDFLAGS = -Wl,-z,relro  -Wl,-z,now
- 
- SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
--	$(SHLIB_LDFLAGS) \
-+	$(SHLIB_LDFLAGS) $(SHLIB_EXTRA_LDFLAGS) \
- 	-o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp @multilib_flags@ \
- 	$(SHLIB_OBJS) $(SHLIB_LC) && \
- 	rm -f $(SHLIB_DIR)/$(SHLIB_SOLINK) && \
diff --git a/SOURCES/gcc11-libgcc-link.patch b/SOURCES/gcc11-libgcc-link.patch
new file mode 100644
index 0000000..8551934
--- /dev/null
+++ b/SOURCES/gcc11-libgcc-link.patch
@@ -0,0 +1,57 @@
+libgcc: Honor LDFLAGS_FOR_TARGET when linking libgcc_s
+
+When building gcc with some specific LDFLAGS_FOR_TARGET, e.g.
+LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now
+those flags propagate info linking of target shared libraries,
+e.g. lib{ubsan,tsan,stdc++,quadmath,objc,lsan,itm,gphobos,gdruntime,gomp,go,gfortran,atomic,asan}.so.*
+but there is one important exception, libgcc_s.so.* linking ignores it.
+
+The following patch fixes that.
+
+Bootstrapped/regtested on x86_64-linux with LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now
+and verified that libgcc_s.so.* is BIND_NOW when it previously wasn't, and
+without any LDFLAGS_FOR_TARGET on x86_64-linux and i686-linux.
+There on x86_64-linux I've verified that the libgcc_s.so.1 linking command
+line for -m64 is identical except for whitespace to one without the patch,
+and for -m32 multilib $(LDFLAGS) actually do supply there an extra -m32
+that also repeats later in the @multilib_flags@, which should be harmless.
+
+2021-08-04  Jakub Jelinek  <jakub@redhat.com>
+
+	* config/t-slibgcc (SHLIB_LINK): Add $(LDFLAGS).
+	* config/t-slibgcc-darwin (SHLIB_LINK): Likewise.
+	* config/t-slibgcc-vms (SHLIB_LINK): Likewise.
+
+--- libgcc/config/t-slibgcc
++++ libgcc/config/t-slibgcc
+@@ -32,7 +32,7 @@ SHLIB_INSTALL_SOLINK = $(LN_S) $(SHLIB_SONAME) \
+ 	$(DESTDIR)$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK)
+ 
+ SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
+-	$(SHLIB_LDFLAGS) \
++	$(SHLIB_LDFLAGS) $(LDFLAGS) \
+ 	-o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp @multilib_flags@ \
+ 	$(SHLIB_OBJS) $(SHLIB_LC) && \
+ 	rm -f $(SHLIB_DIR)/$(SHLIB_SOLINK) && \
+--- libgcc/config/t-slibgcc-darwin
++++ libgcc/config/t-slibgcc-darwin
+@@ -15,7 +15,7 @@ SHLIB_LC = -lc
+ # Note that this version is used for the loader, not the linker; the linker
+ # uses the stub versions named by the versioned members of $(INSTALL_FILES).
+ 
+-SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -dynamiclib -nodefaultlibs \
++SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -dynamiclib -nodefaultlibs \
+ 	-install_name @shlib_slibdir@/$(SHLIB_INSTALL_NAME) \
+ 	-single_module -o $(SHLIB_DIR)/$(SHLIB_SONAME) \
+ 	-Wl,-exported_symbols_list,$(SHLIB_MAP) \
+--- libgcc/config/t-slibgcc-vms
++++ libgcc/config/t-slibgcc-vms
+@@ -22,7 +22,7 @@ SHLIB_LINK = \
+   objdump --syms $(SHLIB_OBJS) | \
+   $(SHLIB_SYMVEC) >> SYMVEC_$$$$.opt ; \
+   echo "case_sensitive=NO" >> SYMVEC_$$$$.opt; \
+-  $(CC) $(LIBGCC2_CFLAGS) -nodefaultlibs \
++  $(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -nodefaultlibs \
+   -shared --for-linker=/noinform -o $(SHLIB_NAME) $(SHLIB_OBJS) \
+   --for-linker=SYMVEC_$$$$.opt \
+   --for-linker=gsmatch=equal,$(shlib_version)
diff --git a/SOURCES/gcc11-pr101786.patch b/SOURCES/gcc11-pr101786.patch
new file mode 100644
index 0000000..427c10a
--- /dev/null
+++ b/SOURCES/gcc11-pr101786.patch
@@ -0,0 +1,66 @@
+c++: Optimize constinit thread_local vars [PR101786]
+
+The paper that introduced constinit mentioned in rationale that constinit
+can be used on externs as well and that it can be used to avoid the
+thread_local initialization wrappers, because the standard requires that
+if constinit is present on any declaration, it is also present on the
+initialization declaration, even if it is in some other TU etc.
+
+There is a small problem though, we use the tls wrappers not just if
+the thread_local variable needs dynamic initialization, but also when
+it has static initialization, but non-trivial destructor, as the
+"dynamic initialization" in that case needs to register the destructor.
+
+So, the following patch optimizes constinit thread_local vars only
+if we can prove they will not have non-trivial destructors.  That includes
+the case where we have incomplete type where we don't know and need to
+conservatively assume the type will have non-trivial destructor at the
+initializing declaration side.
+
+2021-08-11  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/101786
+	* decl2.c (var_defined_without_dynamic_init): Return true for
+	DECL_DECLARED_CONSTINIT_P with complete type and trivial destructor.
+
+	* g++.dg/cpp2a/constinit16.C: New test.
+
+--- gcc/cp/decl2.c
++++ gcc/cp/decl2.c
+@@ -3447,6 +3447,12 @@ set_guard (tree guard)
+ static bool
+ var_defined_without_dynamic_init (tree var)
+ {
++  /* constinit vars are guaranteed to not have dynamic initializer,
++     but still registering the destructor counts as dynamic initialization.  */
++  if (DECL_DECLARED_CONSTINIT_P (var)
++      && COMPLETE_TYPE_P (TREE_TYPE (var))
++      && !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (var)))
++    return true;
+   /* If it's defined in another TU, we can't tell.  */
+   if (DECL_EXTERNAL (var))
+     return false;
+--- gcc/testsuite/g++.dg/cpp2a/constinit16.C
++++ gcc/testsuite/g++.dg/cpp2a/constinit16.C
+@@ -0,0 +1,21 @@
++// PR c++/101786
++// { dg-do compile { target c++20 } }
++// { dg-add-options tls }
++// { dg-require-alias "" }
++// { dg-require-effective-target tls_runtime }
++// { dg-final { scan-assembler-not "_ZTH17mythreadlocalvar1" } }
++// { dg-final { scan-assembler "_ZTH17mythreadlocalvar2" } }
++// { dg-final { scan-assembler-not "_ZTH17mythreadlocalvar3" } }
++// { dg-final { scan-assembler "_ZTH17mythreadlocalvar4" } }
++
++extern thread_local constinit int mythreadlocalvar1;
++struct S;
++extern thread_local constinit S mythreadlocalvar2;
++struct T { int t; };
++extern thread_local constinit T mythreadlocalvar3;
++struct U { int u; ~U (); };
++extern thread_local constinit U mythreadlocalvar4;
++int foo () { return mythreadlocalvar1; }
++S *bar () { return &mythreadlocalvar2; }
++T *baz () { return &mythreadlocalvar3; }
++U *qux () { return &mythreadlocalvar4; }
diff --git a/SOURCES/gcc11-pr102642.patch b/SOURCES/gcc11-pr102642.patch
new file mode 100644
index 0000000..598794b
--- /dev/null
+++ b/SOURCES/gcc11-pr102642.patch
@@ -0,0 +1,47 @@
+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__.patch b/SOURCES/gcc11-stringify-__VA_OPT__.patch
new file mode 100644
index 0000000..3a2a71f
--- /dev/null
+++ b/SOURCES/gcc11-stringify-__VA_OPT__.patch
@@ -0,0 +1,308 @@
+c++: Add C++20 #__VA_OPT__ support
+
+The following patch implements C++20 # __VA_OPT__ (...) support.
+Testcases cover what I came up with myself and what LLVM has for #__VA_OPT__
+in its testsuite and the string literals are identical between the two
+compilers on the va-opt-5.c testcase.
+
+2021-08-17  Jakub Jelinek  <jakub@redhat.com>
+
+libcpp/
+	* macro.c (vaopt_state): Add m_stringify member.
+	(vaopt_state::vaopt_state): Initialize it.
+	(vaopt_state::update): Overwrite it.
+	(vaopt_state::stringify): New method.
+	(stringify_arg): Replace arg argument with first, count arguments
+	and add va_opt argument.  Use first instead of arg->first and
+	count instead of arg->count, for va_opt add paste_tokens handling.
+	(paste_tokens): Fix up len calculation.  Don't spell rhs twice,
+	instead use %.*s to supply lhs and rhs spelling lengths.  Don't call
+	_cpp_backup_tokens here.
+	(paste_all_tokens): Call it here instead.
+	(replace_args): Adjust stringify_arg caller.  For vaopt_state::END
+	if stringify is true handle __VA_OPT__ stringification.
+	(create_iso_definition): Handle # __VA_OPT__ similarly to # macro_arg.
+gcc/testsuite/
+	* c-c++-common/cpp/va-opt-5.c: New test.
+	* c-c++-common/cpp/va-opt-6.c: New test.
+
+--- libcpp/macro.c
++++ libcpp/macro.c
+@@ -118,6 +118,7 @@ class vaopt_state {
+     m_arg (arg),
+     m_variadic (is_variadic),
+     m_last_was_paste (false),
++    m_stringify (false),
+     m_state (0),
+     m_paste_location (0),
+     m_location (0),
+@@ -145,6 +146,7 @@ class vaopt_state {
+ 	  }
+ 	++m_state;
+ 	m_location = token->src_loc;
++	m_stringify = (token->flags & STRINGIFY_ARG) != 0;
+ 	return BEGIN;
+       }
+     else if (m_state == 1)
+@@ -234,6 +236,12 @@ class vaopt_state {
+     return m_state == 0;
+   }
+ 
++  /* Return true for # __VA_OPT__.  */
++  bool stringify () const
++  {
++    return m_stringify;
++  }
++
+  private:
+ 
+   /* The cpp_reader.  */
+@@ -247,6 +255,8 @@ class vaopt_state {
+   /* If true, the previous token was ##.  This is used to detect when
+      a paste occurs at the end of the sequence.  */
+   bool m_last_was_paste;
++  /* True for #__VA_OPT__.  */
++  bool m_stringify;
+ 
+   /* The state variable:
+      0 means not parsing
+@@ -284,7 +294,8 @@ static _cpp_buff *collect_args (cpp_reader *, const cpp_hashnode *,
+ 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 *, macro_arg *);
++static const cpp_token *stringify_arg (cpp_reader *, const cpp_token **,
++				       unsigned int, bool);
+ static void paste_all_tokens (cpp_reader *, const cpp_token *);
+ static bool paste_tokens (cpp_reader *, location_t,
+ 			  const cpp_token **, const cpp_token *);
+@@ -818,10 +829,11 @@ cpp_quote_string (uchar *dest, const uchar *src, unsigned int len)
+   return dest;
+ }
+ 
+-/* Convert a token sequence ARG to a single string token according to
+-   the rules of the ISO C #-operator.  */
++/* 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, macro_arg *arg)
++stringify_arg (cpp_reader *pfile, const cpp_token **first, unsigned int count,
++	       bool va_opt)
+ {
+   unsigned char *dest;
+   unsigned int i, escape_it, backslash_count = 0;
+@@ -834,9 +846,27 @@ stringify_arg (cpp_reader *pfile, macro_arg *arg)
+   *dest++ = '"';
+ 
+   /* Loop, reading in the argument's tokens.  */
+-  for (i = 0; i < arg->count; i++)
++  for (i = 0; i < count; i++)
+     {
+-      const cpp_token *token = arg->first[i];
++      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)
+ 	{
+@@ -923,7 +953,7 @@ paste_tokens (cpp_reader *pfile, location_t location,
+   cpp_token *lhs;
+   unsigned int len;
+ 
+-  len = cpp_token_len (*plhs) + cpp_token_len (rhs) + 1;
++  len = cpp_token_len (*plhs) + cpp_token_len (rhs) + 2;
+   buf = (unsigned char *) alloca (len);
+   end = lhsend = cpp_spell_token (pfile, *plhs, buf, true);
+ 
+@@ -949,8 +979,10 @@ paste_tokens (cpp_reader *pfile, location_t location,
+       location_t saved_loc = lhs->src_loc;
+ 
+       _cpp_pop_buffer (pfile);
+-      _cpp_backup_tokens (pfile, 1);
+-      *lhsend = '\0';
++
++      unsigned char *rhsstart = lhsend;
++      if ((*plhs)->type == CPP_DIV && rhs->type != CPP_EQ)
++	rhsstart++;
+ 
+       /* We have to remove the PASTE_LEFT flag from the old lhs, but
+ 	 we want to keep the new location.  */
+@@ -962,8 +994,10 @@ paste_tokens (cpp_reader *pfile, location_t location,
+       /* Mandatory error for all apart from assembler.  */
+       if (CPP_OPTION (pfile, lang) != CLK_ASM)
+ 	cpp_error_with_line (pfile, CPP_DL_ERROR, location, 0,
+-	 "pasting \"%s\" and \"%s\" does not give a valid preprocessing token",
+-		   buf, cpp_token_as_text (pfile, rhs));
++			     "pasting \"%.*s\" and \"%.*s\" does not give "
++			     "a valid preprocessing token",
++			     (int) (lhsend - buf), buf,
++			     (int) (end - rhsstart), rhsstart);
+       return false;
+     }
+ 
+@@ -1039,7 +1073,10 @@ paste_all_tokens (cpp_reader *pfile, const cpp_token *lhs)
+ 	    abort ();
+ 	}
+       if (!paste_tokens (pfile, virt_loc, &lhs, rhs))
+-	break;
++	{
++	  _cpp_backup_tokens (pfile, 1);
++	  break;
++	}
+     }
+   while (rhs->flags & PASTE_LEFT);
+ 
+@@ -1906,7 +1943,8 @@ 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);
++	      arg->stringified = stringify_arg (pfile, arg->first, arg->count,
++						false);
+ 	  }
+ 	else if ((src->flags & PASTE_LEFT)
+ 		 || (src != macro->exp.tokens && (src[-1].flags & PASTE_LEFT)))
+@@ -2029,7 +2067,24 @@ replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro,
+ 		  paste_flag = tokens_buff_last_token_ptr (buff);
+ 		}
+ 
+-	      if (src->flags & PASTE_LEFT)
++	      if (vaopt_tracker.stringify ())
++		{
++		  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);
++		  while (count--)
++		    tokens_buff_remove_last_token (buff);
++		  if (src->flags & PASTE_LEFT)
++		    copy_paste_flag (pfile, &t, src);
++		  tokens_buff_add_token (buff, virt_locs,
++					 t, t->src_loc, t->src_loc,
++					 NULL, 0);
++		}
++	      else if (src->flags & PASTE_LEFT)
+ 		{
+ 		  /* With a non-empty __VA_OPT__ on the LHS of ##, the last
+ 		     token should be flagged PASTE_LEFT.  */
+@@ -3585,7 +3640,10 @@ create_iso_definition (cpp_reader *pfile)
+ 	 function-like macros when lexing the subsequent token.  */
+       if (macro->count > 1 && token[-1].type == CPP_HASH && macro->fun_like)
+ 	{
+-	  if (token->type == CPP_MACRO_ARG)
++	  if (token->type == CPP_MACRO_ARG
++	      || (macro->variadic
++		  && token->type == CPP_NAME
++		  && token->val.node.node == pfile->spec_nodes.n__VA_OPT__))
+ 	    {
+ 	      if (token->flags & PREV_WHITE)
+ 		token->flags |= SP_PREV_WHITE;
+--- gcc/testsuite/c-c++-common/cpp/va-opt-5.c
++++ gcc/testsuite/c-c++-common/cpp/va-opt-5.c
+@@ -0,0 +1,67 @@
++/* { dg-do run } */
++/* { dg-options "-std=gnu99" { target c } } */
++/* { dg-options "-std=c++20" { target c++ } } */
++
++#define lparen (
++#define a0 fooa0
++#define a1  fooa1 a0
++#define a2  fooa2 a1
++#define a3  fooa3 a2
++#define a() b lparen )
++#define b() c lparen )
++#define c() d lparen )
++#define g h
++#define i(j) j
++#define f(...) #__VA_OPT__(g i(0))
++#define k(x,...) # __VA_OPT__(x) #x #__VA_OPT__(__VA_ARGS__)
++#define l(x,...) #__VA_OPT__(a1 x)
++#define m(x,...) "a()" #__VA_OPT__(a3 __VA_ARGS__ x ## __VA_ARGS__ ## x ## c a3) "a()"
++#define n(x,...) = #__VA_OPT__(a3 __VA_ARGS__ x ## __VA_ARGS__ ## x ## c a3) #x #__VA_OPT__(a0 __VA_ARGS__ x ## __VA_ARGS__ ## x ## c a0) ;
++#define o(x, ...) #__VA_OPT__(x##x x##x)
++#define p(x, ...) #__VA_OPT__(_Pragma ("foobar"))
++#define q(...) #__VA_OPT__(/* foo */x/* bar */)
++const char *v1 = f();
++const char *v2 = f(123);
++const char *v3 = k(1);
++const char *v4 = k(1, 2, 3 );
++const char *v5 = l(a());
++const char *v6 = l(a1 a(), 1);
++const char *v7 = m();
++const char *v8 = m(,);
++const char *v9 = m(,a3);
++const char *v10 = m(a3,a(),a0);
++const char *v11 n()
++const char *v12 n(,)
++const char *v13 n(,a0)
++const char *v14 n(a0, a(),a0)
++const char *v15 = o(, 0);
++const char *v16 = p(0);
++const char *v17 = p(0, 1);
++const char *v18 = q();
++const char *v19 = q(1);
++
++int
++main ()
++{
++  if (__builtin_strcmp (v1, "")
++      || __builtin_strcmp (v2, "g i(0)")
++      || __builtin_strcmp (v3, "1")
++      || __builtin_strcmp (v4, "112, 3")
++      || __builtin_strcmp (v5, "")
++      || __builtin_strcmp (v6, "a1 fooa1 fooa0 b ( )")
++      || __builtin_strcmp (v7, "a()a()")
++      || __builtin_strcmp (v8, "a()a()")
++      || __builtin_strcmp (v9, "a()a3 fooa3 fooa2 fooa1 fooa0 a3c a3a()")
++      || __builtin_strcmp (v10, "a()a3 b ( ),fooa0 a3a(),a0a3c a3a()")
++      || __builtin_strcmp (v11, "")
++      || __builtin_strcmp (v12, "")
++      || __builtin_strcmp (v13, "a3 fooa0 a0c a3a0 fooa0 a0c a0")
++      || __builtin_strcmp (v14, "a3 b ( ),fooa0 a0a(),a0a0c a3a0a0 b ( ),fooa0 a0a(),a0a0c a0")
++      || __builtin_strcmp (v15, "")
++      || __builtin_strcmp (v16, "")
++      || __builtin_strcmp (v17, "_Pragma (\"foobar\")")
++      || __builtin_strcmp (v18, "")
++      || __builtin_strcmp (v19, "x"))
++    __builtin_abort ();
++  return 0;
++}
+--- gcc/testsuite/c-c++-common/cpp/va-opt-6.c
++++ gcc/testsuite/c-c++-common/cpp/va-opt-6.c
+@@ -0,0 +1,17 @@
++/* { dg-do preprocess } */
++/* { dg-options "-std=gnu99" { target c } } */
++/* { dg-options "-std=c++20" { target c++ } } */
++
++#define a ""
++#define b(...) a ## #__VA_OPT__(1)	/* { dg-error "pasting \"a\" and \"\"\"\" does not give a valid preprocessing token" } */
++#define c(...) a ## #__VA_OPT__(1)	/* { dg-error "pasting \"a\" and \"\"1\"\" does not give a valid preprocessing token" } */
++#define d(...) #__VA_OPT__(1) ## !
++#define e(...) #__VA_OPT__(1) ## !
++#define f(...) #__VA_OPT__(. ## !)
++#define g(...) #__VA_OPT__(. ## !)
++b()
++c(1)
++d(   )		/* { dg-error "pasting \"\"\"\" and \"!\" does not give a valid preprocessing token" } */
++e(  1 )		/* { dg-error "pasting \"\"1\"\" and \"!\" does not give a valid preprocessing token" } */
++f()
++g(0)		/* { dg-error "pasting \".\" and \"!\" does not give a valid preprocessing token" } */
diff --git a/SOURCES/gcc11-tsan-sigstksz.patch b/SOURCES/gcc11-tsan-sigstksz.patch
deleted file mode 100644
index 80e23f6..0000000
--- a/SOURCES/gcc11-tsan-sigstksz.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-From 91f8a7a34cf29ae7c465603a801326767f1cc7e9 Mon Sep 17 00:00:00 2001
-From: Martin Liska <mliska@suse.cz>
-Date: Thu, 5 Aug 2021 10:43:17 +0200
-Subject: [PATCH] sanitizer: cherry pick
- 414482751452e54710f16bae58458c66298aaf69
-
-The patch is needed in order to support recent glibc (2.34).
-
-libsanitizer/ChangeLog:
-
-	PR sanitizer/101749
-	* sanitizer_common/sanitizer_posix_libcdep.cpp: Prevent
-	generation of dependency on _cxa_guard for static
-	initialization.
----
- libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp | 7 ++++---
- 1 file changed, 4 insertions(+), 3 deletions(-)
-
-diff --git a/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp b/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp
-index 7ff48c35851..a65b16f5290 100644
---- a/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp
-+++ b/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp
-@@ -166,9 +166,10 @@ bool SupportsColoredOutput(fd_t fd) {
- #if !SANITIZER_GO
- // TODO(glider): different tools may require different altstack size.
- static uptr GetAltStackSize() {
--  // SIGSTKSZ is not enough.
--  static const uptr kAltStackSize = SIGSTKSZ * 4;
--  return kAltStackSize;
-+  // Note: since GLIBC_2.31, SIGSTKSZ may be a function call, so this may be
-+  // more costly that you think. However GetAltStackSize is only call 2-3 times
-+  // per thread so don't cache the evaluation.
-+  return SIGSTKSZ * 4;
- }
- 
- void SetAlternateSignalStack() {
--- 
-2.27.0
diff --git a/SPECS/gcc.spec b/SPECS/gcc.spec
index ef101c5..3c2964d 100644
--- a/SPECS/gcc.spec
+++ b/SPECS/gcc.spec
@@ -1,10 +1,10 @@
-%global DATE 20210728
-%global gitrev 134ab8155c937122663513b76afa8e64ad61fe99
+%global DATE 20211019
+%global gitrev 0990a48aaf68b56a3737fdb290328df1da9095cc
 %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 2
+%global gcc_release 6
 %global nvptx_tools_gitrev 5f6f343a302d620b0868edab376c00b15741e39e
 %global newlib_cygwin_gitrev 50e2a63b04bdd018484605fbb954fd1bd5147fa0
 %global _unpackaged_files_terminate_build 0
@@ -118,7 +118,7 @@
 Summary: Various compilers (C, C++, Objective-C, ...)
 Name: gcc
 Version: %{gcc_version}
-Release: %{gcc_release}.2%{?dist}
+Release: %{gcc_release}%{?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
@@ -249,6 +249,8 @@ Obsoletes: gcc-gnat < %{version}-%{release}
 Obsoletes: gcc-java < %{version}-%{release}
 AutoReq: true
 Provides: bundled(libiberty)
+Provides: bundled(libbacktrace)
+Provides: bundled(libffi)
 Provides: gcc(major) = %{gcc_major}
 
 Patch0: gcc11-hack.patch
@@ -263,8 +265,10 @@ Patch9: gcc11-foffload-default.patch
 Patch10: gcc11-Wno-format-security.patch
 Patch11: gcc11-rh1574936.patch
 Patch12: gcc11-d-shared-libphobos.patch
-Patch13: gcc11-libgcc-hardened.patch
-Patch14: gcc11-tsan-sigstksz.patch
+Patch14: gcc11-libgcc-link.patch
+Patch15: gcc11-pr101786.patch
+Patch16: gcc11-stringify-__VA_OPT__.patch
+Patch17: gcc11-pr102642.patch
 
 Patch100: gcc11-fortran-fdec-duplicates.patch
 Patch101: gcc11-fortran-flogical-as-integer.patch
@@ -787,8 +791,10 @@ to NVidia PTX capable devices if available.
 %patch11 -p0 -b .rh1574936~
 %endif
 %patch12 -p0 -b .d-shared-libphobos~
-%patch13 -p0 -b .libgcc-hardened~
-%patch14 -p1 -b .tsan-sigstksz~
+%patch14 -p0 -b .libgcc-link~
+%patch15 -p0 -b .pr101786~
+%patch16 -p0 -b .stringify-__VA_OPT__~
+%patch17 -p0 -b .pr102642~
 
 %if 0%{?rhel} >= 9
 %patch100 -p1 -b .fortran-fdec-duplicates~
@@ -1080,8 +1086,10 @@ CONFIGURE_OPTS="\
 	--build=%{gcc_target_platform} \
 %endif
 %if 0%{?fedora} >= 35 || 0%{?rhel} >= 9
+%ifnarch %{arm}
 	--with-build-config=bootstrap-lto --enable-link-serialization=1 \
 %endif
+%endif
 	"
 
 CC="$CC" CXX="$CXX" CFLAGS="$OPT_FLAGS" \
@@ -1093,9 +1101,9 @@ CC="$CC" CXX="$CXX" CFLAGS="$OPT_FLAGS" \
 	$CONFIGURE_OPTS
 
 %ifarch sparc sparcv9 sparc64
-make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" LDFLAGS_FOR_TARGET="-Wl,-z,relro,-z,now" bootstrap
+make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now bootstrap
 %else
-make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" LDFLAGS_FOR_TARGET="-Wl,-z,relro,-z,now" profiledbootstrap
+make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now profiledbootstrap
 %endif
 
 CC="`%{gcc_target_platform}/libstdc++-v3/scripts/testsuite_flags --build-cc`"
@@ -2092,7 +2100,7 @@ end
 
 %ldconfig_scriptlets -n libgccjit
 
-%ldconfig_scriptlets -n libgquadmath
+%ldconfig_scriptlets -n libquadmath
 
 %ldconfig_scriptlets -n libitm
 
@@ -2262,6 +2270,7 @@ end
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/include/hresetintrin.h
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/include/keylockerintrin.h
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/include/avxvnniintrin.h
+%{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/include/mwaitintrin.h
 %endif
 %ifarch ia64
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/include/ia64intrin.h
@@ -3134,6 +3143,15 @@ end
 %endif
 
 %changelog
+* Wed Oct 27 2021 Marek Polacek <polacek@redhat.com> 11.2.1-6
+- update from releases/gcc-11-branch (#1996858)
+- build target shared libraries with -Wl,-z,relro,-z,now
+- add mwaitintrin.h on x86 (#2013860)
+- improve generated code with extern thread_local constinit vars
+  with trivial dtors
+- add support for C++20 #__VA_OPT__
+- add bundled(libbacktrace) and bundled(libffi) provides (#1993932)
+
 * Thu Aug 12 2021 Marek Polacek <polacek@redhat.com> 11.2.1-2.2
 - bootstrap with -Wl,-z,relro,-z,now, apply libgcc hardening patch (#1988450)
 - fix libsanitizer with non-constant SIGSTKSZ (#1992727)