proj/gcc-patches:master commit in: 16.2.0/gentoo/
"Sam James" <[email protected]>
| Newsgroups | gmane.linux.gentoo.cvs |
|---|---|
| Message-ID | <1786299352.84f809ccd005493c28997feb2e4e5902fc9e7619.sam@gentoo> |
commit: 84f809ccd005493c28997feb2e4e5902fc9e7619
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 9 18:15:52 2026 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Aug 9 18:15:52 2026 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=84f809cc
16.2.0: clone of 16.1.0
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.2.0/gentoo/01_all_default-fortify-source.patch | 26 +
.../02_all_default-warn-format-security.patch | 21 +
.../gentoo/03_all_default-warn-trampolines.patch | 13 +
16.2.0/gentoo/04_all_nossp-on-nostdlib.patch | 27 +
16.2.0/gentoo/05_all_alpha-mieee-default.patch | 39 ++
16.2.0/gentoo/06_all_ia64_note.GNU-stack.patch | 92 ++++
16.2.0/gentoo/08_all_libiberty-pic.patch | 10 +
16.2.0/gentoo/09_all_esysroot.patch | 97 ++++
16.2.0/gentoo/10_all_sh-drop-sysroot-suffix.patch | 26 +
16.2.0/gentoo/11_all_ia64-TEXTREL.patch | 22 +
16.2.0/gentoo/14_all_respect-build-cxxflags.patch | 39 ++
.../15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch | 14 +
16.2.0/gentoo/20_all_libstdcxx-no-vtv.patch | 61 +++
16.2.0/gentoo/22_all_default_ssp-buffer-size.patch | 14 +
16.2.0/gentoo/23_all_DEF_GENTOO_ZNOW-z-now.patch | 26 +
...ll_DEF_GENTOO_SCP-fstack-clash-protection.patch | 65 +++
16.2.0/gentoo/26_all_enable-cet.patch | 193 +++++++
16.2.0/gentoo/28_all_drop_CFLAGS_sed.patch | 67 +++
16.2.0/gentoo/29_all_msgfmt-libstdc++-link.patch | 39 ++
16.2.0/gentoo/30_all_tar_libstdc++-link.patch | 57 +++
16.2.0/gentoo/32_all_time64.patch | 39 ++
16.2.0/gentoo/33_all_PR80677-cross-limits.patch | 38 ++
16.2.0/gentoo/34_all_time64_ssemath.patch | 43 ++
.../gentoo/35_all_checking-gc-use-heuristics.patch | 22 +
16.2.0/gentoo/36_all_no-afdo-testing.patch | 13 +
...ect-lifetime-instrumentation-for-Valgrind.patch | 567 +++++++++++++++++++++
16.2.0/gentoo/38_all_hurd_linker_path.patch | 26 +
...tx-fix-bashisms-with-gen-copyright.sh-use.patch | 68 +++
16.2.0/gentoo/86_all_PR122794-libtool.patch | 334 ++++++++++++
16.2.0/gentoo/README.history | 31 ++
30 files changed, 2129 insertions(+)
diff --git a/16.2.0/gentoo/01_all_default-fortify-source.patch b/16.2.0/gentoo/01_all_default-fortify-source.patch
new file mode 100644
index 0000000..4cdf5f6
--- /dev/null
+++ b/16.2.0/gentoo/01_all_default-fortify-source.patch
@@ -0,0 +1,26 @@
+Taken Debian's patch and removed docs matches:
+ https://salsa.debian.org/toolchain-team/gcc.git
+Also see https://bugs.gentoo.org/621036 where
+initially Gentoo used too complicated macro.
+
+# DP: Turn on -D_FORTIFY_SOURCE=2 by default for C, C++, ObjC, ObjC++,
+# DP: if the optimization level is > 0
+--- a/gcc/c-family/c-cppbuiltin.cc
++++ b/gcc/c-family/c-cppbuiltin.cc
+@@ -1510,6 +1510,16 @@ c_cpp_builtins (cpp_reader *pfile)
+ builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0);
+ builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0);
+
++#if !defined(ACCEL_COMPILER)
++ #ifndef GENTOO_FORTIFY_SOURCE_LEVEL
++ #define GENTOO_FORTIFY_SOURCE_LEVEL 2
++ #endif
++
++ /* F_S enabled by default for optimization levels > 0, except for ASAN: https://github.com/google/sanitizers/issues/247 */
++ if (optimize && ! (flag_sanitize & SANITIZE_ADDRESS))
++ builtin_define_with_int_value ("_FORTIFY_SOURCE", GENTOO_FORTIFY_SOURCE_LEVEL);
++#endif
++
+ /* Misc. */
+ if (flag_gnu89_inline)
+ cpp_define (pfile, "__GNUC_GNU_INLINE__");
diff --git a/16.2.0/gentoo/02_all_default-warn-format-security.patch b/16.2.0/gentoo/02_all_default-warn-format-security.patch
new file mode 100644
index 0000000..439d9d8
--- /dev/null
+++ b/16.2.0/gentoo/02_all_default-warn-format-security.patch
@@ -0,0 +1,21 @@
+Enable -Wformat and -Wformat-security by default.
+--- a/gcc/c-family/c.opt
++++ b/gcc/c-family/c.opt
+@@ -770,7 +770,7 @@ Warn about function calls with format strings that write past the end
+ of the destination region.
+
+ Wformat-security
+-C ObjC C++ ObjC++ Var(warn_format_security) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 2, 0)
++C ObjC C++ ObjC++ Var(warn_format_security) Init(1) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 2, 0)
+ Warn about possible security problems with format functions.
+
+ Wformat-signedness
+@@ -795,7 +795,7 @@ C ObjC C++ ObjC++ Var(warn_format_zero_length) Warning LangEnabledBy(C ObjC C++
+ Warn about zero-length formats.
+
+ Wformat=
+-C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0) IntegerRange(0, 2)
++C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format) Init(1) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0) IntegerRange(0, 2)
+ Warn about printf/scanf/strftime/strfmon format string anomalies.
+
+ Wframe-address
diff --git a/16.2.0/gentoo/03_all_default-warn-trampolines.patch b/16.2.0/gentoo/03_all_default-warn-trampolines.patch
new file mode 100644
index 0000000..c72d139
--- /dev/null
+++ b/16.2.0/gentoo/03_all_default-warn-trampolines.patch
@@ -0,0 +1,13 @@
+Enable -Wtrampolines by default.
+
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -834,7 +834,7 @@ Common Var(warn_tautological_compare) Warning LangEnabledBy(C ObjC C++ ObjC++,Wa
+ Warn if a comparison always evaluates to true or false.
+
+ Wtrampolines
+-Common Var(warn_trampolines) Warning
++Common Var(warn_trampolines) Init(1) Warning
+ Warn whenever a trampoline is generated.
+
+ Wtrivial-auto-var-init
diff --git a/16.2.0/gentoo/04_all_nossp-on-nostdlib.patch b/16.2.0/gentoo/04_all_nossp-on-nostdlib.patch
new file mode 100644
index 0000000..5351900
--- /dev/null
+++ b/16.2.0/gentoo/04_all_nossp-on-nostdlib.patch
@@ -0,0 +1,27 @@
+Disable ssp on -nostdlib, -nodefaultlibs and -ffreestanding
+
+https://bugs.gentoo.org/484714
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -1017,6 +1017,12 @@ proper position among the other output files. */
+ #define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
+ #endif
+
++#ifdef ENABLE_DEFAULT_SSP
++#define NO_SSP_SPEC "%{nostdlib|nodefaultlibs|ffreestanding:-fno-stack-protector} -foffload-options=-fno-stack-protector "
++#else
++#define NO_SSP_SPEC ""
++#endif
++
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+@@ -1319,7 +1325,7 @@ static const char *cc1_options =
+ %{-version:--version}\
+ %{-help=*:--help=%*}\
+ %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\
+- %{fsyntax-only:-o %j} %{-param*}\
++ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\
+ %{coverage:-fprofile-arcs -ftest-coverage}\
+ %{fprofile-arcs|fcondition-coverage|fpath-coverage|fprofile-generate*|coverage:\
+ %{!fprofile-update=single:\
diff --git a/16.2.0/gentoo/05_all_alpha-mieee-default.patch b/16.2.0/gentoo/05_all_alpha-mieee-default.patch
new file mode 100644
index 0000000..fd1de71
--- /dev/null
+++ b/16.2.0/gentoo/05_all_alpha-mieee-default.patch
@@ -0,0 +1,39 @@
+Set the default behavior on alpha to use -mieee since the large majority of
+time we want this (bad/weird things can happen with packages built without
+it).
+
+To satisfy those people who may not want -mieee forced on them all the time,
+we also provide -mno-ieee.
+
+Patch by Mike Frysinger <[email protected]>
+
+Note: upstream doesn't want to take this due to long standing behavior, and
+because it'd make behavior across OS's inconsistent:
+ https://gcc.gnu.org/ml/gcc-patches/2003-07/msg02144.html
+
+This makes sense for upstream, but Gentoo is more concerned about packages
+behaving the same across arches under Linux.
+
+--- a/gcc/config/alpha/alpha.h
++++ b/gcc/config/alpha/alpha.h
+@@ -94,6 +94,8 @@ along with GCC; see the file COPYING3. If not see
+ while (0)
+ #endif
+
++#define CPP_SPEC "%{!no-ieee:-mieee}"
++
+ /* Run-time compilation parameters selecting different hardware subsets. */
+
+ /* Which processor to schedule for. The cpu attribute defines a list that
+--- a/gcc/config/alpha/alpha.opt
++++ b/gcc/config/alpha/alpha.opt
+@@ -35,7 +35,7 @@
+ Request IEEE-conformant math library routines (OSF/1).
+
+ mieee
+-Target RejectNegative Mask(IEEE)
++Target Mask(IEEE)
+ Emit IEEE-conformant code, without inexact exceptions.
+
+ mieee-with-inexact
+
diff --git a/16.2.0/gentoo/06_all_ia64_note.GNU-stack.patch b/16.2.0/gentoo/06_all_ia64_note.GNU-stack.patch
new file mode 100644
index 0000000..7a1d4c6
--- /dev/null
+++ b/16.2.0/gentoo/06_all_ia64_note.GNU-stack.patch
@@ -0,0 +1,92 @@
+http://gcc.gnu.org/PR21098
+
+
+2004-09-20 Jakub Jelinek <[email protected]>
+
+ * config/rs6000/ppc-asm.h: Add .note.GNU-stack section also
+ on ppc64-linux.
+
+ * config/ia64/lib1funcs.asm: Add .note.GNU-stack section on
+ ia64-linux.
+ * config/ia64/crtbegin.asm: Likewise.
+ * config/ia64/crtend.asm: Likewise.
+ * config/ia64/crti.asm: Likewise.
+ * config/ia64/crtn.asm: Likewise.
+
+2004-05-14 Jakub Jelinek <[email protected]>
+
+ * config/ia64/linux.h (TARGET_ASM_FILE_END): Define.
+
+
+--- a/gcc/config/ia64/linux.h
++++ b/gcc/config/ia64/linux.h
+@@ -23,6 +23,8 @@ a copy of the GCC Runtime Library Exception along with this program;
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
++#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
++
+ /* This is for -profile to use -lc_p instead of -lc. */
+ #undef CC1_SPEC
+ #define CC1_SPEC "%{profile:-p} %{G*}"
+--- a/gcc/config/rs6000/ppc-asm.h
++++ b/gcc/config/rs6000/ppc-asm.h
+@@ -384,7 +384,7 @@ GLUE(.L,name): \
+ #endif
+ #endif
+
+-#if defined __linux__ && !defined __powerpc64__
++#if defined __linux__
+ .section .note.GNU-stack
+ .previous
+ #endif
+--- a/libgcc/config/ia64/crtbegin.S
++++ b/libgcc/config/ia64/crtbegin.S
+@@ -185,3 +185,7 @@ __do_jv_register_classes:
+ .weak __cxa_finalize
+ #endif
+ .weak _Jv_RegisterClasses
++
++#ifdef __linux__
++.section .note.GNU-stack; .previous
++#endif
+--- a/libgcc/config/ia64/crtend.S
++++ b/libgcc/config/ia64/crtend.S
+@@ -114,3 +114,6 @@ __do_global_ctors_aux:
+
+ br.ret.sptk.many rp
+ .endp __do_global_ctors_aux
++#ifdef __linux__
++.section .note.GNU-stack; .previous
++#endif
+--- a/libgcc/config/ia64/crti.S
++++ b/libgcc/config/ia64/crti.S
+@@ -49,5 +49,8 @@ _fini:
+ .save rp, r33
+ mov r33 = b0
+ .body
++#ifdef __linux__
++.section .note.GNU-stack; .previous
++#endif
+
+ # end of crti.S
+--- a/libgcc/config/ia64/crtn.S
++++ b/libgcc/config/ia64/crtn.S
+@@ -39,5 +39,8 @@
+ .restore sp
+ mov r12 = r35
+ br.ret.sptk.many b0
++#ifdef __linux__
++.section .note.GNU-stack; .previous
++#endif
+
+ # end of crtn.S
+--- a/libgcc/config/ia64/lib1funcs.S
++++ b/libgcc/config/ia64/lib1funcs.S
+@@ -793,3 +793,6 @@ __floattitf:
+ .endp __floattitf
+ #endif
+ #endif
++#ifdef __linux__
++.section .note.GNU-stack; .previous
++#endif
diff --git a/16.2.0/gentoo/08_all_libiberty-pic.patch b/16.2.0/gentoo/08_all_libiberty-pic.patch
new file mode 100644
index 0000000..3f0bae1
--- /dev/null
+++ b/16.2.0/gentoo/08_all_libiberty-pic.patch
@@ -0,0 +1,10 @@
+--- a/libiberty/Makefile.in
++++ b/libiberty/Makefile.in
+@@ -265,6 +265,7 @@ $(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS)
+ $(AR) $(AR_FLAGS) $(TARGETLIB) \
+ $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS); \
+ $(RANLIB) $(TARGETLIB); \
++ cp $(TARGETLIB) ../ ; \
+ cd ..; \
+ else true; fi
+
diff --git a/16.2.0/gentoo/09_all_esysroot.patch b/16.2.0/gentoo/09_all_esysroot.patch
new file mode 100644
index 0000000..51b527e
--- /dev/null
+++ b/16.2.0/gentoo/09_all_esysroot.patch
@@ -0,0 +1,97 @@
+From a80ab24d90b14b3d4971843693b09c30b511ae42 Mon Sep 17 00:00:00 2001
+Message-ID: <a80ab24d90b14b3d4971843693b09c30b511ae42.1775133863.git.sam-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
+From: James Le Cuirot <[email protected]>
+Date: Mon, 23 Dec 2024 16:50:25 +0000
+Subject: [PATCH] Allow setting target sysroot with ESYSROOT env var for
+ cross-compilers
+
+The variable is ignored for native compilers, when it matches BROOT, and
+when the target machine does not match CHOST (if set). The --sysroot
+command line option takes precedence.
+
+The CHOST check is necessary for a Canadian Cross. In that case, two
+cross-compilers are invoked, but only the one matching CHOST should have
+its sysroot set by ESYSROOT.
+
+Bug: https://bugs.gentoo.org/942672
+Closes: https://github.com/gentoo/gcc-patches/pull/7
+Signed-off-by: James Le Cuirot <[email protected]>
+---
+ gcc/doc/invoke.texi | 11 +++++++++++
+ gcc/gcc.cc | 29 +++++++++++++++++++++++++++++
+ 2 files changed, 40 insertions(+)
+
+diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
+index 7749513bfb44..99e293a1d71b 100644
+--- a/gcc/doc/invoke.texi
++++ b/gcc/doc/invoke.texi
+@@ -18901,6 +18901,10 @@ for this option. If your linker does not support this option, the
+ header file aspect of @option{--sysroot} still works, but the
+ library aspect does not.
+
++On Gentoo Linux, this option can also be set for cross-compilers using the
++@env{ESYSROOT} environmnent variable. The command line option takes
++precedence.
++
+ @opindex no-sysroot-suffix
+ @item --no-sysroot-suffix
+ For some targets, a suffix is added to the root directory specified
+@@ -37535,6 +37539,13 @@ using GCC also uses these directories when searching for ordinary
+ libraries for the @option{-l} option (but directories specified with
+ @option{-L} come first).
+
++@vindex ESYSROOT
++@item ESYSROOT
++On Gentoo Linux, this variable sets the logical root directory for headers and
++libraries for cross-compilers. It is ignored for native compilers, when it
++matches @env{BROOT}, and when the target machine does not match @env{CHOST}
++(if set). The @option{--sysroot} option takes precedence.
++
+ @vindex GCC_EXTRA_DIAGNOSTIC_OUTPUT
+ @item GCC_EXTRA_DIAGNOSTIC_OUTPUT
+ If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values,
+diff --git a/gcc/gcc.cc b/gcc/gcc.cc
+index 43b0158ee02b..dc973f541516 100644
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -5525,6 +5525,35 @@ process_command (unsigned int decoded_options_count,
+ gcc_assert (!compare_debug_opt);
+ }
+
++ if (*cross_compile == '1' && !target_system_root_changed)
++ {
++ const char *esysroot = env.get("ESYSROOT");
++ const char *chost = env.get("CHOST");
++ if (esysroot && (!chost || strcmp(chost, spec_machine) == 0))
++ {
++ char *my_esysroot = lrealpath(esysroot);
++ if (my_esysroot[0] == '\0')
++ my_esysroot = xstrdup("/");
++
++ if (!target_system_root ||
++ !filename_eq(my_esysroot, target_system_root[0] == '\0' ? "/" : target_system_root))
++ {
++ const char *broot = env.get("BROOT");
++ char *my_broot = (!broot || broot[0] == '\0') ? xstrdup("/") : lrealpath(broot);
++
++ if (!filename_eq(my_esysroot, my_broot))
++ {
++ target_system_root = esysroot;
++ target_system_root_changed = 1;
++ }
++
++ free(my_broot);
++ }
++
++ free(my_esysroot);
++ }
++ }
++
+ /* Set up the search paths. We add directories that we expect to
+ contain GNU Toolchain components before directories specified by
+ the machine description so that we will find GNU components (like
+
+base-commit: 37b6f073bb1f81bdde024edc9b30f476d6db14e5
+--
+2.53.0
+
diff --git a/16.2.0/gentoo/10_all_sh-drop-sysroot-suffix.patch b/16.2.0/gentoo/10_all_sh-drop-sysroot-suffix.patch
new file mode 100644
index 0000000..e778f81
--- /dev/null
+++ b/16.2.0/gentoo/10_all_sh-drop-sysroot-suffix.patch
@@ -0,0 +1,26 @@
+From 5eeeff19bb4978a8d3c0d53bc81744bc25d82993 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <[email protected]>
+Date: Sat, 14 Apr 2018 13:07:39 +0100
+Subject: [PATCH] gcc/config.gcc: sh-*: Disable sysroot-suffix (PR42947)
+
+sh-* is a multilib target. It is also one of 2 sysroot-prefix targets.
+Unfortunately two options do not mix well. Attempt to use default
+multilib flavour always prepends sysroot-prefix.
+
+Bug: https://bugs.gentoo.org/511548
+Bug: https://gcc.gnu.org/PR42947
+Signed-off-by: Sergei Trofimovich <[email protected]>
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -3328,8 +3328,6 @@ sh-*-elf* | sh[12346l]*-*-elf* | \
+ if test x${enable_incomplete_targets} = xyes ; then
+ tm_defines="$tm_defines SUPPORT_SH1=1 SUPPORT_SH2E=1 SUPPORT_SH4=1 SUPPORT_SH4_SINGLE=1 SUPPORT_SH2A=1 SUPPORT_SH2A_SINGLE=1"
+ fi
+- tm_file="$tm_file ./sysroot-suffix.h"
+- tmake_file="$tmake_file t-sysroot-suffix"
+ ;;
+ sh-*-rtems*)
+ tmake_file="${tmake_file} sh/t-sh sh/t-rtems"
+--
+2.17.0
+
diff --git a/16.2.0/gentoo/11_all_ia64-TEXTREL.patch b/16.2.0/gentoo/11_all_ia64-TEXTREL.patch
new file mode 100644
index 0000000..f5d0a99
--- /dev/null
+++ b/16.2.0/gentoo/11_all_ia64-TEXTREL.patch
@@ -0,0 +1,22 @@
+Fix textrels on -rdynamic binaries:
+Bug: https://gcc.gnu.org/PR84553
+Bug: https://bugs.gentoo.org/566118
+--- a/gcc/config/ia64/ia64.cc
++++ b/gcc/config/ia64/ia64.cc
+@@ -10840,12 +10840,14 @@ ia64_hpux_reloc_rw_mask (void)
+
+ /* For others, relax this so that relocations to local data goes in
+ read-only segments, but we still cannot allow global relocations
+- in read-only segments. */
++ in read-only segments. Except that use of -rdynamic at link time
++ may make any local data global, so we can't allow local data in
++ read-only segments either. */
+
+ static int
+ ia64_reloc_rw_mask (void)
+ {
+- return flag_pic ? 3 : 2;
++ return flag_pic ? 3 : 3;
+ }
+
+ /* Return the section to use for X. The only special thing we do here
diff --git a/16.2.0/gentoo/14_all_respect-build-cxxflags.patch b/16.2.0/gentoo/14_all_respect-build-cxxflags.patch
new file mode 100644
index 0000000..1f9a774
--- /dev/null
+++ b/16.2.0/gentoo/14_all_respect-build-cxxflags.patch
@@ -0,0 +1,39 @@
+Pass CXXFLAGS as CXXFLAGS_FOR_BUILD to stage1.
+
+Fixes build failure when CXXFLAGS contains
+TARGET-specific flags.
+
+Tested on x86_64-pc-linux-gnu host as:
+ # CFLAGS='-O2 -mfpu=neon-vfpv4' CXXFLAGS='-O2 -mfpu=neon-vfpv4' \
+ armv7a-unknown-linux-gnueabihf-emerge -v1 sys-devel/gcc --quiet-build=n
+
+Fix by Peter Levine.
+https://bugs.gentoo.org/581406
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -176,6 +176,7 @@
+ # built for the build system to override those in BASE_FLAGS_TO_PASS.
+ EXTRA_BUILD_FLAGS = \
+ CFLAGS="$(CFLAGS_FOR_BUILD)" \
++ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
+ LDFLAGS="$(LDFLAGS_FOR_BUILD)"
+
+ # This is the list of directories to built for the host system.
+@@ -842,6 +843,7 @@
+ "CC_FOR_BUILD=$(CC_FOR_BUILD)" \
+ "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
+ "CXX_FOR_BUILD=$(CXX_FOR_BUILD)" \
++ "CXXFLAGS_FOR_BUILD=$(CXXFLAGS_FOR_BUILD)" \
+ "EXPECT=$(EXPECT)" \
+ "FLEX=$(FLEX)" \
+ "INSTALL=$(INSTALL)" \
+--- a/Makefile.tpl
++++ b/Makefile.tpl
+@@ -179,6 +179,7 @@
+ # built for the build system to override those in BASE_FLAGS_TO_PASS.
+ EXTRA_BUILD_FLAGS = \
+ CFLAGS="$(CFLAGS_FOR_BUILD)" \
++ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
+ LDFLAGS="$(LDFLAGS_FOR_BUILD)"
+
+ # This is the list of directories to built for the host system.
diff --git a/16.2.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch b/16.2.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch
new file mode 100644
index 0000000..4972c08
--- /dev/null
+++ b/16.2.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch
@@ -0,0 +1,14 @@
+https://bugs.gentoo.org/876895
+--- a/gcc/c-family/c-cppbuiltin.cc
++++ b/gcc/c-family/c-cppbuiltin.cc
+@@ -963,6 +963,10 @@ c_cpp_builtins (cpp_reader *pfile)
+ cpp_define (pfile, "__cpp_rtti=199711L");
+ }
+
++ #if defined(DEF_GENTOO_GLIBCXX_ASSERTIONS) && !defined(ACCEL_COMPILER)
++ cpp_define (pfile, "_GLIBCXX_ASSERTIONS");
++ #endif
++
+ if (cxx_dialect >= cxx11)
+ {
+ cpp_define (pfile, "__GXX_EXPERIMENTAL_CXX0X__");
diff --git a/16.2.0/gentoo/20_all_libstdcxx-no-vtv.patch b/16.2.0/gentoo/20_all_libstdcxx-no-vtv.patch
new file mode 100644
index 0000000..2719e2d
--- /dev/null
+++ b/16.2.0/gentoo/20_all_libstdcxx-no-vtv.patch
@@ -0,0 +1,61 @@
+Final libstdc++.so should not contain rpath to make libvtv usable.
+It's up to final binaries to link against proper libvtv.
+
+Bug: https://bugs.gentoo.org/582524
+Bug: https://gcc.gnu.org/PR85884
+--- a/libstdc++-v3/src/Makefile.am
++++ b/libstdc++-v3/src/Makefile.am
+@@ -277,7 +277,6 @@ CXXLINK = \
+ $(LIBTOOL) --tag CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXX) \
+- $(VTV_CXXLINKFLAGS) \
+ $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) \
+ $(LTLDFLAGS) $(LTLIBICONV) \
+ -o $@
+--- a/libstdc++-v3/src/Makefile.in
++++ b/libstdc++-v3/src/Makefile.in
+@@ -642,7 +642,6 @@ CXXLINK = \
+ $(LIBTOOL) --tag CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXX) \
+- $(VTV_CXXLINKFLAGS) \
+ $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) \
+ $(LTLDFLAGS) $(LTLIBICONV) \
+ -o $@
+--- a/libstdc++-v3/src/c++11/Makefile.am
++++ b/libstdc++-v3/src/c++11/Makefile.am
+@@ -214,5 +214,4 @@ CXXLINK = \
+ $(LIBTOOL) --tag CXX --tag disable-shared \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXX) \
+- $(VTV_CXXLINKFLAGS) \
+ $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
+--- a/libstdc++-v3/src/c++11/Makefile.in
++++ b/libstdc++-v3/src/c++11/Makefile.in
+@@ -588,7 +588,6 @@ CXXLINK = \
+ $(LIBTOOL) --tag CXX --tag disable-shared \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXX) \
+- $(VTV_CXXLINKFLAGS) \
+ $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
+
+ all: all-am
+--- a/libstdc++-v3/src/c++98/Makefile.am
++++ b/libstdc++-v3/src/c++98/Makefile.am
+@@ -268,5 +268,4 @@ CXXLINK = \
+ $(LIBTOOL) --tag CXX --tag disable-shared \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXX) \
+- $(VTV_CXXLINKFLAGS) \
+ $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
+--- a/libstdc++-v3/src/c++98/Makefile.in
++++ b/libstdc++-v3/src/c++98/Makefile.in
+@@ -590,7 +590,6 @@ CXXLINK = \
+ $(LIBTOOL) --tag CXX --tag disable-shared \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXX) \
+- $(VTV_CXXLINKFLAGS) \
+ $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
+
+ all: all-am
diff --git a/16.2.0/gentoo/22_all_default_ssp-buffer-size.patch b/16.2.0/gentoo/22_all_default_ssp-buffer-size.patch
new file mode 100644
index 0000000..0e0dd42
--- /dev/null
+++ b/16.2.0/gentoo/22_all_default_ssp-buffer-size.patch
@@ -0,0 +1,14 @@
+Change the minimal SSP buffer size.
+
+https://bugs.gentoo.org/484714
+--- a/gcc/params.opt
++++ b/gcc/params.opt
+@@ -1012,7 +1012,7 @@ Common Joined UInteger Var(param_ssa_name_def_chain_limit) Init(512) Param Optim
+ The maximum number of SSA_NAME assignments to follow in determining a value.
+
+ -param=ssp-buffer-size=
+-Common Joined UInteger Var(param_ssp_buffer_size) Init(8) IntegerRange(1, 65536) Param Optimization
++Common Joined UInteger Var(param_ssp_buffer_size) Init(4) IntegerRange(1, 65536) Param Optimization
+ The lower bound for a buffer to be considered for stack smashing protection.
+
+ -param=stack-clash-protection-guard-size=
diff --git a/16.2.0/gentoo/23_all_DEF_GENTOO_ZNOW-z-now.patch b/16.2.0/gentoo/23_all_DEF_GENTOO_ZNOW-z-now.patch
new file mode 100644
index 0000000..2ed7968
--- /dev/null
+++ b/16.2.0/gentoo/23_all_DEF_GENTOO_ZNOW-z-now.patch
@@ -0,0 +1,26 @@
+If requested we add -z now
+
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -1001,6 +1001,12 @@ proper position among the other output files. */
+ #endif
+ #endif
+
++#ifdef DEF_GENTOO_ZNOW
++#define LINK_NOW_SPEC "%{!nonow:-z now} "
++#else
++#define LINK_NOW_SPEC ""
++#endif
++
+ #ifdef ENABLE_DEFAULT_PIE
+ #define PIE_SPEC "!no-pie"
+ #define NO_FPIE1_SPEC "fno-pie"
+@@ -1161,7 +1167,7 @@ proper position among the other output files. */
+ %(linker) " \
+ LINK_PLUGIN_SPEC \
+ "%{flto|flto=*:%<fcompare-debug*} \
+- %{flto} %{fno-lto} %{flto=*} %l " LINK_PIE_SPEC \
++ %{flto} %{fno-lto} %{flto=*} %l " LINK_PIE_SPEC LINK_NOW_SPEC \
+ "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \
+ "%X %{o*} %{e*} %{N} %{n} %{r}\
+ %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \
diff --git a/16.2.0/gentoo/24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch b/16.2.0/gentoo/24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch
new file mode 100644
index 0000000..b2cc852
--- /dev/null
+++ b/16.2.0/gentoo/24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch
@@ -0,0 +1,65 @@
+We add -fstack-clash-protection if requested
+
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -2698,7 +2698,7 @@ Common Alias(fstack-check=, specific, no
+ Insert stack checking code into the program. Same as -fstack-check=specific.
+
+ fstack-clash-protection
+-Common Var(flag_stack_clash_protection) Optimization
++Common Var(flag_stack_clash_protection) Optimization Init(-1)
+ Insert code to probe each page of stack space as it is allocated to protect
+ from stack-clash style attacks.
+
+--- a/gcc/defaults.h
++++ b/gcc/defaults.h
+@@ -1425,6 +1425,15 @@ see the files COPYING3 and COPYING.RUNTI
+ #define STACK_CHECK_MAX_VAR_SIZE (STACK_CHECK_MAX_FRAME_SIZE / 100)
+ #endif
+
++/* Default value for flag_clash_protector when flag_clash_protector is
++ initialized to -1. */
++#if defined(DEF_GENTOO_SCP) && !defined(ACCEL_COMPILER)
++#define DEFAULT_FLAG_SCP 1
++#endif
++#ifndef DEFAULT_FLAG_SCP
++#define DEFAULT_FLAG_SCP 0
++#endif
++
+ /* By default, the C++ compiler will use function addresses in the
+ vtable entries. Setting this nonzero tells the compiler to use
+ function descriptors instead. The value of this macro says how
+--- a/gcc/toplev.cc
++++ b/gcc/toplev.cc
+@@ -1610,6 +1610,10 @@ process_options (void)
+
+ /* -fstack-clash-protection is not currently supported on targets
+ where the stack grows up. */
++ if (flag_stack_clash_protection == -1)
++ {
++ flag_stack_clash_protection = DEFAULT_FLAG_SCP;
++ }
+ if (flag_stack_clash_protection && !STACK_GROWS_DOWNWARD)
+ {
+ warning_at (UNKNOWN_LOCATION, 0,
+
+--- a/libgcc/Makefile.in
++++ b/libgcc/Makefile.in
+@@ -246,7 +246,7 @@ endif
+ LIBGCC2_DEBUG_CFLAGS = -g
+ LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \
+ $(LIBGCC2_DEBUG_CFLAGS) -DIN_LIBGCC2 \
+- -fbuilding-libgcc -fno-stack-protector \
++ -fbuilding-libgcc -fno-stack-protector -fno-stack-clash-protection \
+ $(INHIBIT_LIBC_CFLAGS)
+
+ # Additional options to use when compiling libgcc2.a.
+@@ -302,7 +302,7 @@ INTERNAL_CFLAGS = $(CFLAGS) $(LIBGCC2_CF
+ $(NO_PIE_CFLAGS) -finhibit-size-directive -fno-inline -fno-exceptions \
+ -fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize \
+ -fbuilding-libgcc -fno-stack-protector $(FORCE_EXPLICIT_EH_REGISTRY) \
+- $(INHIBIT_LIBC_CFLAGS) $(USE_TM_CLONE_REGISTRY)
++ -fno-stack-clash-protection $(INHIBIT_LIBC_CFLAGS) $(USE_TM_CLONE_REGISTRY)
+
+ # Extra flags to use when compiling crt{begin,end}.o.
+ CRTSTUFF_T_CFLAGS =
diff --git a/16.2.0/gentoo/26_all_enable-cet.patch b/16.2.0/gentoo/26_all_enable-cet.patch
new file mode 100644
index 0000000..6d977cf
--- /dev/null
+++ b/16.2.0/gentoo/26_all_enable-cet.patch
@@ -0,0 +1,193 @@
+https://bugs.gentoo.org/822036
+https://salsa.debian.org/toolchain-team/gcc/-/blob/master/debian/patches/gcc-distro-specs.diff
+
+From: Sam James <[email protected]>
+Subject: [PATCH] Enable CET (-fcf-protection=full) by default
+
+Needs:
+- CET to be enabled for GCC
+- -DEXTRA_OPTIONS_CF to be passed during build (via toolchain.eclass).
+
+Only supported on amd64.
+--- a/gcc/cp/lang-specs.h
++++ b/gcc/cp/lang-specs.h
+@@ -57,7 +57,7 @@ along with GCC; see the file COPYING3. If not see
+ " %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}"
+ " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}"
+ " %{fmodules*:-fmodule-header %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(default_flag_cf_spec) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s}"
+ " %{!fmodule-*:%{!fmodules*:%{!fdump-ada-spec*:"
+@@ -78,7 +78,7 @@ along with GCC; see the file COPYING3. If not see
+ " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}"
+ " %{fmodules*:-fmodule-header=system"
+ " %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(default_flag_cf_spec) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s}"
+ " %{!fmodule-*:%{!fmodules*:%{!fdump-ada-spec*:"
+@@ -98,7 +98,7 @@ along with GCC; see the file COPYING3. If not see
+ " %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}"
+ " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}"
+ " %{fmodules*:-fmodule-header=user %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(default_flag_cf_spec) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s}"
+ " %{!fmodule-*:%{!fmodules*:%{!fdump-ada-spec*:"
+@@ -113,7 +113,7 @@ along with GCC; see the file COPYING3. If not see
+ " cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed"
+ " %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}"
+ " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(default_flag_cf_spec) %2"
+ " %{!fsyntax-only:"
+ " %{fmodule-only:%{!S:-o %g.s%V}}"
+ " %{!fmodule-only:%(invoke_as)}}"
+@@ -122,7 +122,7 @@ along with GCC; see the file COPYING3. If not see
+ {".ii", "@c++-cpp-output", 0, 0, 0},
+ {"@c++-cpp-output",
+ "%{!E:%{!M:%{!MM:"
+- " cc1plus -fpreprocessed %i %(cc1_options) %2"
++ " cc1plus -fpreprocessed %i %(cc1_options) %(default_flag_cf_spec) %2"
+ " %{!fsyntax-only:"
+ " %{fmodule-only:%{!S:-o %g.s%V}}"
+ " %{!fmodule-only:%{!fmodule-header*:%(invoke_as)}}}"
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -1011,6 +1011,18 @@ proper position among the other output files. */
+ #define LINK_NOW_SPEC ""
+ #endif
+
++/* Default value for flag_cf_protection when flag_cf_protection is
++ initialized to CF_FULL.
++
++ We use a new option (EXTRA_OPTIONS_CF) here to avoid turning
++ this on accidentally for other arches. */
++#if defined(EXTRA_OPTIONS_CF) && !defined(ACCEL_COMPILER)
++#define DEFAULT_FLAG_CF_SPEC " %{!m16:%{!m32:%{!fcf-protection*:%{!fno-cf-protection:-fcf-protection}}}} -foffload-options=-fcf-protection=none"
++#endif
++#ifndef DEFAULT_FLAG_CF_SPEC
++#define DEFAULT_FLAG_CF_SPEC ""
++#endif
++
+ #ifdef ENABLE_DEFAULT_PIE
+ #define PIE_SPEC "!no-pie"
+ #define NO_FPIE1_SPEC "fno-pie"
+@@ -1217,6 +1229,7 @@ static const char *cpp_spec = CPP_SPEC;
+ static const char *cc1_spec = CC1_SPEC OS_CC1_SPEC;
+ static const char *cc1plus_spec = CC1PLUS_SPEC;
+ static const char *link_gcc_c_sequence_spec = LINK_GCC_C_SEQUENCE_SPEC;
++static const char *default_flag_cf_spec = DEFAULT_FLAG_CF_SPEC;
+ static const char *link_ssp_spec = LINK_SSP_SPEC;
+ static const char *asm_spec = ASM_SPEC;
+ static const char *asm_final_spec = ASM_FINAL_SPEC;
+@@ -1277,7 +1290,7 @@ static const char *cpp_options =
+ "%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w}\
+ %{f*} %{g*:%{%:debug-level-gt(0):%{g*}\
+ %{!fno-working-directory:-fworking-directory}}} %{O*}\
+- %{undef} %{save-temps*:-fpch-preprocess}";
++ %{undef} %{save-temps*:-fpch-preprocess} %(default_flag_cf_spec)";
+
+ /* Pass -d* flags, possibly modifying -dumpdir, -dumpbase et al.
+
+@@ -1471,9 +1484,9 @@ static const struct compiler default_compilers[] =
+ %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \
+ %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\
+ cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \
+- %(cc1_options)}\
++ %(cc1_options)%(default_flag_cf_spec)}\
+ %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\
+- cc1 %(cpp_unique_options) %(cc1_options)}}}\
++ cc1 %(cpp_unique_options) %(cc1_options) %(default_flag_cf_spec)}}}\
+ %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 1},
+ {"-",
+ "%{!E:%e-E or -x required when input is from standard input}\
+@@ -1498,7 +1511,7 @@ static const struct compiler default_compilers[] =
+ %W{o*:--output-pch %w%*}}%{!S:%V}}}}}}}}", 0, 0, 0},
+ {".i", "@cpp-output", 0, 0, 0},
+ {"@cpp-output",
+- "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
++ "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %(default_flag_cf_spec) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
+ {".s", "@assembler", 0, 0, 0},
+ {"@assembler",
+ "%{!M:%{!MM:%{!E:%{!S:as %(asm_debug) %(asm_options) %i %A }}}}", 0, 0, 0},
+@@ -1730,6 +1743,7 @@ static struct spec_list static_specs[] =
+ INIT_STATIC_SPEC ("cc1_options", &cc1_options),
+ INIT_STATIC_SPEC ("cc1plus", &cc1plus_spec),
+ INIT_STATIC_SPEC ("link_gcc_c_sequence", &link_gcc_c_sequence_spec),
++ INIT_STATIC_SPEC ("default_flag_cf_spec", &default_flag_cf_spec),
+ INIT_STATIC_SPEC ("link_ssp", &link_ssp_spec),
+ INIT_STATIC_SPEC ("endfile", &endfile_spec),
+ INIT_STATIC_SPEC ("link", &link_spec),
+--- a/gcc/objc/lang-specs.h
++++ b/gcc/objc/lang-specs.h
+@@ -29,9 +29,9 @@ along with GCC; see the file COPYING3. If not see
+ %{traditional|traditional-cpp:\
+ %eGNU Objective C no longer supports traditional compilation}\
+ %{save-temps*|no-integrated-cpp:cc1obj -E %(cpp_options) -o %{save-temps*:%b.mi} %{!save-temps*:%g.mi} \n\
+- cc1obj -fpreprocessed %{save-temps*:%b.mi} %{!save-temps*:%g.mi} %(cc1_options) %{print-objc-runtime-info} %{gen-decls}}\
++ cc1obj -fpreprocessed %{save-temps*:%b.mi} %{!save-temps*:%g.mi} %(cc1_options) %(default_flag_cf_spec) %{print-objc-runtime-info} %{gen-decls}}\
+ %{!save-temps*:%{!no-integrated-cpp:\
+- cc1obj %(cpp_unique_options) %(cc1_options) %{print-objc-runtime-info} %{gen-decls}}}\
++ cc1obj %(cpp_unique_options) %(cc1_options) %(default_flag_cf_spec) %{print-objc-runtime-info} %{gen-decls}}}\
+ %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
+ {"@objective-c-header",
+ "%{E|M|MM:cc1obj -E %{traditional|traditional-cpp:-traditional-cpp}\
+@@ -40,18 +40,18 @@ along with GCC; see the file COPYING3. If not see
+ %{traditional|traditional-cpp:\
+ %eGNU Objective C no longer supports traditional compilation}\
+ %{save-temps*|no-integrated-cpp:cc1obj -E %(cpp_options) -o %{save-temps*:%b.mi} %{!save-temps*:%g.mi} \n\
+- cc1obj -fpreprocessed %b.mi %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\
++ cc1obj -fpreprocessed %b.mi %(cc1_options) %(default_flag_cf_spec) %{print-objc-runtime-info} %{gen-decls}\
+ -o %g.s %{!o*:--output-pch %i.gch}\
+ %W{o*:--output-pch %*}%V}\
+ %{!save-temps*:%{!no-integrated-cpp:\
+- cc1obj %(cpp_unique_options) %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\
++ cc1obj %(cpp_unique_options) %(cc1_options) %(default_flag_cf_spec) %{print-objc-runtime-info} %{gen-decls}\
+ -o %g.s %{!o*:--output-pch %i.gch}\
+ %W{o*:--output-pch %*}%V}}}}}", 0, 0, 0},
+ {".mi", "@objective-c-cpp-output", 0, 0, 0},
+ {"@objective-c-cpp-output",
+- "%{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\
++ "%{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %(default_flag_cf_spec) %{print-objc-runtime-info} %{gen-decls}\
+ %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
+ {"@objc-cpp-output",
+ "%nobjc-cpp-output is deprecated; please use objective-c-cpp-output instead\n\
+- %{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\
++ %{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %(default_flag_cf_spec) %{print-objc-runtime-info} %{gen-decls}\
+ %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
+--- a/gcc/objcp/lang-specs.h
++++ b/gcc/objcp/lang-specs.h
+@@ -36,7 +36,7 @@ along with GCC; see the file COPYING3. If not see
+ %(cpp_options) %2 -o %{save-temps*:%b.mii} %{!save-temps*:%g.mii} \n}\
+ cc1objplus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.mii} %{!save-temps*:%g.mii}}\
+ %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\
+- %(cc1_options) %2\
++ %(cc1_options) %(default_flag_cf_spec) %2\
+ -o %g.s %{!o*:--output-pch %i.gch} %W{o*:--output-pch %*}%V}}}",
+ CPLUSPLUS_CPP_SPEC, 0, 0},
+ {"@objective-c++",
+@@ -46,16 +46,16 @@ along with GCC; see the file COPYING3. If not see
+ %(cpp_options) %2 -o %{save-temps*:%b.mii} %{!save-temps*:%g.mii} \n}\
+ cc1objplus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.mii} %{!save-temps*:%g.mii}}\
+ %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\
+- %(cc1_options) %2\
++ %(cc1_options) %(default_flag_cf_spec) %2\
+ %{!fsyntax-only:%(invoke_as)}}}}",
+ CPLUSPLUS_CPP_SPEC, 0, 0},
+ {".mii", "@objective-c++-cpp-output", 0, 0, 0},
+ {"@objective-c++-cpp-output",
+ "%{!M:%{!MM:%{!E:\
+- cc1objplus -fpreprocessed %i %(cc1_options) %2\
++ cc1objplus -fpreprocessed %i %(cc1_options) %(default_flag_cf_spec) %2\
+ %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
+ {"@objc++-cpp-output",
+ "%nobjc++-cpp-output is deprecated; please use objective-c++-cpp-output instead\n\
+ %{!M:%{!MM:%{!E:\
+- cc1objplus -fpreprocessed %i %(cc1_options) %2\
++ cc1objplus -fpreprocessed %i %(cc1_options) %(default_flag_cf_spec) %2\
+ %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
diff --git a/16.2.0/gentoo/28_all_drop_CFLAGS_sed.patch b/16.2.0/gentoo/28_all_drop_CFLAGS_sed.patch
new file mode 100644
index 0000000..b160c92
--- /dev/null
+++ b/16.2.0/gentoo/28_all_drop_CFLAGS_sed.patch
@@ -0,0 +1,67 @@
+https://bugs.gentoo.org/849722
+https://github.com/InBetweenNames/gentooLTO/issues/846
+https://github.com/vaeth/portage-bashrc-mv/issues/11
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -5473,29 +5473,6 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
+ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+-# Remove all -O flags: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *)
+- new_CFLAGS=
+- for flag in $CFLAGS; do
+- case $flag in
+- -O*) ;;
+- *) new_CFLAGS="$new_CFLAGS $flag" ;;
+- esac
+- done
+- CFLAGS=$new_CFLAGS
+- new_CXXFLAGS=
+- for flag in $CXXFLAGS; do
+- case $flag in
+- -O*) ;;
+- *) new_CXXFLAGS="$new_CXXFLAGS $flag" ;;
+- esac
+- done
+- CXXFLAGS=$new_CXXFLAGS
+- ;;
+-esac
+
+
+
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -463,29 +463,6 @@ ACX_PROG_GDC([-I"$srcdir"/d])
+ # Do configure tests with the C++ compiler, since that's what we build with.
+ AC_LANG(C++)
+
+-# Remove all -O flags: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *)
+- new_CFLAGS=
+- for flag in $CFLAGS; do
+- case $flag in
+- -O*) ;;
+- *) new_CFLAGS="$new_CFLAGS $flag" ;;
+- esac
+- done
+- CFLAGS=$new_CFLAGS
+- new_CXXFLAGS=
+- for flag in $CXXFLAGS; do
+- case $flag in
+- -O*) ;;
+- *) new_CXXFLAGS="$new_CXXFLAGS $flag" ;;
+- esac
+- done
+- CXXFLAGS=$new_CXXFLAGS
+- ;;
+-esac
+ AC_SUBST(CFLAGS)
+ AC_SUBST(CXXFLAGS)
+ AC_SUBST(GDCFLAGS)
diff --git a/16.2.0/gentoo/29_all_msgfmt-libstdc++-link.patch b/16.2.0/gentoo/29_all_msgfmt-libstdc++-link.patch
new file mode 100644
index 0000000..0d2f113
--- /dev/null
+++ b/16.2.0/gentoo/29_all_msgfmt-libstdc++-link.patch
@@ -0,0 +1,39 @@
+Ensure that msgfmt doesn't encounter problems during gcc bootstrapping.
+
+Solves error messages like the following:
+
+msgfmt: /var/tmp/portage/sys-devel/gcc-4.1.2/work/build/./gcc/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/libstdc++.so.6)
+
+The libgcc_s.so used during build doesn't satisfy the needs of the
+libstdc++.so that msgfmt is linked against. On the other hand, msgfmt
+is used as a stand-alone application here, and what library it uses
+behind the scenes is of no concern to the gcc build process.
+Therefore, simply invoking it "as usual", i.e. without any special
+library path, will make it work as expected here.
+
+2011-09-19 Martin von Gagern
+
+References:
+https://bugs.gentoo.org/372377
+https://bugs.gentoo.org/295480
+https://bugs.gentoo.org/843119
+--- a/libstdc++-v3/po/Makefile.am
++++ b/libstdc++-v3/po/Makefile.am
+@@ -39,6 +39,7 @@ MSGFMT = msgfmt
+ EXTRA_DIST = string_literals.cc POTFILES.in $(PACKAGE).pot $(LOCALE_IN)
+
+ .po.mo:
++ env --unset=LD_LIBRARY_PATH \
+ $(MSGFMT) -o $@ $<
+
+ all-local: all-local-$(USE_NLS)
+--- a/libstdc++-v3/po/Makefile.in
++++ b/libstdc++-v3/po/Makefile.in
+@@ -419,6 +419,7 @@ uninstall-am: uninstall-info-am
+
+
+ .po.mo:
++ env --unset=LD_LIBRARY_PATH \
+ $(MSGFMT) -o $@ $<
+
+ all-local: all-local-$(USE_NLS)
diff --git a/16.2.0/gentoo/30_all_tar_libstdc++-link.patch b/16.2.0/gentoo/30_all_tar_libstdc++-link.patch
new file mode 100644
index 0000000..adb414a
--- /dev/null
+++ b/16.2.0/gentoo/30_all_tar_libstdc++-link.patch
@@ -0,0 +1,57 @@
+From eae11e896edef4199a128bf6720b5bd4e5edc2f9 Mon Sep 17 00:00:00 2001
+From: Sam James <[email protected]>
+Date: Sat, 17 Dec 2022 02:42:59 +0000
+Subject: [PATCH] Fix calling libarchive's tar
+
+https://bugs.gentoo.org/886447
+
+Very similar to 33_all_msgfmt-libstdc++-link.patch, whose description is:
+"""
+Ensure that msgfmt doesn't encounter problems during gcc bootstrapping.
+
+Solves error messages like the following:
+
+msgfmt: /var/tmp/portage/sys-devel/gcc-4.1.2/work/build/./gcc/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/libstdc++.so.6)
+
+The libgcc_s.so used during build doesn't satisfy the needs of the
+libstdc++.so that msgfmt is linked against. On the other hand, msgfmt
+is used as a stand-alone application here, and what library it uses
+behind the scenes is of no concern to the gcc build process.
+Therefore, simply invoking it "as usual", i.e. without any special
+library path, will make it work as expected here.
+
+2011-09-19 Martin von Gagern
+
+References:
+https://bugs.gentoo.org/372377
+https://bugs.gentoo.org/295480
+https://bugs.gentoo.org/843119
+"""
+
+Signed-off-by: Sam James <[email protected]>
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -3955,10 +3955,10 @@ install-headers-tar: stmp-int-hdrs install-include-dir
+ # Unless a full pathname is provided, some shells would print the new CWD,
+ # found in CDPATH, corrupting the output. We could just redirect the
+ # output of `cd', but some shells lose on redirection within `()'s
+- (cd `${PWD_COMMAND}`/include ; \
+- tar -cf - .; exit 0) | (cd $(DESTDIR)$(libsubdir)/include; tar xpf - )
+- (cd `${PWD_COMMAND}`/include-fixed ; \
+- tar -cf - .; exit 0) | (cd $(DESTDIR)$(libsubdir)/include-fixed; tar xpf - )
++ (unset LD_LIBRARY_PATH ; cd `${PWD_COMMAND}`/include ; \
++ tar -cf - .; exit 0) | (unset LD_LIBRARY_PATH ; cd $(DESTDIR)$(libsubdir)/include; tar xpf - )
++ (unset LD_LIBRARY_PATH ; cd `${PWD_COMMAND}`/include-fixed ; \
++ tar -cf - .; exit 0) | (unset LD_LIBRARY_PATH ; cd $(DESTDIR)$(libsubdir)/include-fixed; tar xpf - )
+ # /bin/sh on some systems returns the status of the first tar,
+ # and that can lose with GNU tar which always writes a full block.
+ # So use `exit 0' to ignore its exit status.
+@@ -3979,7 +3979,7 @@ install-headers-cp: stmp-int-hdrs install-include-dir
+ # Targets without dependencies, for use in prev-gcc during bootstrap.
+ real-install-headers-tar:
+ (cd `${PWD_COMMAND}`/include-fixed ; \
+- tar -cf - .; exit 0) | (cd $(DESTDIR)$(libsubdir)/include-fixed; tar xpf - )
++ unset LD_LIBRARY_PATH; tar -cf - .; exit 0) | (cd $(DESTDIR)$(libsubdir)/include-fixed; unset LD_LIBRARY_PATH; tar xpf - )
+
+ real-install-headers-cpio:
+ cd `${PWD_COMMAND}`/include-fixed ; \
diff --git a/16.2.0/gentoo/32_all_time64.patch b/16.2.0/gentoo/32_all_time64.patch
new file mode 100644
index 0000000..ac972b9
--- /dev/null
+++ b/16.2.0/gentoo/32_all_time64.patch
@@ -0,0 +1,39 @@
+From b2ee3846dfcea638e0fbf2d550234f1c7594fcdb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <[email protected]>
+Date: Fri, 1 Nov 2024 07:48:37 +0100
+Subject: [PATCH] Support forcing _TIME_BITS=64 for time64 profiles
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Support forcing _TIME_BITS=64 and _FILE_OFFSET_BITS=64
+via -D_GENTOO_TIME64_FORCE=1, for time64 profiles.
+
+Signed-off-by: Michał Górny <[email protected]>
+---
+ gcc/c-family/c-cppbuiltin.cc | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc
+index 8bbfe84b2..962cbd414 100644
+--- a/gcc/c-family/c-cppbuiltin.cc
++++ b/gcc/c-family/c-cppbuiltin.cc
+@@ -1593,6 +1593,15 @@ c_cpp_builtins (cpp_reader *pfile)
+ builtin_define_with_int_value ("_FORTIFY_SOURCE", GENTOO_FORTIFY_SOURCE_LEVEL);
+ #endif
+
++#ifndef _GENTOO_TIME64_FORCE
++ #define _GENTOO_TIME64_FORCE 0
++#endif
++
++ if (_GENTOO_TIME64_FORCE) {
++ cpp_define (pfile, "_FILE_OFFSET_BITS=64");
++ cpp_define (pfile, "_TIME_BITS=64");
++ }
++
+ /* Misc. */
+ if (flag_gnu89_inline)
+ cpp_define (pfile, "__GNUC_GNU_INLINE__");
+--
+2.47.0
+
diff --git a/16.2.0/gentoo/33_all_PR80677-cross-limits.patch b/16.2.0/gentoo/33_all_PR80677-cross-limits.patch
new file mode 100644
index 0000000..3cbef01
--- /dev/null
+++ b/16.2.0/gentoo/33_all_PR80677-cross-limits.patch
@@ -0,0 +1,38 @@
+https://gcc.gnu.org/PR80677
+--- a/gcc/limitx.h
++++ b/gcc/limitx.h
+@@ -29,7 +29,7 @@
+ #ifndef _GCC_LIMITS_H_ /* Terminated in limity.h. */
+ #define _GCC_LIMITS_H_
+
+-#ifndef _LIBC_LIMITS_H_
++#if !defined(_LIBC_LIMITS_H_) && __has_include_next(<limits.h>)
+ /* Use "..." so that we find syslimits.h only in this same directory. */
+ #include "syslimits.h"
+ #endif
+--- a/gcc/limity.h
++++ b/gcc/limity.h
+@@ -3,7 +3,7 @@
+
+ #else /* not _GCC_LIMITS_H_ */
+
+-#ifdef _GCC_NEXT_LIMITS_H
++#if defined(_GCC_NEXT_LIMITS_H) && __has_include_next(<limits.h>)
+ #include_next <limits.h> /* recurse down to the real one */
+ #endif
+
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -3344,11 +3344,7 @@ stmp-int-hdrs: $(STMP_FIXINC) $(T_GLIMITS_H) $(T_STDINT_GCC_H) $(USER_H) fixinc_
+ sysroot_headers_suffix=`echo $${ml} | sed -e 's/;.*$$//'`; \
+ multi_dir=`echo $${ml} | sed -e 's/^[^;]*;//'`; \
+ include_dir=include$${multi_dir}; \
+- if $(LIMITS_H_TEST) ; then \
+- cat $(srcdir)/limitx.h $(T_GLIMITS_H) $(srcdir)/limity.h > tmp-xlimits.h; \
+- else \
+- cat $(T_GLIMITS_H) > tmp-xlimits.h; \
+- fi; \
++ cat $(srcdir)/limitx.h $(T_GLIMITS_H) $(srcdir)/limity.h > tmp-xlimits.h; \
+ $(mkinstalldirs) $${include_dir}; \
+ chmod a+rx $${include_dir} || true; \
+ $(SHELL) $(srcdir)/../move-if-change \
diff --git a/16.2.0/gentoo/34_all_time64_ssemath.patch b/16.2.0/gentoo/34_all_time64_ssemath.patch
new file mode 100644
index 0000000..3701b6b
--- /dev/null
+++ b/16.2.0/gentoo/34_all_time64_ssemath.patch
@@ -0,0 +1,43 @@
+From 33ba5944f2b887fe8bddd541790645b74f1f2655 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <[email protected]>
+Date: Sun, 24 Nov 2024 14:45:37 +0100
+Subject: [PATCH] Default to -mfpmath=sse on x86 with time64
+
+Our time64 stages already default to `-mfpmath=sse`, so let's have
+the time64 flag implicitly enable it as the default to make things more
+consistent. Furthermore, this also improves compatibility with clang
+that always enables it whenever the target architectures supports SSE.
+
+Note that this works only if `-march=` with SSE support is specified.
+We could technically improve the consistency even further by raising
+the default `-march=`, but that seems a bit intrusive and probably
+unnecessary, given that the vast majority of Gentoo users and/or
+upstream projects will specify `-march=`.
+
+See also:
+https://public-inbox.gentoo.org/gentoo-dev/ce894afe6c2b324fef012da9bb9387cfde7aed03.camel-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org/
+https://public-inbox.gentoo.org/gentoo-dev/baa1ca92da4941b0999ea2feecf02334b5b20ade.camel-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org/
+---
+ gcc/config/i386/i386-options.cc | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc
+index 6c212a8ed..03801f382 100644
+--- a/gcc/config/i386/i386-options.cc
++++ b/gcc/config/i386/i386-options.cc
+@@ -2881,7 +2881,11 @@ ix86_option_override_internal (bool main_args_p,
+ Also -mfpmath=387 is overall a lot more compact (bout 4-5%) than SSE
+ codegen. We may switch to 387 with -ffast-math for size optimized
+ functions. */
+- else if (fast_math_flags_set_p (&global_options)
++#ifndef _GENTOO_TIME64_FORCE
++ #define _GENTOO_TIME64_FORCE 0
++#endif
++
++ else if ((fast_math_flags_set_p (&global_options) || _GENTOO_TIME64_FORCE)
+ && TARGET_SSE2_P (opts->x_ix86_isa_flags))
+ opts->x_ix86_fpmath = FPMATH_SSE;
+ else
+--
+2.47.0
+
diff --git a/16.2.0/gentoo/35_all_checking-gc-use-heuristics.patch b/16.2.0/gentoo/35_all_checking-gc-use-heuristics.patch
new file mode 100644
index 0000000..35ba553
--- /dev/null
+++ b/16.2.0/gentoo/35_all_checking-gc-use-heuristics.patch
@@ -0,0 +1,22 @@
+GCC's --enable-checking=yes includes 'gc' which also then disables the
+default (already conservative) GC threshold heuristics.
+--- a/gcc/ggc-common.cc
++++ b/gcc/ggc-common.cc
+@@ -1029,7 +1029,7 @@ mmap_gt_pch_use_address (void *&base, size_t size, int fd, size_t offset)
+ }
+ #endif /* HAVE_MMAP_FILE */
+
+-#if !defined ENABLE_GC_CHECKING && !defined ENABLE_GC_ALWAYS_COLLECT
++#if !defined ENABLE_GC_ALWAYS_COLLECT
+
+ /* Modify the bound based on rlimits. */
+ static double
+@@ -1126,7 +1126,7 @@ ggc_min_heapsize_heuristic (void)
+ void
+ init_ggc_heuristics (void)
+ {
+-#if !defined ENABLE_GC_CHECKING && !defined ENABLE_GC_ALWAYS_COLLECT
++#if !defined ENABLE_GC_ALWAYS_COLLECT
+ param_ggc_min_expand = ggc_min_expand_heuristic ();
+ param_ggc_min_heapsize = ggc_min_heapsize_heuristic ();
+ #endif
diff --git a/16.2.0/gentoo/36_all_no-afdo-testing.patch b/16.2.0/gentoo/36_all_no-afdo-testing.patch
new file mode 100644
index 0000000..9282804
--- /dev/null
+++ b/16.2.0/gentoo/36_all_no-afdo-testing.patch
@@ -0,0 +1,13 @@
+`perf` doesn't seem to work well in sandbox and this isn't so useful
+anyway for packaging testing purposes. These tests seemed to hang.
+--- a/gcc/testsuite/lib/target-supports.exp
++++ b/gcc/testsuite/lib/target-supports.exp
+@@ -799,7 +799,7 @@ proc check_profiling_available { test_what } {
+ }
+ puts $wrapper
+ global srcdir
+- set status [remote_exec host "$wrapper true -v >/dev/null"]
++ set status [remote_exec host "false >/dev/null"]
+ if { [lindex $status 0] != 0 } {
+ verbose "autofdo not supported because perf does not work"
+ return 0
diff --git a/16.2.0/gentoo/37_all_PR66487-object-lifetime-instrumentation-for-Valgrind.patch b/16.2.0/gentoo/37_all_PR66487-object-lifetime-instrumentation-for-Valgrind.patch
new file mode 100644
index 0000000..074e941
--- /dev/null
+++ b/16.2.0/gentoo/37_all_PR66487-object-lifetime-instrumentation-for-Valgrind.patch
@@ -0,0 +1,567 @@
+From 8bc449a063d7f3d0929740f179b58239aadbcf21 Mon Sep 17 00:00:00 2001
+Message-ID: <8bc449a063d7f3d0929740f179b58239aadbcf21.1764773217.git.sam-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
+From: Daniil Frolov <[email protected]>
+Date: Fri, 22 Dec 2023 17:10:38 +0300
+Subject: [PATCH] object lifetime instrumentation for Valgrind [PR66487]
+
+PR 66487 is asking to provide sanitizer-like detection for C++ object
+lifetime violations that are worked around with -fno-lifetime-dse or
+-flifetime-dse=1 in Firefox, LLVM (PR 106943), OpenJade (PR 69534).
+
+The discussion in the PR was centered around extending MSan, but MSan
+was not ported to GCC (and requires rebuilding everything with
+instrumentation).
+
+Instead, allow Valgrind to see lifetime boundaries by emitting client
+requests along *this = { CLOBBER }. The client request marks the
+"clobbered" memory as undefined for Valgrind; clobbering assignments
+mark the beginning of ctor and end of dtor execution for C++ objects.
+Hence, attempts to read object storage after the destructor, or
+"pre-initialize" its fields prior to the constructor will be caught.
+
+Valgrind client requests are offered as macros that emit inline asm.
+For use in code generation, let's wrap them as libgcc builtins.
+
+gcc/ChangeLog:
+
+ * Makefile.in (OBJS): Add gimple-valgrind-interop.o.
+ * builtins.def (BUILT_IN_VALGRIND_MAKE_UNDEFINED): New.
+ * common.opt (-fvalgrind-annotations): New option.
+ * doc/install.texi (--enable-valgrind-interop): Document.
+ * doc/invoke.texi (-fvalgrind-annotations): Document.
+ * passes.def (pass_instrument_valgrind): Add.
+ * tree-pass.h (make_pass_instrument_valgrind): Declare.
+ * gimple-valgrind-interop.cc: New file.
+
+libgcc/ChangeLog:
+
+ * Makefile.in (LIB2ADD_ST): Add valgrind-interop.c.
+ * config.in: Regenerate.
+ * configure: Regenerate.
+ * configure.ac (--enable-valgrind-interop): New flag.
+ * libgcc2.h (__gcc_vgmc_make_mem_undefined): Declare.
+ * valgrind-interop.c: New file.
+
+gcc/testsuite/ChangeLog:
+
+ * g++.dg/valgrind-annotations-1.C: New test.
+ * g++.dg/valgrind-annotations-2.C: New test.
+
+Co-authored-by: Alexander Monakov <[email protected]>
+---
+ gcc/Makefile.in | 1 +
+ gcc/builtins.def | 3 +
+ gcc/common.opt | 4 +
+ gcc/doc/install.texi | 5 +
+ gcc/doc/invoke.texi | 27 ++++
+ gcc/gimple-valgrind-interop.cc | 125 ++++++++++++++++++
+ gcc/passes.def | 1 +
+ gcc/testsuite/g++.dg/valgrind-annotations-1.C | 22 +++
+ gcc/testsuite/g++.dg/valgrind-annotations-2.C | 12 ++
+ gcc/tree-pass.h | 1 +
+ libgcc/Makefile.in | 3 +
+ libgcc/config.in | 6 +
+ libgcc/configure | 22 ++-
+ libgcc/configure.ac | 15 ++-
+ libgcc/libgcc2.h | 2 +
+ libgcc/valgrind-interop.c | 40 ++++++
+ 16 files changed, 287 insertions(+), 2 deletions(-)
+ create mode 100644 gcc/gimple-valgrind-interop.cc
+ create mode 100644 gcc/testsuite/g++.dg/valgrind-annotations-1.C
+ create mode 100644 gcc/testsuite/g++.dg/valgrind-annotations-2.C
+ create mode 100644 libgcc/valgrind-interop.c
+
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index 8ecef4ccdc7..e4d803c856f 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -1547,6 +1547,7 @@ OBJS = \
+ gimple-ssa-warn-restrict.o \
+ gimple-streamer-in.o \
+ gimple-streamer-out.o \
++ gimple-valgrind-interop.o \
+ gimple-walk.o \
+ gimple-warn-recursion.o \
+ gimplify.o \
+diff --git a/gcc/builtins.def b/gcc/builtins.def
+index 8ab0599b17f..98c0563e35f 100644
+--- a/gcc/builtins.def
++++ b/gcc/builtins.def
+@@ -1271,6 +1271,9 @@ DEF_GCC_BUILTIN (BUILT_IN_LINE, "LINE", BT_FN_INT, ATTR_NOTHROW_LEAF_LIST)
+ /* Control Flow Redundancy hardening out-of-line checker. */
+ DEF_BUILTIN_STUB (BUILT_IN___HARDCFR_CHECK, "__builtin___hardcfr_check")
+
++/* Wrappers for Valgrind client requests. */
++DEF_EXT_LIB_BUILTIN (BUILT_IN_VALGRIND_MAKE_UNDEFINED, "__gcc_vgmc_make_mem_undefined", BT_FN_VOID_PTR_SIZE, ATTR_NOTHROW_LEAF_LIST)
++
+ /* Synchronization Primitives. */
+ #include "sync-builtins.def"
+
+diff --git a/gcc/common.opt b/gcc/common.opt
+index 5d0e255a40d..a08811122d0 100644
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -3574,6 +3574,10 @@ Enum(auto_init_type) String(pattern) Value(AUTO_INIT_PATTERN)
+ EnumValue
+ Enum(auto_init_type) String(zero) Value(AUTO_INIT_ZERO)
+
++fvalgrind-annotations
++Common Var(flag_valgrind_annotations) Optimization
++Annotate lifetime boundaries with Valgrind client requests.
++
+ ; -fverbose-asm causes extra commentary information to be produced in
+ ; the generated assembly code (to make it more readable). This option
+ ; is generally only of use to those who actually need to read the
+diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
+index 001d16fe67a..7ec45913f92 100644
+--- a/gcc/doc/install.texi
++++ b/gcc/doc/install.texi
+@@ -1708,6 +1708,11 @@ Disable TM clone registry in libgcc. It is enabled in libgcc by default.
+ This option helps to reduce code size for embedded targets which do
+ not use transactional memory.
+
++@item --enable-valgrind-interop
++Provide wrappers for Valgrind client requests in libgcc, which are used for
++@option{-fvalgrind-annotations}. Requires Valgrind header files for the
++target (in the build-time sysroot if building a cross-compiler).
++
+ @item --with-cpu=@var{cpu}
+ @itemx --with-cpu-32=@var{cpu}
+ @itemx --with-cpu-64=@var{cpu}
+diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
+index 9207a021e64..79a4836b00a 100644
+--- a/gcc/doc/invoke.texi
++++ b/gcc/doc/invoke.texi
+@@ -720,6 +720,7 @@ Objective-C and Objective-C++ Dialects}.
+ -fno-stack-limit -fsplit-stack
+ -fstrub=disable -fstrub=strict -fstrub=relaxed
+ -fstrub=all -fstrub=at-calls -fstrub=internal
++-fvalgrind-annotations
+ -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
+ -fvtv-counts -fvtv-debug
+ -finstrument-functions -finstrument-functions-once
+@@ -14204,6 +14205,9 @@ can use @option{-flifetime-dse=1}. The default behavior can be
+ explicitly selected with @option{-flifetime-dse=2}.
+ @option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}.
+
++See @option{-fvalgrind-annotations} for instrumentation that allows to
++detect violations of standard lifetime semantics using Valgrind.
++
+ @opindex flive-range-shrinkage
+ @opindex fno-live-range-shrinkage
+ @item -flive-range-shrinkage
+@@ -18083,6 +18087,29 @@ function attributes that tell which mode was selected for each function.
+ The primary use of this option is for testing, to exercise thoroughly
+ the @code{strub} machinery.
+
++@opindex fvalgrind-annotations
++@item -fvalgrind-annotations
++Emit Valgrind client requests annotating object lifetime boundaries.
++This allows to detect attempts to access fields of a C++ object after
++its destructor has completed (but storage was not deallocated yet), or
++to initialize it in advance from @code{operator new} rather than the
++constructor.
++
++This instrumentation relies on presence of @code{__gcc_vgmc_make_mem_undefined}
++function that wraps the corresponding Valgrind client request. It is provided
++by libgcc when it is configured with @samp{--enable-valgrind-interop}.
++Otherwise, you can implement it like this:
++
++@smallexample
++#include <valgrind/memcheck.h>
++
++void
++__gcc_vgmc_make_mem_undefined (void *addr, size_t size)
++@{
++ VALGRIND_MAKE_MEM_UNDEFINED (addr, size);
++@}
++@end smallexample
++
+ @opindex fvtable-verify
+ @item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
+ This option is only available when compiling C++ code.
+diff --git a/gcc/gimple-valgrind-interop.cc b/gcc/gimple-valgrind-interop.cc
+new file mode 100644
+index 00000000000..05d9bdc6602
+--- /dev/null
++++ b/gcc/gimple-valgrind-interop.cc
+@@ -0,0 +1,125 @@
++/* Annotate lifetime boundaries for Valgrind.
++ Copyright (C) 2023 Free Software Foundation, Inc.
++
++This file is part of GCC.
++
++GCC is free software; you can redistribute it and/or modify it
++under the terms of the GNU General Public License as published by the
++Free Software Foundation; either version 3, or (at your option) any
++later version.
++
++GCC is distributed in the hope that it will be useful, but WITHOUT
++ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++for more details.
++
++You should have received a copy of the GNU General Public License
++along with GCC; see the file COPYING3. If not see
++<http://www.gnu.org/licenses/>. */
++
++#include "config.h"
++#include "system.h"
++#include "coretypes.h"
++#include "tree.h"
++#include "function.h"
++#include "cfg.h"
++#include "basic-block.h"
++#include "gimple.h"
++#include "gimple-iterator.h"
++#include "tree-pass.h"
++#include "gimplify-me.h"
++#include "fold-const.h"
++
++namespace {
++
++/* Emit VALGRIND_MAKE_MEM_UNDEFINED annotation for the object given by VAR. */
++
++bool
++annotate_undef (gimple_stmt_iterator *gsi, tree var)
++{
++ tree size = arg_size_in_bytes (TREE_TYPE (var));
++ if (size == size_zero_node)
++ return false;
++
++ tree addr = build_fold_addr_expr (var);
++ tree decl = builtin_decl_explicit (BUILT_IN_VALGRIND_MAKE_UNDEFINED);
++ tree call = build_call_expr (decl, 2, addr, size);
++
++ force_gimple_operand_gsi (gsi, call, false, NULL_TREE, false, GSI_NEW_STMT);
++ return true;
++}
++
++const pass_data pass_data_instrument_valgrind = {
++ GIMPLE_PASS, /* type */
++ "valgrind", /* name */
++ OPTGROUP_NONE, /* optinfo_flags */
++ TV_NONE, /* tv_id */
++ PROP_cfg, /* properties_required */
++ 0, /* properties_provided */
++ 0, /* properties_destroyed */
++ 0, /* todo_flags_start */
++ 0, /* todo_flags_finish */
++};
++
++}
++
++class pass_instrument_valgrind : public gimple_opt_pass
++{
++public:
++ pass_instrument_valgrind (gcc::context *ctxt)
++ : gimple_opt_pass (pass_data_instrument_valgrind, ctxt)
++ {
++ }
++
++ unsigned int execute (function *) final override;
++ bool gate (function *) final override;
++};
++
++bool
++pass_instrument_valgrind::gate (function *)
++{
++ return flag_valgrind_annotations;
++}
++
++/* Scan for GIMPLE clobbers that mark object lifetime boundaries and
++ make them known to Valgrind by emitting corresponding client requests. */
++
++unsigned int
++pass_instrument_valgrind::execute (function *fun)
++{
++ bool changed = false;
++ basic_block bb;
++ FOR_EACH_BB_FN (bb, fun)
++ {
++ for (gimple_stmt_iterator gsi = gsi_start_nondebug_bb (bb);
++ !gsi_end_p (gsi); gsi_next_nondebug (&gsi))
++ {
++ gimple *stmt = gsi_stmt (gsi);
++
++ if (gimple_clobber_p (stmt))
++ switch (CLOBBER_KIND (gimple_assign_rhs1 (stmt)))
++ {
++ case CLOBBER_UNDEF:
++ case CLOBBER_OBJECT_BEGIN:
++ case CLOBBER_OBJECT_END:
++ changed |= annotate_undef (&gsi, gimple_assign_lhs (stmt));
++ break;
++ case CLOBBER_STORAGE_BEGIN:
++ case CLOBBER_STORAGE_END:
++ /* Leave these for ASan. */
++ break;
++ case CLOBBER_LAST:
++ default:
++ gcc_unreachable ();
++ }
++ }
++ }
++
++ return changed ? TODO_update_ssa : 0;
++}
++
++gimple_opt_pass *
++make_pass_instrument_valgrind (gcc::context *ctxt)
++{
++ return new pass_instrument_valgrind (ctxt);
++}
+diff --git a/gcc/passes.def b/gcc/passes.def
+index cdddb87302f..52d6e22e06f 100644
+--- a/gcc/passes.def
++++ b/gcc/passes.def
+@@ -57,6 +57,7 @@ along with GCC; see the file COPYING3. If not see
+ PUSH_INSERT_PASSES_WITHIN (pass_build_ssa_passes)
+ NEXT_PASS (pass_fixup_cfg);
+ NEXT_PASS (pass_build_ssa);
++ NEXT_PASS (pass_instrument_valgrind);
+ NEXT_PASS (pass_walloca, /*strict_mode_p=*/true);
+ NEXT_PASS (pass_warn_printf);
+ NEXT_PASS (pass_warn_nonnull_compare);
+diff --git a/gcc/testsuite/g++.dg/valgrind-annotations-1.C b/gcc/testsuite/g++.dg/valgrind-annotations-1.C
+new file mode 100644
+index 00000000000..49dc5a9cf13
+--- /dev/null
++++ b/gcc/testsuite/g++.dg/valgrind-annotations-1.C
+@@ -0,0 +1,22 @@
++/* { dg-do compile { target c++11 } } */
++/* { dg-options "-O2 -fvalgrind-annotations -fdump-tree-optimized" } */
++
++#include <new>
++
++struct Foo
++{
++ int val;
++};
++
++struct Bar : Foo
++{
++ Bar() {}
++};
++
++int main ()
++{
++ alignas(Bar) char buf [sizeof (Bar)];
++ Bar *obj = new(buf) Bar;
++}
++
++/* { dg-final { scan-tree-dump-times "__builtin___gcc_vgmc_make_mem_undefined" 1 "optimized" } } */
+diff --git a/gcc/testsuite/g++.dg/valgrind-annotations-2.C b/gcc/testsuite/g++.dg/valgrind-annotations-2.C
+new file mode 100644
+index 00000000000..a8b646d0765
+--- /dev/null
++++ b/gcc/testsuite/g++.dg/valgrind-annotations-2.C
+@@ -0,0 +1,12 @@
++/* { dg-do compile { target c++11 } } */
++/* { dg-options "-O2 -fvalgrind-annotations -fdump-tree-optimized" } */
++
++struct Foo
++{
++ char buf [1024];
++ Foo () {}
++};
++
++Foo Obj;
++
++/* { dg-final { scan-tree-dump-times "__builtin___gcc_vgmc_make_mem_undefined" 1 "optimized" } } */
+diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h
+index b3c97658a8f..d26fb67336b 100644
+--- a/gcc/tree-pass.h
++++ b/gcc/tree-pass.h
+@@ -444,6 +444,7 @@ extern gimple_opt_pass *make_pass_omp_device_lower (gcc::context *ctxt);
+ extern gimple_opt_pass *make_pass_object_sizes (gcc::context *ctxt);
+ extern gimple_opt_pass *make_pass_early_object_sizes (gcc::context *ctxt);
+ extern gimple_opt_pass *make_pass_warn_access (gcc::context *ctxt);
++extern gimple_opt_pass *make_pass_instrument_valgrind (gcc::context *ctxt);
+ extern gimple_opt_pass *make_pass_warn_printf (gcc::context *ctxt);
+ extern gimple_opt_pass *make_pass_warn_recursion (gcc::context *ctxt);
+ extern gimple_opt_pass *make_pass_strlen (gcc::context *ctxt);
+diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
+index 8b8fe6e9a28..e2743a710c6 100644
+--- a/libgcc/Makefile.in
++++ b/libgcc/Makefile.in
+@@ -442,6 +442,9 @@ LIB2ADD += $(srcdir)/hardcfr.c
+ # Stack scrubbing infrastructure.
+ @HAVE_STRUB_SUPPORT@LIB2ADD += $(srcdir)/strub.c
+
++# Wrappers for Valgrind client requests.
++LIB2ADD_ST += $(srcdir)/valgrind-interop.c
++
+ # While emutls.c has nothing to do with EH, it is in LIB2ADDEH*
+ # instead of LIB2ADD because that's the way to be sure on some targets
+ # (e.g. *-*-darwin*) only one copy of it is linked.
+diff --git a/libgcc/config.in b/libgcc/config.in
+index a8b6f91610e..5d82224cd9e 100644
+--- a/libgcc/config.in
++++ b/libgcc/config.in
+@@ -3,6 +3,9 @@
+ /* Define to the .hidden-like directive if it exists. */
+ #undef AS_HIDDEN_DIRECTIVE
+
++/* Build Valgrind request wrappers */
++#undef ENABLE_VALGRIND_INTEROP
++
+ /* Define to 1 if the assembler supports AVX. */
+ #undef HAVE_AS_AVX
+
+@@ -61,6 +64,9 @@
+ /* Define to 1 if you have the <unistd.h> header file. */
+ #undef HAVE_UNISTD_H
+
++/* Define to 1 if you have the <valgrind/memcheck.h> header file. */
++#undef HAVE_VALGRIND_MEMCHECK_H
++
+ /* Define to 1 if __getauxval is available. */
+ #undef HAVE___GETAUXVAL
+
+diff --git a/libgcc/configure b/libgcc/configure
+index f2bee6d90fe..4dcf17fab00 100755
+--- a/libgcc/configure
++++ b/libgcc/configure
+@@ -719,6 +719,7 @@ with_system_libunwind
+ enable_cet
+ enable_explicit_exception_frame_registration
+ enable_tm_clone_registry
++enable_valgrind_interop
+ with_glibc_version
+ enable_tls
+ with_gcc_major_version_only
+@@ -1364,6 +1365,8 @@ Optional Features:
+ start, for use e.g. for compatibility with
+ installations without PT_GNU_EH_FRAME support
+ --disable-tm-clone-registry disable TM clone registry
++ --enable-valgrind-interop
++ build wrappers for Valgrind client requests
+ --enable-tls Use thread-local storage [default=yes]
+ --enable-werror build with -Werror for selected targets
+
+@@ -4472,7 +4475,8 @@ as_fn_arith $ac_cv_sizeof_long_double \* 8 && long_double_type_size=$as_val
+
+ for ac_header in inttypes.h stdint.h stdlib.h ftw.h \
+ unistd.h sys/stat.h sys/types.h \
+- string.h strings.h memory.h sys/auxv.h sys/mman.h
++ string.h strings.h memory.h sys/auxv.h sys/mman.h \
++ valgrind/memcheck.h
+ do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ ac_fn_c_check_header_preproc "$LINENO" "$ac_header" "$as_ac_Header"
+@@ -5064,6 +5068,22 @@ fi
+
+
+
++# Check whether --enable-valgrind-interop was given.
++if test "${enable_valgrind_interop+set}" = set; then :
++ enableval=$enable_valgrind_interop;
++else
++ enable_valgrind_interop=no
++fi
++
++if test $enable_valgrind_interop != no; then
++ if test $ac_cv_header_valgrind_memcheck_h = no; then
++ as_fn_error $? "--enable-valgrind-interop: valgrind/memcheck.h not found" "$LINENO" 5
++ fi
++
++$as_echo "#define ENABLE_VALGRIND_INTEROP 1" >>confdefs.h
++
++fi
++
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+ $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+ if ${acl_cv_prog_gnu_ld+:} false; then :
+diff --git a/libgcc/configure.ac b/libgcc/configure.ac
+index 72d23b427d0..40fafa45adf 100644
+--- a/libgcc/configure.ac
++++ b/libgcc/configure.ac
+@@ -231,7 +231,8 @@ AC_SUBST(long_double_type_size)
+
+ AC_CHECK_HEADERS(inttypes.h stdint.h stdlib.h ftw.h \
+ unistd.h sys/stat.h sys/types.h \
+- string.h strings.h memory.h sys/auxv.h sys/mman.h)
++ string.h strings.h memory.h sys/auxv.h sys/mman.h \
++ valgrind/memcheck.h)
+ AC_HEADER_STDC
+
+ # Check for decimal float support.
+@@ -317,6 +318,18 @@ esac
+ ])
+ AC_SUBST([use_tm_clone_registry])
+
++AC_ARG_ENABLE([valgrind-interop],
++ [AC_HELP_STRING([--enable-valgrind-interop],
++ [build wrappers for Valgrind client requests])],
++ [],
++ [enable_valgrind_interop=no])
++if test $enable_valgrind_interop != no; then
++ if test $ac_cv_header_valgrind_memcheck_h = no; then
++ AC_MSG_ERROR([--enable-valgrind-interop: valgrind/memcheck.h not found])
++ fi
++ AC_DEFINE(ENABLE_VALGRIND_INTEROP, 1, [Build Valgrind request wrappers])
++fi
++
+ AC_LIB_PROG_LD_GNU
+
+ GCC_AC_THREAD_MODEL
+diff --git a/libgcc/libgcc2.h b/libgcc/libgcc2.h
+index 79185d8e880..9e23a19ebeb 100644
+--- a/libgcc/libgcc2.h
++++ b/libgcc/libgcc2.h
+@@ -560,6 +560,8 @@ extern void __strub_enter (void **);
+ extern void __strub_update (void**);
+ extern void __strub_leave (void **);
+
++extern void __gcc_vgmc_make_mem_undefined (void *, size_t);
++
+ #ifndef HIDE_EXPORTS
+ #pragma GCC visibility pop
+ #endif
+diff --git a/libgcc/valgrind-interop.c b/libgcc/valgrind-interop.c
+new file mode 100644
+index 00000000000..fdb8d41bc56
+--- /dev/null
++++ b/libgcc/valgrind-interop.c
+@@ -0,0 +1,40 @@
++/* Wrappers for Valgrind client requests.
++ Copyright (C) 2023 Free Software Foundation, Inc.
++
++This file is part of GCC.
++
++GCC is free software; you can redistribute it and/or modify it under
++the terms of the GNU General Public License as published by the Free
++Software Foundation; either version 3, or (at your option) any later
++version.
++
++GCC is distributed in the hope that it will be useful, but WITHOUT ANY
++WARRANTY; without even the implied warranty of MERCHANTABILITY or
++FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++for more details.
++
++Under Section 7 of GPL version 3, you are granted additional
++permissions described in the GCC Runtime Library Exception, version
++3.1, as published by the Free Software Foundation.
++
++You should have received a copy of the GNU General Public License and
++a copy of the GCC Runtime Library Exception along with this program;
++see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
++<http://www.gnu.org/licenses/>. */
++
++#include "tsystem.h"
++#include "auto-target.h"
++
++#ifdef ENABLE_VALGRIND_INTEROP
++
++#include <valgrind/memcheck.h>
++
++/* Externally callable wrapper for Valgrind Memcheck client request:
++ declare SIZE bytes of memory at address ADDR as uninitialized. */
++
++void
++__gcc_vgmc_make_mem_undefined (void *addr, size_t size)
++{
++ VALGRIND_MAKE_MEM_UNDEFINED (addr, size);
++}
++#endif
diff --git a/16.2.0/gentoo/38_all_hurd_linker_path.patch b/16.2.0/gentoo/38_all_hurd_linker_path.patch
new file mode 100644
index 0000000..a848fc8
--- /dev/null
+++ b/16.2.0/gentoo/38_all_hurd_linker_path.patch
@@ -0,0 +1,26 @@
+The paths for native and multilib were inconsistent (ld.so vs ld.so.1;
+correct for multilib).
+--- a/gcc/config/i386/gnu.h
++++ b/gcc/config/i386/gnu.h
+@@ -22,7 +22,7 @@ along with GCC. If not, see <http://www.gnu.org/licenses/>.
+ #define GNU_USER_LINK_EMULATION "elf_i386"
+
+ #undef GNU_USER_DYNAMIC_LINKER
+-#define GNU_USER_DYNAMIC_LINKER "/lib/ld.so"
++#define GNU_USER_DYNAMIC_LINKER "/lib/ld.so.1"
+
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+
+--- a/gcc/config/i386/gnu64.h
++++ b/gcc/config/i386/gnu64.h
+@@ -25,8 +25,8 @@ along with GCC. If not, see <http://www.gnu.org/licenses/>.
+
+ #undef GNU_USER_DYNAMIC_LINKER
+ #define GNU_USER_DYNAMIC_LINKER32 "/lib/ld.so.1"
+-#define GNU_USER_DYNAMIC_LINKER64 "/lib/ld-x86-64.so.1"
+-#define GNU_USER_DYNAMIC_LINKERX32 "/lib/ld-x32.so.1"
++#define GNU_USER_DYNAMIC_LINKER64 "/lib64/ld-x86-64.so.1"
++#define GNU_USER_DYNAMIC_LINKERX32 "/libx32/ld-x32.so.1"
+
+ #undef STARTFILE_SPEC
+ #if defined HAVE_LD_PIE
diff --git a/16.2.0/gentoo/76_all_PR117854-config-nvptx-fix-bashisms-with-gen-copyright.sh-use.patch b/16.2.0/gentoo/76_all_PR117854-config-nvptx-fix-bashisms-with-gen-copyright.sh-use.patch
new file mode 100644
index 0000000..263204e
--- /dev/null
+++ b/16.2.0/gentoo/76_all_PR117854-config-nvptx-fix-bashisms-with-gen-copyright.sh-use.patch
@@ -0,0 +1,68 @@
+From f6959883aecd1500698ea969de631ffa010ce833 Mon Sep 17 00:00:00 2001
+Message-ID: <f6959883aecd1500698ea969de631ffa010ce833.1733807152.git.sam-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
+From: Sam James <[email protected]>
+Date: Fri, 6 Dec 2024 09:11:11 +0000
+Subject: [PATCH] config: nvptx: fix bashisms with gen-copyright.sh use
+
+Providing parameters to `.` when sourcing is a bashism and not supported
+by POSIX shell which causes a build failure when compiling a toolchain
+for nvptx-none with dash as /bin/sh.
+
+gen-copyright.sh takes a parameter for the format of copyright notice
+required. Switch that to using an environment variable `NVPTX_GEN_COPYRIGHT`,
+although this could be changed to a function if desired (just more churn
+in gen-copyright.sh then).
+
+gcc/ChangeLog:
+ PR target/117854
+
+ * config/nvptx/gen-copyright.sh: Read NVPTX_GEN_COPYRIGHT envvar.
+ * config/nvptx/gen-h.sh: Set NVPTX_GEN_COPYRIGHT.
+ * config/nvptx/gen-opt.sh: Ditto.
+---
+ gcc/config/nvptx/gen-copyright.sh | 2 +-
+ gcc/config/nvptx/gen-h.sh | 2 +-
+ gcc/config/nvptx/gen-opt.sh | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/gcc/config/nvptx/gen-copyright.sh b/gcc/config/nvptx/gen-copyright.sh
+index d0a86acb832c..b140de0eb76d 100644
+--- a/gcc/config/nvptx/gen-copyright.sh
++++ b/gcc/config/nvptx/gen-copyright.sh
+@@ -18,7 +18,7 @@
+ # along with GCC; see the file COPYING3. If not see
+ # <http://www.gnu.org/licenses/>.
+
+-style="$1"
++style="${NVPTX_GEN_COPYRIGHT}"
+ case $style in
+ opt)
+ ;;
+diff --git a/gcc/config/nvptx/gen-h.sh b/gcc/config/nvptx/gen-h.sh
+index bc4ce9af1e2a..a5c18d864504 100644
+--- a/gcc/config/nvptx/gen-h.sh
++++ b/gcc/config/nvptx/gen-h.sh
+@@ -36,7 +36,7 @@ EOF
+ # Separator.
+ echo
+
+-. $gen_copyright_sh c
++NVPTX_GEN_COPYRIGHT=c . $gen_copyright_sh
+
+ # Separator.
+ echo
+diff --git a/gcc/config/nvptx/gen-opt.sh b/gcc/config/nvptx/gen-opt.sh
+index 103bcddc02b5..40c949425f27 100644
+--- a/gcc/config/nvptx/gen-opt.sh
++++ b/gcc/config/nvptx/gen-opt.sh
+@@ -40,7 +40,7 @@ EOF
+ # Separator.
+ echo
+
+-. $gen_copyright_sh opt
++NVPTX_GEN_COPYRIGHT=opt . $gen_copyright_sh
+
+ # Not emitting the following here (in addition to having it in 'nvptx.opt'), as
+ # we'll otherwise run into:
+--
+2.47.1
diff --git a/16.2.0/gentoo/86_all_PR122794-libtool.patch b/16.2.0/gentoo/86_all_PR122794-libtool.patch
new file mode 100644
index 0000000..8a013e9
--- /dev/null
+++ b/16.2.0/gentoo/86_all_PR122794-libtool.patch
@@ -0,0 +1,334 @@
+From 7285d16718aa5d9abccfa005bbab00d9362c25ea Mon Sep 17 00:00:00 2001
+Message-ID: <7285d16718aa5d9abccfa005bbab00d9362c25ea.1765875507.git.sam-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
+From: Stefan Schulze Frielinghaus <stefansf-/[email protected]>
+Date: Wed, 3 Dec 2025 15:03:56 +0100
+Subject: [PATCH] libphobos libgo: Fix dealing with boilerplate [PR122794]
+
+While experimenting with a new warning, I was running into build errors
+for libphobos as e.g.
+
+libtool: compile: mv -f "atomic.o" "core/.libs/atomic.o"
+mv: cannot stat 'atomic.o': No such file or directory
+
+or when building libgo like
+
+libtool: compile: mv -f "tables.o" ".libs/unicode.o"
+mv: cannot stat 'tables.o': No such file or directory
+
+These boil down to the fact that test _LT_COMPILER_C_O evaluates to "no"
+for those, i.e., we have
+
+lt_cv_prog_compiler_c_o=yes
+lt_cv_prog_compiler_c_o_D=no
+
+likewise
+
+lt_cv_prog_compiler_c_o=yes
+lt_cv_prog_compiler_c_o_GO=no
+
+and at the same time _LT_ENABLE_LOCK/need_locks evaluates to "no" which
+breaks parallel builds due to races on those files. Although I think
+for a parallel build need_locks should be rather set to "yes" in case
+_LT_COMPILER_C_O evaluates to "no", this patch enables a parallel build
+without the need of locks.
+
+_LT_COMPILER_C_O evaluates to "no" in the first place because
+boilerplate is computed with a different CC when it is compared to.
+When boilerplate is computed, CC equals xgcc which means we emit
+warnings of the form
+
+xgcc: warning: ...
+d21: warning: ...
+
+whereas when we compute _LT_COMPILER_C_O, CC is changed shortly before
+to gdc so we end up with warnings of the form
+
+gdc: warning: ...
+d21: warning: ...
+
+which ultimately means the check whether the warning is expected fails
+and we do not set _LT_COMPILER_C_O to "yes".
+
+Fixed by moving the computation of boilerplate after setting CC to
+gdc/gccgo.
+
+ PR d/122794
+
+ChangeLog:
+
+ * libgo/config/libtool.m4: Move _LT_COMPILER_BOILERPLATE and
+ _LT_LINKER_BOILERPLATE after setting CC.
+ * libgo/configure: Regenerate.
+
+libphobos/ChangeLog:
+
+* configure: Regenerate.
+ * m4/libtool.m4: Move _LT_COMPILER_BOILERPLATE and
+ _LT_LINKER_BOILERPLATE after setting CC.
+---
+ libgo/config/libtool.m4 | 49 +++++++++++++++++++++--------------------
+ libgo/configure | 28 +++++++++++------------
+ libphobos/configure | 28 +++++++++++------------
+ libphobos/m4/libtool.m4 | 8 +++----
+ 4 files changed, 57 insertions(+), 56 deletions(-)
+
+diff --git a/libgo/config/libtool.m4 b/libgo/config/libtool.m4
+index 4ca90ee71bca..4d27d86b63ba 100644
+--- a/libgo/config/libtool.m4
++++ b/libgo/config/libtool.m4
+@@ -5476,10 +5476,6 @@ if test "$_lt_caught_CXX_error" != yes; then
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+ _LT_TAG_COMPILER
+
+- # save warnings/boilerplate of simple test code
+- _LT_COMPILER_BOILERPLATE
+- _LT_LINKER_BOILERPLATE
+-
+ # Allow CC to be a program name with arguments.
+ lt_save_CC=$CC
+ lt_save_LD=$LD
+@@ -5503,6 +5499,10 @@ if test "$_lt_caught_CXX_error" != yes; then
+ _LT_TAGVAR(compiler, $1)=$CC
+ _LT_CC_BASENAME([$compiler])
+
++ # save warnings/boilerplate of simple test code
++ _LT_COMPILER_BOILERPLATE
++ _LT_LINKER_BOILERPLATE
++
+ if test -n "$compiler"; then
+ # We don't want -fno-exception when compiling C++ code, so set the
+ # no_builtin_flag separately
+@@ -6727,10 +6727,6 @@ if test "$_lt_disable_F77" != yes; then
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+ _LT_TAG_COMPILER
+
+- # save warnings/boilerplate of simple test code
+- _LT_COMPILER_BOILERPLATE
+- _LT_LINKER_BOILERPLATE
+-
+ # Allow CC to be a program name with arguments.
+ lt_save_CC="$CC"
+ lt_save_GCC=$GCC
+@@ -6739,6 +6735,11 @@ if test "$_lt_disable_F77" != yes; then
+ _LT_TAGVAR(compiler, $1)=$CC
+ _LT_CC_BASENAME([$compiler])
+ GCC=$G77
++
++ # save warnings/boilerplate of simple test code
++ _LT_COMPILER_BOILERPLATE
++ _LT_LINKER_BOILERPLATE
++
+ if test -n "$compiler"; then
+ AC_MSG_CHECKING([if libtool supports shared libraries])
+ AC_MSG_RESULT([$can_build_shared])
+@@ -6857,10 +6858,6 @@ if test "$_lt_disable_FC" != yes; then
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+ _LT_TAG_COMPILER
+
+- # save warnings/boilerplate of simple test code
+- _LT_COMPILER_BOILERPLATE
+- _LT_LINKER_BOILERPLATE
+-
+ # Allow CC to be a program name with arguments.
+ lt_save_CC="$CC"
+ lt_save_GCC=$GCC
+@@ -6868,6 +6865,10 @@ if test "$_lt_disable_FC" != yes; then
+ compiler=$CC
+ GCC=$ac_cv_fc_compiler_gnu
+
++ # save warnings/boilerplate of simple test code
++ _LT_COMPILER_BOILERPLATE
++ _LT_LINKER_BOILERPLATE
++
+ _LT_TAGVAR(compiler, $1)=$CC
+ _LT_CC_BASENAME([$compiler])
+
+@@ -6952,10 +6953,6 @@ lt_simple_link_test_code='public class conftest { public static void main(String
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+ _LT_TAG_COMPILER
+
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
+-
+ # Allow CC to be a program name with arguments.
+ lt_save_CC="$CC"
+ lt_save_GCC=$GCC
+@@ -6973,6 +6970,10 @@ _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+ _LT_TAGVAR(reload_flag, $1)=$reload_flag
+ _LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+
++# save warnings/boilerplate of simple test code
++_LT_COMPILER_BOILERPLATE
++_LT_LINKER_BOILERPLATE
++
+ ## CAVEAT EMPTOR:
+ ## There is no encapsulation within the following macros, do not change
+ ## the running order or otherwise move them around unless you know exactly
+@@ -7019,10 +7020,6 @@ lt_simple_link_test_code='package main; func main() { }'
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+ _LT_TAG_COMPILER
+
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
+-
+ # Allow CC to be a program name with arguments.
+ lt_save_CC="$CC"
+ lt_save_GCC="$GCC"
+@@ -7033,6 +7030,10 @@ _LT_TAGVAR(compiler, $1)=$CC
+ _LT_TAGVAR(LD, $1)="$LD"
+ _LT_CC_BASENAME([$compiler])
+
++# save warnings/boilerplate of simple test code
++_LT_COMPILER_BOILERPLATE
++_LT_LINKER_BOILERPLATE
++
+ # Go did not exist at the time GCC didn't implicitly link libc in.
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+@@ -7085,10 +7086,6 @@ lt_simple_link_test_code="$lt_simple_compile_test_code"
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+ _LT_TAG_COMPILER
+
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
+-
+ # Allow CC to be a program name with arguments.
+ lt_save_CC="$CC"
+ lt_save_GCC=$GCC
+@@ -7099,6 +7096,10 @@ _LT_TAGVAR(compiler, $1)=$CC
+ _LT_CC_BASENAME([$compiler])
+ _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+
++# save warnings/boilerplate of simple test code
++_LT_COMPILER_BOILERPLATE
++_LT_LINKER_BOILERPLATE
++
+ if test -n "$compiler"; then
+ :
+ _LT_CONFIG($1)
+diff --git a/libgo/configure b/libgo/configure
+index bba3c7aa7804..ddb6eec5c283 100755
+--- a/libgo/configure
++++ b/libgo/configure
+@@ -11912,20 +11912,6 @@ LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+ compiler=$CC
+
+
+-# save warnings/boilerplate of simple test code
+-ac_outfile=conftest.$ac_objext
+-echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+-_lt_compiler_boilerplate=`cat conftest.err`
+-$RM conftest*
+-
+-ac_outfile=conftest.$ac_objext
+-echo "$lt_simple_link_test_code" >conftest.$ac_ext
+-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+-_lt_linker_boilerplate=`cat conftest.err`
+-$RM -r conftest*
+-
+-
+ # Allow CC to be a program name with arguments.
+ lt_save_CC="$CC"
+ lt_save_GCC="$GCC"
+@@ -11945,6 +11931,20 @@ done
+ cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+
+
++# save warnings/boilerplate of simple test code
++ac_outfile=conftest.$ac_objext
++echo "$lt_simple_compile_test_code" >conftest.$ac_ext
++eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
++_lt_compiler_boilerplate=`cat conftest.err`
++$RM conftest*
++
++ac_outfile=conftest.$ac_objext
++echo "$lt_simple_link_test_code" >conftest.$ac_ext
++eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
++_lt_linker_boilerplate=`cat conftest.err`
++$RM -r conftest*
++
++
+ # Go did not exist at the time GCC didn't implicitly link libc in.
+ archive_cmds_need_lc_GO=no
+
+diff --git a/libphobos/configure b/libphobos/configure
+index 3965e64e593b..65f23887c245 100755
+--- a/libphobos/configure
++++ b/libphobos/configure
+@@ -12624,20 +12624,6 @@ LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+ compiler=$CC
+
+
+-# save warnings/boilerplate of simple test code
+-ac_outfile=conftest.$ac_objext
+-echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+-_lt_compiler_boilerplate=`cat conftest.err`
+-$RM conftest*
+-
+-ac_outfile=conftest.$ac_objext
+-echo "$lt_simple_link_test_code" >conftest.$ac_ext
+-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+-_lt_linker_boilerplate=`cat conftest.err`
+-$RM -r conftest*
+-
+-
+ # Allow CC to be a program name with arguments.
+ lt_save_CC=$CC
+ lt_save_CFLAGS=$CFLAGS
+@@ -12659,6 +12645,20 @@ done
+ cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+
+
++# save warnings/boilerplate of simple test code
++ac_outfile=conftest.$ac_objext
++echo "$lt_simple_compile_test_code" >conftest.$ac_ext
++eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
++_lt_compiler_boilerplate=`cat conftest.err`
++$RM conftest*
++
++ac_outfile=conftest.$ac_objext
++echo "$lt_simple_link_test_code" >conftest.$ac_ext
++eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
++_lt_linker_boilerplate=`cat conftest.err`
++$RM -r conftest*
++
++
+ # GDC did not exist at the time GCC didn't implicitly link libc in.
+ archive_cmds_need_lc_D=no
+
+diff --git a/libphobos/m4/libtool.m4 b/libphobos/m4/libtool.m4
+index 0263a530cf01..6d7a6f958638 100644
+--- a/libphobos/m4/libtool.m4
++++ b/libphobos/m4/libtool.m4
+@@ -34,10 +34,6 @@ lt_simple_link_test_code="\
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+ _LT_TAG_COMPILER
+
+-# save warnings/boilerplate of simple test code
+-_LT_COMPILER_BOILERPLATE
+-_LT_LINKER_BOILERPLATE
+-
+ # Allow CC to be a program name with arguments.
+ lt_save_CC=$CC
+ lt_save_CFLAGS=$CFLAGS
+@@ -50,6 +46,10 @@ _LT_TAGVAR(compiler, $1)=$CC
+ _LT_TAGVAR(LD, $1)=$CC
+ _LT_CC_BASENAME([$compiler])
+
++# save warnings/boilerplate of simple test code
++_LT_COMPILER_BOILERPLATE
++_LT_LINKER_BOILERPLATE
++
+ # GDC did not exist at the time GCC didn't implicitly link libc in.
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+
+base-commit: 3dfd545671f0b3ffb2bd5166637381665fea7ebb
+--
+2.52.0
+
diff --git a/16.2.0/gentoo/README.history b/16.2.0/gentoo/README.history
new file mode 100644
index 0000000..c7bd85f
--- /dev/null
+++ b/16.2.0/gentoo/README.history
@@ -0,0 +1,31 @@
+ 1 ????
+
+ + 01_all_default-fortify-source.patch
+ + 02_all_default-warn-format-security.patch
+ + 03_all_default-warn-trampolines.patch
+ + 04_all_nossp-on-nostdlib.patch
+ + 05_all_alpha-mieee-default.patch
+ + 06_all_ia64_note.GNU-stack.patch
+ + 08_all_libiberty-pic.patch
+ + 09_all_esysroot.patch
+ + 10_all_sh-drop-sysroot-suffix.patch
+ + 11_all_ia64-TEXTREL.patch
+ + 14_all_respect-build-cxxflags.patch
+ + 15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch
+ + 20_all_libstdcxx-no-vtv.patch
+ + 22_all_default_ssp-buffer-size.patch
+ + 23_all_DEF_GENTOO_ZNOW-z-now.patch
+ + 24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch
+ + 26_all_enable-cet.patch
+ + 28_all_drop_CFLAGS_sed.patch
+ + 29_all_msgfmt-libstdc++-link.patch
+ + 30_all_tar_libstdc++-link.patch
+ + 32_all_time64.patch
+ + 33_all_PR80677-cross-limits.patch
+ + 34_all_time64_ssemath.patch
+ + 35_all_checking-gc-use-heuristics.patch
+ + 36_all_no-afdo-testing.patch
+ + 37_all_PR66487-object-lifetime-instrumentation-for-Valgrind.patch
+ + 38_all_hurd_linker_path.patch
+ + 76_all_PR117854-config-nvptx-fix-bashisms-with-gen-copyright.sh-use.patch
+ + 86_all_PR122794-libtool.patch