aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--10.3.0/gentoo/36_all_msgfmt-libstdc++-link.patch39
-rw-r--r--10.3.0/gentoo/37_all_glibc_236.patch68
-rw-r--r--10.3.0/gentoo/README.history4
-rw-r--r--10.3.0/musl/25_all_multilib_pure64.patch86
-rw-r--r--10.3.0/musl/50_all_cpu_indicator.patch46
-rw-r--r--10.3.0/musl/50_all_posix_memalign.patch29
-rw-r--r--10.3.0/musl/nocross/50_all_libssp_unconditionally.patch24
-rw-r--r--10.4.0/gentoo/22_all_libstdcxx-no-vtv.patch42
-rw-r--r--10.4.0/gentoo/33_all_msgfmt-libstdc++-link.patch39
-rw-r--r--10.4.0/gentoo/34_all_drop_CFLAGS_sed.patch35
-rw-r--r--10.4.0/gentoo/75_all_glibc_236.patch68
-rw-r--r--10.4.0/gentoo/76_all_d_compiler_for_build_pie.patch63
-rw-r--r--10.4.0/gentoo/README.history15
-rw-r--r--10.4.0/musl/25_all_multilib_pure64.patch86
-rw-r--r--10.4.0/musl/50_all_cpu_indicator.patch46
-rw-r--r--10.4.0/musl/50_all_posix_memalign.patch29
-rw-r--r--10.4.0/musl/nocross/50_all_libssp_unconditionally.patch24
-rw-r--r--10.5.0/gentoo/01_all_default-fortify-source.patch (renamed from 12.0.0/gentoo/01_all_default-fortify-source.patch)0
-rw-r--r--10.5.0/gentoo/02_all_default-warn-format-security.patch22
-rw-r--r--10.5.0/gentoo/03_all_default-warn-trampolines.patch (renamed from 12.0.0/gentoo/03_all_default-warn-trampolines.patch)0
-rw-r--r--10.5.0/gentoo/04_all_nossp-on-nostdlib.patch27
-rw-r--r--10.5.0/gentoo/05_all_alpha-mieee-default.patch39
-rw-r--r--10.5.0/gentoo/06_all_ia64_note.GNU-stack.patch (renamed from 12.0.0/gentoo/06_all_ia64_note.GNU-stack.patch)0
-rw-r--r--10.5.0/gentoo/07_all_i386_libgcc_note.GNU-stack.patch54
-rw-r--r--10.5.0/gentoo/08_all_libiberty-asprintf.patch18
-rw-r--r--10.5.0/gentoo/09_all_libiberty-pic.patch (renamed from 12.0.0/gentoo/08_all_libiberty-pic.patch)0
-rw-r--r--10.5.0/gentoo/10_all_nopie-all-flags.patch18
-rw-r--r--10.5.0/gentoo/11_all_sh-drop-sysroot-suffix.patch26
-rw-r--r--10.5.0/gentoo/12_all_ia64-TEXTREL.patch22
-rw-r--r--10.5.0/gentoo/13_all_disable-systemtap-switch.patch115
-rw-r--r--10.5.0/gentoo/14_all_m68k-textrel-on-libgcc.patch87
-rw-r--r--10.5.0/gentoo/15_all_respect-build-cxxflags.patch (renamed from 12.0.0/gentoo/14_all_respect-build-cxxflags.patch)0
-rw-r--r--10.5.0/gentoo/16_all_libgfortran-Werror.patch28
-rw-r--r--10.5.0/gentoo/17_all_libgomp-Werror.patch26
-rw-r--r--10.5.0/gentoo/18_all_libitm-Werror.patch25
-rw-r--r--10.5.0/gentoo/19_all_libatomic-Werror.patch25
-rw-r--r--10.5.0/gentoo/20_all_libbacktrace-Werror.patch (renamed from 12.0.0/gentoo/18_all_libbacktrace-Werror.patch)0
-rw-r--r--10.5.0/gentoo/21_all_libsanitizer-Werror.patch (renamed from 12.0.0/gentoo/19_all_libsanitizer-Werror.patch)0
-rw-r--r--10.5.0/gentoo/22_all_libstdcxx-no-vtv.patch79
-rw-r--r--10.5.0/gentoo/23_all_disable-riscv32-ABIs.patch52
-rw-r--r--10.5.0/gentoo/24_all_default_ssp-buffer-size.patch (renamed from 12.0.0/gentoo/22_all_default_ssp-buffer-size.patch)0
-rw-r--r--10.5.0/gentoo/25_all_hppa-faster-synth_mult.patch40
-rw-r--r--10.5.0/gentoo/26_all_libcpp-ar.patch143
-rw-r--r--10.5.0/gentoo/27_all_EXTRA_OPTIONS-z-now.patch26
-rw-r--r--10.5.0/gentoo/28_all_EXTRA_OPTIONS-fstack-clash-protection.patch65
-rw-r--r--10.5.0/gentoo/29_all_lto-intl-workaround-PR95194.patch (renamed from 12.0.0/gentoo/25_all_lto-intl-workaround-PR95194.patch)0
-rw-r--r--10.5.0/gentoo/30_all_plugin-objdump.patch (renamed from 12.0.0/gentoo/26_all_plugin-objdump.patch)0
-rw-r--r--10.5.0/gentoo/31_all_fno-delayed-branch.patch36
-rw-r--r--10.5.0/gentoo/32_all_vtv-slibtool.patch58
-rw-r--r--10.5.0/gentoo/33_all_msgfmt-libstdc++-link.patch39
-rw-r--r--10.5.0/gentoo/34_all_drop_CFLAGS_sed.patch35
-rw-r--r--10.5.0/gentoo/35_all_tar_libstdc++-link.patch57
-rw-r--r--10.5.0/gentoo/75_all_d_compiler_for_build_pie.patch63
-rw-r--r--10.5.0/gentoo/76_all_configure-c89.patch141
-rw-r--r--10.5.0/gentoo/77_all_all_PR109585_13_rtl-alias-analysis-typo.patch79
-rw-r--r--10.5.0/gentoo/README.history54
-rw-r--r--10.5.0/musl/25_all_multilib_pure64.patch80
-rw-r--r--10.5.0/musl/50_all_cpu_indicator.patch37
-rw-r--r--10.5.0/musl/50_all_libssp_unconditionally.patch24
-rw-r--r--10.5.0/musl/50_all_posix_memalign.patch28
-rw-r--r--11.2.0/musl/25_all_multilib_pure64.patch89
-rw-r--r--11.2.0/musl/50_all_cpu_indicator.patch46
-rw-r--r--11.2.0/musl/50_all_posix_memalign.patch29
-rw-r--r--11.2.0/musl/nocross/50_all_libssp_unconditionally.patch24
-rw-r--r--11.3.0/gentoo/26_all_enable-cet.patch68
-rw-r--r--11.3.0/gentoo/27_all_msgfmt-libstdc++-link.patch39
-rw-r--r--11.3.0/gentoo/28_all_drop_CFLAGS_sed.patch35
-rw-r--r--11.3.0/gentoo/75_all_x86_PR99703_12_no-cet-for-i486.patch389
-rw-r--r--11.3.0/gentoo/76_all_all_PR103910_12_ICE-on-PCH.patch35
-rw-r--r--11.3.0/gentoo/77_all_glibc_236.patch69
-rw-r--r--11.3.0/gentoo/README.history21
-rw-r--r--11.3.0/musl/25_all_multilib_pure64.patch89
-rw-r--r--11.3.0/musl/50_all_cpu_indicator.patch46
-rw-r--r--11.3.0/musl/50_all_posix_memalign.patch29
-rw-r--r--11.3.0/musl/nocross/50_all_libssp_unconditionally.patch24
-rw-r--r--11.4.0/gentoo/01_all_default-fortify-source.patch22
-rw-r--r--11.4.0/gentoo/02_all_default-warn-format-security.patch22
-rw-r--r--11.4.0/gentoo/03_all_default-warn-trampolines.patch13
-rw-r--r--11.4.0/gentoo/04_all_nossp-on-nostdlib.patch27
-rw-r--r--11.4.0/gentoo/05_all_alpha-mieee-default.patch (renamed from 12.0.0/gentoo/05_all_alpha-mieee-default.patch)0
-rw-r--r--11.4.0/gentoo/06_all_ia64_note.GNU-stack.patch92
-rw-r--r--11.4.0/gentoo/07_all_libiberty-asprintf.patch18
-rw-r--r--11.4.0/gentoo/08_all_libiberty-pic.patch10
-rw-r--r--11.4.0/gentoo/09_all_nopie-all-flags.patch18
-rw-r--r--11.4.0/gentoo/10_all_sh-drop-sysroot-suffix.patch26
-rw-r--r--11.4.0/gentoo/11_all_ia64-TEXTREL.patch22
-rw-r--r--11.4.0/gentoo/12_all_disable-systemtap-switch.patch115
-rw-r--r--11.4.0/gentoo/13_all_m68k-textrel-on-libgcc.patch87
-rw-r--r--11.4.0/gentoo/14_all_respect-build-cxxflags.patch39
-rw-r--r--11.4.0/gentoo/15_all_libgomp-Werror.patch26
-rw-r--r--11.4.0/gentoo/16_all_libitm-Werror.patch25
-rw-r--r--11.4.0/gentoo/17_all_libatomic-Werror.patch25
-rw-r--r--11.4.0/gentoo/18_all_libbacktrace-Werror.patch17
-rw-r--r--11.4.0/gentoo/19_all_libsanitizer-Werror.patch17
-rw-r--r--11.4.0/gentoo/20_all_libstdcxx-no-vtv.patch97
-rw-r--r--11.4.0/gentoo/21_all_default_ssp-buffer-size.patch14
-rw-r--r--11.4.0/gentoo/22_all_EXTRA_OPTIONS-z-now.patch26
-rw-r--r--11.4.0/gentoo/23_all_EXTRA_OPTIONS-fstack-clash-protection.patch (renamed from 12.0.0/gentoo/24_all_EXTRA_OPTIONS-fstack-clash-protection.patch)16
-rw-r--r--11.4.0/gentoo/24_all_lto-intl-workaround-PR95194.patch20
-rw-r--r--11.4.0/gentoo/25_all_plugin-objdump.patch34
-rw-r--r--11.4.0/gentoo/27_all_msgfmt-libstdc++-link.patch39
-rw-r--r--11.4.0/gentoo/28_all_drop_CFLAGS_sed.patch35
-rw-r--r--11.4.0/gentoo/29_all_tar_libstdc++-link.patch57
-rw-r--r--11.4.0/gentoo/75_all_x86_PR99703_12_no-cet-for-i486.patch373
-rw-r--r--11.4.0/gentoo/76_all_all_PR103910_12_ICE-on-PCH.patch35
-rw-r--r--11.4.0/gentoo/README.history65
-rw-r--r--11.4.0/musl/25_all_multilib_pure64.patch83
-rw-r--r--11.4.0/musl/50_all_calloc_libgccjit.patch122
-rw-r--r--11.4.0/musl/50_all_cpu_indicator.patch37
-rw-r--r--11.4.0/musl/50_all_libssp_unconditionally.patch24
-rw-r--r--11.4.0/musl/50_all_posix_memalign.patch28
-rw-r--r--12.1.0/gentoo/01_all_default-fortify-source.patch22
-rw-r--r--12.1.0/gentoo/02_all_default-warn-format-security.patch22
-rw-r--r--12.1.0/gentoo/03_all_default-warn-trampolines.patch13
-rw-r--r--12.1.0/gentoo/04_all_nossp-on-nostdlib.patch27
-rw-r--r--12.1.0/gentoo/05_all_alpha-mieee-default.patch39
-rw-r--r--12.1.0/gentoo/06_all_ia64_note.GNU-stack.patch92
-rw-r--r--12.1.0/gentoo/07_all_libiberty-asprintf.patch18
-rw-r--r--12.1.0/gentoo/08_all_libiberty-pic.patch10
-rw-r--r--12.1.0/gentoo/09_all_nopie-all-flags.patch18
-rw-r--r--12.1.0/gentoo/10_all_sh-drop-sysroot-suffix.patch32
-rw-r--r--12.1.0/gentoo/11_all_ia64-TEXTREL.patch22
-rw-r--r--12.1.0/gentoo/12_all_disable-systemtap-switch.patch122
-rw-r--r--12.1.0/gentoo/14_all_respect-build-cxxflags.patch39
-rw-r--r--12.1.0/gentoo/20_all_libstdcxx-no-vtv.patch61
-rw-r--r--12.1.0/gentoo/22_all_default_ssp-buffer-size.patch14
-rw-r--r--12.1.0/gentoo/23_all_EXTRA_OPTIONS-z-now.patch (renamed from 12.0.0/gentoo/23_all_EXTRA_OPTIONS-z-now.patch)14
-rw-r--r--12.1.0/gentoo/24_all_EXTRA_OPTIONS-fstack-clash-protection.patch65
-rw-r--r--12.1.0/gentoo/25_all_lto-intl-workaround-PR95194.patch20
-rw-r--r--12.1.0/gentoo/26_all_enable-cet.patch206
-rw-r--r--12.1.0/gentoo/27_all_plugin-objdump.patch34
-rw-r--r--12.1.0/gentoo/28_all_drop_CFLAGS_sed.patch35
-rw-r--r--12.1.0/gentoo/29_all_msgfmt-libstdc++-link.patch39
-rw-r--r--12.1.0/gentoo/README.history98
-rw-r--r--12.1.0/musl/25_all_multilib_pure64.patch89
-rw-r--r--12.1.0/musl/50_all_cpu_indicator.patch35
-rw-r--r--12.1.0/musl/50_all_posix_memalign.patch29
-rw-r--r--12.1.0/musl/README.history27
-rw-r--r--12.1.0/musl/nocross/50_all_libssp_unconditionally.patch24
-rw-r--r--12.2.0/gentoo/01_all_default-fortify-source.patch26
-rw-r--r--12.2.0/gentoo/02_all_default-warn-format-security.patch22
-rw-r--r--12.2.0/gentoo/03_all_default-warn-trampolines.patch13
-rw-r--r--12.2.0/gentoo/04_all_nossp-on-nostdlib.patch27
-rw-r--r--12.2.0/gentoo/05_all_alpha-mieee-default.patch39
-rw-r--r--12.2.0/gentoo/06_all_ia64_note.GNU-stack.patch92
-rw-r--r--12.2.0/gentoo/07_all_libiberty-asprintf.patch18
-rw-r--r--12.2.0/gentoo/08_all_libiberty-pic.patch10
-rw-r--r--12.2.0/gentoo/09_all_nopie-all-flags.patch18
-rw-r--r--12.2.0/gentoo/10_all_sh-drop-sysroot-suffix.patch26
-rw-r--r--12.2.0/gentoo/11_all_ia64-TEXTREL.patch22
-rw-r--r--12.2.0/gentoo/12_all_disable-systemtap-switch.patch115
-rw-r--r--12.2.0/gentoo/14_all_respect-build-cxxflags.patch39
-rw-r--r--12.2.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch14
-rw-r--r--12.2.0/gentoo/20_all_libstdcxx-no-vtv.patch61
-rw-r--r--12.2.0/gentoo/22_all_default_ssp-buffer-size.patch14
-rw-r--r--12.2.0/gentoo/23_all_DEF_GENTOO_ZNOW-z-now.patch26
-rw-r--r--12.2.0/gentoo/24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch65
-rw-r--r--12.2.0/gentoo/25_all_lto-intl-workaround-PR95194.patch20
-rw-r--r--12.2.0/gentoo/26_all_enable-cet.patch206
-rw-r--r--12.2.0/gentoo/27_all_plugin-objdump.patch34
-rw-r--r--12.2.0/gentoo/28_all_drop_CFLAGS_sed.patch35
-rw-r--r--12.2.0/gentoo/29_all_msgfmt-libstdc++-link.patch39
-rw-r--r--12.2.0/gentoo/30_all_tar_libstdc++-link.patch57
-rw-r--r--12.2.0/gentoo/75_all_go_posix_shell_arithmetic_nonbash.patch40
-rw-r--r--12.2.0/gentoo/76_all_all_PR109573_12_ICE-in-vectorizable_live_operation.patch131
-rw-r--r--12.2.0/gentoo/README.history77
-rw-r--r--12.2.0/musl/25_all_multilib_pure64.patch83
-rw-r--r--12.2.0/musl/50_all_cpu_indicator.patch35
-rw-r--r--12.2.0/musl/50_all_libssp_unconditionally.patch24
-rw-r--r--12.2.0/musl/50_all_posix_memalign.patch28
-rw-r--r--12.2.0/musl/README.history30
-rw-r--r--12.3.0/gentoo/01_all_default-fortify-source.patch26
-rw-r--r--12.3.0/gentoo/02_all_default-warn-format-security.patch22
-rw-r--r--12.3.0/gentoo/03_all_default-warn-trampolines.patch13
-rw-r--r--12.3.0/gentoo/04_all_nossp-on-nostdlib.patch27
-rw-r--r--12.3.0/gentoo/05_all_alpha-mieee-default.patch39
-rw-r--r--12.3.0/gentoo/06_all_ia64_note.GNU-stack.patch92
-rw-r--r--12.3.0/gentoo/07_all_libiberty-asprintf.patch18
-rw-r--r--12.3.0/gentoo/08_all_libiberty-pic.patch10
-rw-r--r--12.3.0/gentoo/09_all_nopie-all-flags.patch18
-rw-r--r--12.3.0/gentoo/10_all_sh-drop-sysroot-suffix.patch26
-rw-r--r--12.3.0/gentoo/11_all_ia64-TEXTREL.patch22
-rw-r--r--12.3.0/gentoo/12_all_disable-systemtap-switch.patch115
-rw-r--r--12.3.0/gentoo/14_all_respect-build-cxxflags.patch39
-rw-r--r--12.3.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch14
-rw-r--r--12.3.0/gentoo/20_all_libstdcxx-no-vtv.patch61
-rw-r--r--12.3.0/gentoo/22_all_default_ssp-buffer-size.patch14
-rw-r--r--12.3.0/gentoo/23_all_DEF_GENTOO_ZNOW-z-now.patch26
-rw-r--r--12.3.0/gentoo/24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch65
-rw-r--r--12.3.0/gentoo/25_all_lto-intl-workaround-PR95194.patch20
-rw-r--r--12.3.0/gentoo/26_all_enable-cet.patch206
-rw-r--r--12.3.0/gentoo/27_all_plugin-objdump.patch34
-rw-r--r--12.3.0/gentoo/28_all_drop_CFLAGS_sed.patch35
-rw-r--r--12.3.0/gentoo/29_all_msgfmt-libstdc++-link.patch39
-rw-r--r--12.3.0/gentoo/30_all_tar_libstdc++-link.patch57
-rw-r--r--12.3.0/gentoo/75_all_go_posix_shell_arithmetic_nonbash.patch40
-rw-r--r--12.3.0/gentoo/76_all_all_PR107087_12_Wstringop-overread-libstdc++-cow-empty.patch63
-rw-r--r--12.3.0/gentoo/77_all_riscv_PR106271-multilib-bootstrap.patch36
-rw-r--r--12.3.0/gentoo/README.history (renamed from 12.0.0/gentoo/README.history)31
-rw-r--r--12.3.0/musl/25_all_multilib_pure64.patch83
-rw-r--r--12.3.0/musl/50_all_cpu_indicator.patch35
-rw-r--r--12.3.0/musl/50_all_libssp_unconditionally.patch24
-rw-r--r--12.3.0/musl/50_all_posix_memalign.patch28
-rw-r--r--12.3.0/musl/README.history6
-rw-r--r--13.1.0/gentoo/01_all_default-fortify-source.patch26
-rw-r--r--13.1.0/gentoo/02_all_default-warn-format-security.patch22
-rw-r--r--13.1.0/gentoo/03_all_default-warn-trampolines.patch13
-rw-r--r--13.1.0/gentoo/04_all_nossp-on-nostdlib.patch27
-rw-r--r--13.1.0/gentoo/05_all_alpha-mieee-default.patch39
-rw-r--r--13.1.0/gentoo/06_all_ia64_note.GNU-stack.patch92
-rw-r--r--13.1.0/gentoo/07_all_libiberty-asprintf.patch18
-rw-r--r--13.1.0/gentoo/08_all_libiberty-pic.patch10
-rw-r--r--13.1.0/gentoo/09_all_nopie-all-flags.patch18
-rw-r--r--13.1.0/gentoo/10_all_sh-drop-sysroot-suffix.patch26
-rw-r--r--13.1.0/gentoo/11_all_ia64-TEXTREL.patch22
-rw-r--r--13.1.0/gentoo/14_all_respect-build-cxxflags.patch39
-rw-r--r--13.1.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch14
-rw-r--r--13.1.0/gentoo/20_all_libstdcxx-no-vtv.patch61
-rw-r--r--13.1.0/gentoo/22_all_default_ssp-buffer-size.patch14
-rw-r--r--13.1.0/gentoo/23_all_DEF_GENTOO_ZNOW-z-now.patch26
-rw-r--r--13.1.0/gentoo/24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch65
-rw-r--r--13.1.0/gentoo/25_all_lto-intl-workaround-PR95194.patch20
-rw-r--r--13.1.0/gentoo/26_all_enable-cet.patch193
-rw-r--r--13.1.0/gentoo/28_all_drop_CFLAGS_sed.patch35
-rw-r--r--13.1.0/gentoo/29_all_msgfmt-libstdc++-link.patch39
-rw-r--r--13.1.0/gentoo/30_all_tar_libstdc++-link.patch57
-rw-r--r--13.1.0/gentoo/31_all_gm2_make_P_var.patch49
-rw-r--r--13.1.0/gentoo/README.history56
-rw-r--r--13.1.0/musl/25_all_multilib_pure64.patch83
-rw-r--r--13.1.0/musl/50_all_cpu_indicator.patch37
-rw-r--r--13.1.0/musl/50_all_libssp_unconditionally.patch24
-rw-r--r--13.1.0/musl/50_all_posix_memalign.patch28
-rw-r--r--13.1.0/musl/README.history6
-rw-r--r--13.2.0/gentoo/01_all_default-fortify-source.patch26
-rw-r--r--13.2.0/gentoo/02_all_default-warn-format-security.patch22
-rw-r--r--13.2.0/gentoo/03_all_default-warn-trampolines.patch13
-rw-r--r--13.2.0/gentoo/04_all_nossp-on-nostdlib.patch27
-rw-r--r--13.2.0/gentoo/05_all_alpha-mieee-default.patch39
-rw-r--r--13.2.0/gentoo/06_all_ia64_note.GNU-stack.patch92
-rw-r--r--13.2.0/gentoo/07_all_libiberty-asprintf.patch18
-rw-r--r--13.2.0/gentoo/08_all_libiberty-pic.patch10
-rw-r--r--13.2.0/gentoo/09_all_nopie-all-flags.patch18
-rw-r--r--13.2.0/gentoo/10_all_sh-drop-sysroot-suffix.patch26
-rw-r--r--13.2.0/gentoo/11_all_ia64-TEXTREL.patch22
-rw-r--r--13.2.0/gentoo/14_all_respect-build-cxxflags.patch39
-rw-r--r--13.2.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch14
-rw-r--r--13.2.0/gentoo/20_all_libstdcxx-no-vtv.patch61
-rw-r--r--13.2.0/gentoo/22_all_default_ssp-buffer-size.patch14
-rw-r--r--13.2.0/gentoo/23_all_DEF_GENTOO_ZNOW-z-now.patch26
-rw-r--r--13.2.0/gentoo/24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch65
-rw-r--r--13.2.0/gentoo/25_all_lto-intl-workaround-PR95194.patch20
-rw-r--r--13.2.0/gentoo/26_all_enable-cet.patch193
-rw-r--r--13.2.0/gentoo/28_all_drop_CFLAGS_sed.patch35
-rw-r--r--13.2.0/gentoo/29_all_msgfmt-libstdc++-link.patch39
-rw-r--r--13.2.0/gentoo/30_all_tar_libstdc++-link.patch57
-rw-r--r--13.2.0/gentoo/31_all_gm2_make_P_var.patch49
-rw-r--r--13.2.0/gentoo/76_all_match.pd-don-t-emit-label-if-not-needed.patch114
-rw-r--r--13.2.0/gentoo/77_all_match.pd-Remove-commented-out-line-pragmas-unless-vv.patch41
-rw-r--r--13.2.0/gentoo/78_all_match.pd-CSE-the-dump-output-check.patch70
-rw-r--r--13.2.0/gentoo/79_all_genmatch-split-shared-code-to-gimple-match-exports.c.patch2560
-rw-r--r--13.2.0/gentoo/80_all_match.pd-automatically-partition-match.cc-files.patch524
-rw-r--r--13.2.0/gentoo/81_all_match.pd-Use-splits-in-makefile-and-make-configurabl.patch276
-rw-r--r--13.2.0/gentoo/82_all_Makefile.in-clean-up-match.pd-related-dependencies.patch60
-rw-r--r--13.2.0/gentoo/84_all_x86_PR110792-Early-clobber-issues-with-rot32di2.patch186
-rw-r--r--13.2.0/gentoo/85_all_x86_PR110792-Early-clobber-issues-with-rot32di2-test-fixup.patch39
-rw-r--r--13.2.0/gentoo/86_all_build-Replace-seq-for-portability-with-GNU-Make-vari.patch73
-rw-r--r--13.2.0/gentoo/87_all_Remove-DEFAULT_MATCHPD_PARTITIONS-macro.patch90
-rw-r--r--13.2.0/gentoo/88_all_Makefile.in-Make-TM_P_H-depend-on-TREE_H-PR111021.patch66
-rw-r--r--13.2.0/gentoo/89_all_Makefile.in-Make-recog.h-depend-on-TREE_H-PR111021.patch45
-rw-r--r--13.2.0/gentoo/90_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch1404
-rw-r--r--13.2.0/gentoo/91_all_riscv_PR106271-multilib-bootstrap.patch37
-rw-r--r--13.2.0/gentoo/92_all_riscv_PR109760-gstreamer.patch337
-rw-r--r--13.2.0/gentoo/README.history119
-rw-r--r--13.2.0/musl/25_all_multilib_pure64.patch83
-rw-r--r--13.2.0/musl/50_all_cpu_indicator.patch37
-rw-r--r--13.2.0/musl/50_all_libssp_unconditionally.patch24
-rw-r--r--13.2.0/musl/50_all_posix_memalign.patch28
-rw-r--r--13.2.0/musl/50_all_sanitizer_lfs.patch197
-rw-r--r--13.2.0/musl/README.history9
-rw-r--r--14.0.0/gentoo/01_all_default-fortify-source.patch26
-rw-r--r--14.0.0/gentoo/02_all_default-warn-format-security.patch21
-rw-r--r--14.0.0/gentoo/03_all_default-warn-trampolines.patch13
-rw-r--r--14.0.0/gentoo/04_all_nossp-on-nostdlib.patch28
-rw-r--r--14.0.0/gentoo/05_all_alpha-mieee-default.patch39
-rw-r--r--14.0.0/gentoo/06_all_ia64_note.GNU-stack.patch92
-rw-r--r--14.0.0/gentoo/07_all_libiberty-asprintf.patch18
-rw-r--r--14.0.0/gentoo/08_all_libiberty-pic.patch10
-rw-r--r--14.0.0/gentoo/10_all_sh-drop-sysroot-suffix.patch26
-rw-r--r--14.0.0/gentoo/11_all_ia64-TEXTREL.patch22
-rw-r--r--14.0.0/gentoo/14_all_respect-build-cxxflags.patch39
-rw-r--r--14.0.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch14
-rw-r--r--14.0.0/gentoo/20_all_libstdcxx-no-vtv.patch61
-rw-r--r--14.0.0/gentoo/22_all_default_ssp-buffer-size.patch14
-rw-r--r--14.0.0/gentoo/23_all_DEF_GENTOO_ZNOW-z-now.patch26
-rw-r--r--14.0.0/gentoo/24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch65
-rw-r--r--14.0.0/gentoo/26_all_enable-cet.patch193
-rw-r--r--14.0.0/gentoo/28_all_drop_CFLAGS_sed.patch35
-rw-r--r--14.0.0/gentoo/29_all_msgfmt-libstdc++-link.patch39
-rw-r--r--14.0.0/gentoo/30_all_tar_libstdc++-link.patch57
-rw-r--r--14.0.0/gentoo/76_all_ppc_PR112868-no-checking-many.patch42
-rw-r--r--14.0.0/gentoo/README.history155
-rw-r--r--14.0.0/musl/25_all_multilib_pure64.patch83
-rw-r--r--14.0.0/musl/50_all_cpu_indicator.patch37
-rw-r--r--14.0.0/musl/50_all_libssp_unconditionally.patch24
-rw-r--r--14.0.0/musl/50_all_posix_memalign.patch28
-rw-r--r--14.0.0/musl/README.history6
-rw-r--r--8.5.0/gentoo/33_all_msgfmt-libstdc++-link.patch39
-rw-r--r--8.5.0/gentoo/README.history3
-rw-r--r--9.3.0/gentoo/75_all_remove_cyclades.patch127
-rw-r--r--9.3.0/gentoo/README.history3
-rw-r--r--9.4.0/gentoo/30_all_glibc_236.patch37
-rw-r--r--9.4.0/gentoo/README.history3
-rw-r--r--9.5.0/gentoo/01_all_default-fortify-source.patch22
-rw-r--r--9.5.0/gentoo/02_all_default-warn-format-security.patch (renamed from 12.0.0/gentoo/02_all_default-warn-format-security.patch)0
-rw-r--r--9.5.0/gentoo/03_all_default-warn-trampolines.patch13
-rw-r--r--9.5.0/gentoo/04_all_nossp-on-nostdlib.patch (renamed from 12.0.0/gentoo/04_all_nossp-on-nostdlib.patch)4
-rw-r--r--9.5.0/gentoo/05_all_alpha-mieee-default.patch39
-rw-r--r--9.5.0/gentoo/06_all_ia64_note.GNU-stack.patch92
-rw-r--r--9.5.0/gentoo/07_all_i386_libgcc_note.GNU-stack.patch54
-rw-r--r--9.5.0/gentoo/08_all_libiberty-asprintf.patch (renamed from 12.0.0/gentoo/07_all_libiberty-asprintf.patch)0
-rw-r--r--9.5.0/gentoo/09_all_libiberty-pic.patch10
-rw-r--r--9.5.0/gentoo/10_all_nopie-all-flags.patch (renamed from 12.0.0/gentoo/09_all_nopie-all-flags.patch)0
-rw-r--r--9.5.0/gentoo/11_all_extra-options.patch89
-rw-r--r--9.5.0/gentoo/12_all_pr55930-dependency-tracking.patch18
-rw-r--r--9.5.0/gentoo/13_all_sh-drop-sysroot-suffix.patch (renamed from 12.0.0/gentoo/10_all_sh-drop-sysroot-suffix.patch)0
-rw-r--r--9.5.0/gentoo/14_all_ia64-TEXTREL.patch (renamed from 12.0.0/gentoo/11_all_ia64-TEXTREL.patch)0
-rw-r--r--9.5.0/gentoo/15_all_disable-systemtap-switch.patch (renamed from 12.0.0/gentoo/12_all_disable-systemtap-switch.patch)0
-rw-r--r--9.5.0/gentoo/16_all_m68k-textrel-on-libgcc.patch (renamed from 12.0.0/gentoo/13_all_m68k-textrel-on-libgcc.patch)0
-rw-r--r--9.5.0/gentoo/17_all_respect-build-cxxflags.patch39
-rw-r--r--9.5.0/gentoo/18_all_libgfortran-Werror.patch20
-rw-r--r--9.5.0/gentoo/19_all_libgomp-Werror.patch (renamed from 12.0.0/gentoo/15_all_libgomp-Werror.patch)0
-rw-r--r--9.5.0/gentoo/20_all_libitm-Werror.patch (renamed from 12.0.0/gentoo/16_all_libitm-Werror.patch)0
-rw-r--r--9.5.0/gentoo/21_all_libatomic-Werror.patch (renamed from 12.0.0/gentoo/17_all_libatomic-Werror.patch)0
-rw-r--r--9.5.0/gentoo/22_all_libbacktrace-Werror.patch17
-rw-r--r--9.5.0/gentoo/23_all_libsanitizer-Werror.patch17
-rw-r--r--9.5.0/gentoo/24_all_libstdcxx-no-vtv.patch (renamed from 12.0.0/gentoo/20_all_libstdcxx-no-vtv.patch)0
-rw-r--r--9.5.0/gentoo/25_all_disable-riscv32-ABIs.patch53
-rw-r--r--9.5.0/gentoo/26_all_default_ssp-buffer-size.patch14
-rw-r--r--9.5.0/gentoo/27_all_hppa-faster-synth_mult.patch44
-rw-r--r--9.5.0/gentoo/28_all_libcpp-ar.patch143
-rw-r--r--9.5.0/gentoo/29_all_plugin-objdump.patch34
-rw-r--r--9.5.0/gentoo/30_all_glibc_236.patch39
-rw-r--r--9.5.0/gentoo/31_all_msgfmt-libstdc++-link.patch39
-rw-r--r--9.5.0/gentoo/README.history34
-rw-r--r--README5
-rw-r--r--README.Gentoo.patches12
-rwxr-xr-xmake-tarball.sh126
-rw-r--r--scripts/README1
-rwxr-xr-xscripts/testsuite-management/validate_failures.py733
-rw-r--r--scripts/testsuite-management/x86_64-unknown-linux-gnu.xfail109
350 files changed, 20917 insertions, 136 deletions
diff --git a/10.3.0/gentoo/36_all_msgfmt-libstdc++-link.patch b/10.3.0/gentoo/36_all_msgfmt-libstdc++-link.patch
new file mode 100644
index 0000000..0d2f113
--- /dev/null
+++ b/10.3.0/gentoo/36_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/10.3.0/gentoo/37_all_glibc_236.patch b/10.3.0/gentoo/37_all_glibc_236.patch
new file mode 100644
index 0000000..7a0f7d3
--- /dev/null
+++ b/10.3.0/gentoo/37_all_glibc_236.patch
@@ -0,0 +1,68 @@
+https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=6bd956e31b2fb6fe1eee4eb1bf309247dcd19b23
+https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=8c3238510ce63c75024c0288eade5c933f6d322e
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106266
+https://bugs.gentoo.org/864717
+https://bugs.gentoo.org/865879
+
+From 6bd956e31b2fb6fe1eee4eb1bf309247dcd19b23 Mon Sep 17 00:00:00 2001
+From: Martin Liska <mliska@suse.cz>
+Date: Mon, 11 Jul 2022 22:03:14 +0200
+Subject: [PATCH] libsanitizer: cherry-pick 9cf13067cb5088626ba7 from upstream
+
+9cf13067cb5088626ba7ee1ec4c42ec59c7995a0 [sanitizer] Remove #include <linux/fs.h> to resolve fsconfig_command/mount_attr conflict with glibc 2.36
+
+(cherry picked from commit 2701442d0cf6292f6624443c15813d6d1a3562fe)
+--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
+@@ -72,7 +72,9 @@
+ #include <sys/vt.h>
+ #include <linux/cdrom.h>
+ #include <linux/fd.h>
++#if SANITIZER_ANDROID
+ #include <linux/fs.h>
++#endif
+ #include <linux/hdreg.h>
+ #include <linux/input.h>
+ #include <linux/ioctl.h>
+@@ -822,10 +824,10 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+ unsigned IOCTL_EVIOCGPROP = IOCTL_NOT_PRESENT;
+ unsigned IOCTL_EVIOCSKEYCODE_V2 = IOCTL_NOT_PRESENT;
+ #endif
+- unsigned IOCTL_FS_IOC_GETFLAGS = FS_IOC_GETFLAGS;
+- unsigned IOCTL_FS_IOC_GETVERSION = FS_IOC_GETVERSION;
+- unsigned IOCTL_FS_IOC_SETFLAGS = FS_IOC_SETFLAGS;
+- unsigned IOCTL_FS_IOC_SETVERSION = FS_IOC_SETVERSION;
++ unsigned IOCTL_FS_IOC_GETFLAGS = _IOR('f', 1, long);
++ unsigned IOCTL_FS_IOC_GETVERSION = _IOR('v', 1, long);
++ unsigned IOCTL_FS_IOC_SETFLAGS = _IOW('f', 2, long);
++ unsigned IOCTL_FS_IOC_SETVERSION = _IOW('v', 2, long);
+ unsigned IOCTL_GIO_CMAP = GIO_CMAP;
+ unsigned IOCTL_GIO_FONT = GIO_FONT;
+ unsigned IOCTL_GIO_UNIMAP = GIO_UNIMAP;
+
+From 8c3238510ce63c75024c0288eade5c933f6d322e Mon Sep 17 00:00:00 2001
+From: Ian Lance Taylor <iant@golang.org>
+Date: Tue, 12 Jul 2022 19:42:43 -0700
+Subject: [PATCH] libgo: don't include <linux/fs.h> when building
+ gen-sysinfo.go
+
+Removing this doesn't change anything at least with glibc 2.33.
+The include was added in https://go.dev/cl/6100049 but it's not
+clear why.
+
+Fixes PR go/106266
+
+Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/417294
+(cherry picked from commit f35d65517a59565758107c5b1a51a5fa382f8d1a)
+--- a/libgo/sysinfo.c
++++ b/libgo/sysinfo.c
+@@ -150,9 +150,6 @@
+ #if defined(HAVE_LINUX_ETHER_H)
+ #include <linux/ether.h>
+ #endif
+-#if defined(HAVE_LINUX_FS_H)
+-#include <linux/fs.h>
+-#endif
+ #if defined(HAVE_LINUX_REBOOT_H)
+ #include <linux/reboot.h>
+ #endif
diff --git a/10.3.0/gentoo/README.history b/10.3.0/gentoo/README.history
index 4487403..6420b44 100644
--- a/10.3.0/gentoo/README.history
+++ b/10.3.0/gentoo/README.history
@@ -1,3 +1,7 @@
+4 17 Sep 2022
+ + 36_all_msgfmt-libstdc++-link.patch
+ + 37_all_glibc_236.patch
+
3 05 July 2021
+ 35_all_remove-cyclades.patch
diff --git a/10.3.0/musl/25_all_multilib_pure64.patch b/10.3.0/musl/25_all_multilib_pure64.patch
new file mode 100644
index 0000000..19fd5c9
--- /dev/null
+++ b/10.3.0/musl/25_all_multilib_pure64.patch
@@ -0,0 +1,86 @@
+diff -Naur gcc-9.3.0.orig/gcc/config/aarch64/t-aarch64-linux gcc-9.3.0/gcc/config/aarch64/t-aarch64-linux
+--- gcc-9.3.0.orig/gcc/config/aarch64/t-aarch64-linux 2020-10-05 02:59:12.767988285 -0700
++++ gcc-9.3.0/gcc/config/aarch64/t-aarch64-linux 2020-10-05 03:03:32.310816444 -0700
+@@ -22,7 +22,7 @@
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+diff -Naur gcc-9.3.0.orig/gcc/config/i386/t-linux64 gcc-9.3.0/gcc/config/i386/t-linux64
+--- gcc-9.3.0.orig/gcc/config/i386/t-linux64 2020-10-05 02:59:12.757989347 -0700
++++ gcc-9.3.0/gcc/config/i386/t-linux64 2020-10-05 03:24:58.878825272 -0700
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
+-MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
++MULTILIB_OSDIRNAMES+= mx32=../libx32
+diff -Naur gcc-9.3.0.orig/gcc/config/rs6000/t-linux gcc-9.3.0/gcc/config/rs6000/t-linux
+--- gcc-9.3.0.orig/gcc/config/rs6000/t-linux 2020-10-05 02:59:12.767988285 -0700
++++ gcc-9.3.0/gcc/config/rs6000/t-linux 2020-10-05 03:03:32.310816444 -0700
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+
+diff -Naur gcc-9.3.0.orig/gcc/config/rs6000/t-linux64 gcc-9.3.0/gcc/config/rs6000/t-linux64
+--- gcc-9.3.0.orig/gcc/config/rs6000/t-linux64 2020-10-05 02:59:12.767988285 -0700
++++ gcc-9.3.0/gcc/config/rs6000/t-linux64 2020-10-05 03:03:32.310816444 -0700
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS := m64/m32
+ MULTILIB_DIRNAMES := 64 32
+ MULTILIB_EXTRA_OPTS :=
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ $(COMPILE) $<
+diff -Naur gcc-9.3.0.orig/gcc/config/rs6000/t-linux64bele gcc-9.3.0/gcc/config/rs6000/t-linux64bele
+--- gcc-9.3.0.orig/gcc/config/rs6000/t-linux64bele 2020-10-05 02:59:12.767988285 -0700
++++ gcc-9.3.0/gcc/config/rs6000/t-linux64bele 2020-10-05 03:03:32.310816444 -0700
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mlittle
+ MULTILIB_DIRNAMES += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
+diff -Naur gcc-9.3.0.orig/gcc/config/rs6000/t-linux64lebe gcc-9.3.0/gcc/config/rs6000/t-linux64lebe
+--- gcc-9.3.0.orig/gcc/config/rs6000/t-linux64lebe 2020-10-05 02:59:12.777987222 -0700
++++ gcc-9.3.0/gcc/config/rs6000/t-linux64lebe 2020-10-05 03:03:32.310816444 -0700
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mbig
+ MULTILIB_DIRNAMES += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
diff --git a/10.3.0/musl/50_all_cpu_indicator.patch b/10.3.0/musl/50_all_cpu_indicator.patch
new file mode 100644
index 0000000..6141a83
--- /dev/null
+++ b/10.3.0/musl/50_all_cpu_indicator.patch
@@ -0,0 +1,46 @@
+From d16a8ceb1c3c8a7ec381090b4c316ff4c55661c0 Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 7 May 2020 21:14:11 -0500
+Subject: [PATCH] convert "__cpu_indicator_init" to
+ "__cpu_indicator_init_local"
+
+---
+ gcc/config/i386/i386-expand.c | 4 ++--
+ libgcc/config/i386/cpuinfo.c | 6 +++---
+ 2 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c
+index 48f00c5fc..78650b202 100644
+--- a/gcc/config/i386/i386-expand.c
++++ b/gcc/config/i386/i386-expand.c
+@@ -10941,10 +10941,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
+ {
+ case IX86_BUILTIN_CPU_INIT:
+ {
+- /* Make it call __cpu_indicator_init in libgcc. */
++ /* Make it call __cpu_indicator_init_local in libgcc. */
+ tree call_expr, fndecl, type;
+ type = build_function_type_list (integer_type_node, NULL_TREE);
+- fndecl = build_fn_decl ("__cpu_indicator_init", type);
++ fndecl = build_fn_decl ("__cpu_indicator_init_local", type);
+ call_expr = build_call_expr (fndecl, 0);
+ return expand_expr (call_expr, target, mode, EXPAND_NORMAL);
+ }
+diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c
+index 00322c586..f42bbb8af 100644
+--- a/libgcc/config/i386/cpuinfo.c
++++ b/libgcc/config/i386/cpuinfo.c
+@@ -508,7 +508,7 @@ __cpu_indicator_init (void)
+ return 0;
+ }
+
+-#if defined SHARED && defined USE_ELF_SYMVER
+-__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0");
+-__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0");
++#ifndef SHARED
++int __cpu_indicator_init_local (void)
++ __attribute__ ((weak, alias ("__cpu_indicator_init")));
+ #endif
+--
+2.26.2
+
diff --git a/10.3.0/musl/50_all_posix_memalign.patch b/10.3.0/musl/50_all_posix_memalign.patch
new file mode 100644
index 0000000..a288e1d
--- /dev/null
+++ b/10.3.0/musl/50_all_posix_memalign.patch
@@ -0,0 +1,29 @@
+diff -Naur gcc-7.1.0.orig/gcc/config/i386/pmm_malloc.h gcc-7.1.0/gcc/config/i386/pmm_malloc.h
+--- gcc-7.1.0.orig/gcc/config/i386/pmm_malloc.h 2017-01-01 04:07:43.000000000 -0800
++++ gcc-7.1.0/gcc/config/i386/pmm_malloc.h 2017-05-07 11:35:22.878398460 -0700
+@@ -27,12 +27,13 @@
+ #include <stdlib.h>
+
+ /* We can't depend on <stdlib.h> since the prototype of posix_memalign
+- may not be visible. */
++ may not be visible and we can't pollute the namespace either. */
+ #ifndef __cplusplus
+-extern int posix_memalign (void **, size_t, size_t);
++extern int __gcc_posix_memalign (void **, size_t, size_t)
+ #else
+-extern "C" int posix_memalign (void **, size_t, size_t) throw ();
++extern "C" int __gcc_posix_memalign (void **, size_t, size_t) throw ()
+ #endif
++__asm__("posix_memalign");
+
+ static __inline void *
+ _mm_malloc (size_t __size, size_t __alignment)
+@@ -42,7 +43,7 @@
+ return malloc (__size);
+ if (__alignment == 2 || (sizeof (void *) == 8 && __alignment == 4))
+ __alignment = sizeof (void *);
+- if (posix_memalign (&__ptr, __alignment, __size) == 0)
++ if (__gcc_posix_memalign (&__ptr, __alignment, __size) == 0)
+ return __ptr;
+ else
+ return NULL;
diff --git a/10.3.0/musl/nocross/50_all_libssp_unconditionally.patch b/10.3.0/musl/nocross/50_all_libssp_unconditionally.patch
new file mode 100644
index 0000000..7e4c58a
--- /dev/null
+++ b/10.3.0/musl/nocross/50_all_libssp_unconditionally.patch
@@ -0,0 +1,24 @@
+https://bugs.gentoo.org/706210
+https://bugs.gentoo.org/747346
+
+Author: Timo Teräs <timo.teras@iki.fi>
+
+"Alpine musl package provides libssp_nonshared.a. We link to it unconditionally,
+as otherwise we get link failures if some objects are -fstack-protector built
+and final link happens with -fno-stack-protector. This seems to be the common
+case when bootstrapping gcc, the piepatches do not seem to fully fix the
+crosstoolchain and bootstrap sequence wrt. stack-protector flag usage."
+
+(We do the same in Gentoo.)
+--- gcc-6.1.0/gcc/gcc.c.orig
++++ gcc-6.1.0/gcc/gcc.c
+@@ -870,8 +870,7 @@
+
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+- "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ "|fstack-protector-strong|fstack-protector-explicit" \
diff --git a/10.4.0/gentoo/22_all_libstdcxx-no-vtv.patch b/10.4.0/gentoo/22_all_libstdcxx-no-vtv.patch
index 68508bd..4526af1 100644
--- a/10.4.0/gentoo/22_all_libstdcxx-no-vtv.patch
+++ b/10.4.0/gentoo/22_all_libstdcxx-no-vtv.patch
@@ -5,27 +5,27 @@ Bug: https://bugs.gentoo.org/582524
Bug: https://gcc.gnu.org/PR85884
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
-@@ -217,7 +217,6 @@ CXXLINK = \
+@@ -221,7 +221,6 @@ CXXLINK = \
$(LIBTOOL) --tag CXX \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXX) \
- $(VTV_CXXLINKFLAGS) \
- $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
-
- # Symbol versioning for shared libraries.
+ $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) \
+ $(LTLDFLAGS) $(LTLIBICONV) \
+ -o $@
--- a/libstdc++-v3/src/Makefile.in
+++ b/libstdc++-v3/src/Makefile.in
-@@ -511,7 +511,6 @@ CXXLINK = \
+@@ -596,7 +596,6 @@ CXXLINK = \
$(LIBTOOL) --tag CXX \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXX) \
- $(VTV_CXXLINKFLAGS) \
- $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
-
- @ENABLE_SYMVERS_TRUE@CLEANFILES = libstdc++-symbols.ver $(version_dep)
+ $(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
-@@ -204,5 +204,4 @@ CXXLINK = \
+@@ -214,5 +214,4 @@ CXXLINK = \
$(LIBTOOL) --tag CXX --tag disable-shared \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXX) \
@@ -33,7 +33,25 @@ Bug: https://gcc.gnu.org/PR85884
$(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
--- a/libstdc++-v3/src/c++11/Makefile.in
+++ b/libstdc++-v3/src/c++11/Makefile.in
-@@ -496,7 +496,6 @@ CXXLINK = \
+@@ -575,7 +575,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++17/Makefile.am
++++ b/libstdc++-v3/src/c++17/Makefile.am
+@@ -119,5 +119,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++17/Makefile.in
++++ b/libstdc++-v3/src/c++17/Makefile.in
+@@ -502,7 +502,6 @@ CXXLINK = \
$(LIBTOOL) --tag CXX --tag disable-shared \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXX) \
@@ -43,7 +61,7 @@ Bug: https://gcc.gnu.org/PR85884
all: all-am
--- a/libstdc++-v3/src/c++98/Makefile.am
+++ b/libstdc++-v3/src/c++98/Makefile.am
-@@ -273,5 +273,4 @@ CXXLINK = \
+@@ -268,5 +268,4 @@ CXXLINK = \
$(LIBTOOL) --tag CXX --tag disable-shared \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXX) \
@@ -51,7 +69,7 @@ Bug: https://gcc.gnu.org/PR85884
$(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
--- a/libstdc++-v3/src/c++98/Makefile.in
+++ b/libstdc++-v3/src/c++98/Makefile.in
-@@ -500,7 +500,6 @@ CXXLINK = \
+@@ -577,7 +577,6 @@ CXXLINK = \
$(LIBTOOL) --tag CXX --tag disable-shared \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXX) \
diff --git a/10.4.0/gentoo/33_all_msgfmt-libstdc++-link.patch b/10.4.0/gentoo/33_all_msgfmt-libstdc++-link.patch
new file mode 100644
index 0000000..0d2f113
--- /dev/null
+++ b/10.4.0/gentoo/33_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/10.4.0/gentoo/34_all_drop_CFLAGS_sed.patch b/10.4.0/gentoo/34_all_drop_CFLAGS_sed.patch
new file mode 100644
index 0000000..0136628
--- /dev/null
+++ b/10.4.0/gentoo/34_all_drop_CFLAGS_sed.patch
@@ -0,0 +1,35 @@
+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
+@@ -5195,13 +5195,6 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
+ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+-# Remove the -O2: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[ ]//" -e "s/-O[gs][ ]//" -e "s/-O[0-9]*[ ]//" `
+- CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[ ]//" -e "s/-O[gs][ ]//" -e "s/-O[0-9]*[ ]//" ` ;;
+-esac
+
+
+
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -397,13 +397,6 @@ ACX_PROG_GNAT([-I"$srcdir"/ada/libgnat])
+ # Do configure tests with the C++ compiler, since that's what we build with.
+ AC_LANG(C++)
+
+-# Remove the -O2: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" `
+- CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" ` ;;
+-esac
+ AC_SUBST(CFLAGS)
+ AC_SUBST(CXXFLAGS)
+
diff --git a/10.4.0/gentoo/75_all_glibc_236.patch b/10.4.0/gentoo/75_all_glibc_236.patch
new file mode 100644
index 0000000..7a0f7d3
--- /dev/null
+++ b/10.4.0/gentoo/75_all_glibc_236.patch
@@ -0,0 +1,68 @@
+https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=6bd956e31b2fb6fe1eee4eb1bf309247dcd19b23
+https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=8c3238510ce63c75024c0288eade5c933f6d322e
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106266
+https://bugs.gentoo.org/864717
+https://bugs.gentoo.org/865879
+
+From 6bd956e31b2fb6fe1eee4eb1bf309247dcd19b23 Mon Sep 17 00:00:00 2001
+From: Martin Liska <mliska@suse.cz>
+Date: Mon, 11 Jul 2022 22:03:14 +0200
+Subject: [PATCH] libsanitizer: cherry-pick 9cf13067cb5088626ba7 from upstream
+
+9cf13067cb5088626ba7ee1ec4c42ec59c7995a0 [sanitizer] Remove #include <linux/fs.h> to resolve fsconfig_command/mount_attr conflict with glibc 2.36
+
+(cherry picked from commit 2701442d0cf6292f6624443c15813d6d1a3562fe)
+--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
+@@ -72,7 +72,9 @@
+ #include <sys/vt.h>
+ #include <linux/cdrom.h>
+ #include <linux/fd.h>
++#if SANITIZER_ANDROID
+ #include <linux/fs.h>
++#endif
+ #include <linux/hdreg.h>
+ #include <linux/input.h>
+ #include <linux/ioctl.h>
+@@ -822,10 +824,10 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+ unsigned IOCTL_EVIOCGPROP = IOCTL_NOT_PRESENT;
+ unsigned IOCTL_EVIOCSKEYCODE_V2 = IOCTL_NOT_PRESENT;
+ #endif
+- unsigned IOCTL_FS_IOC_GETFLAGS = FS_IOC_GETFLAGS;
+- unsigned IOCTL_FS_IOC_GETVERSION = FS_IOC_GETVERSION;
+- unsigned IOCTL_FS_IOC_SETFLAGS = FS_IOC_SETFLAGS;
+- unsigned IOCTL_FS_IOC_SETVERSION = FS_IOC_SETVERSION;
++ unsigned IOCTL_FS_IOC_GETFLAGS = _IOR('f', 1, long);
++ unsigned IOCTL_FS_IOC_GETVERSION = _IOR('v', 1, long);
++ unsigned IOCTL_FS_IOC_SETFLAGS = _IOW('f', 2, long);
++ unsigned IOCTL_FS_IOC_SETVERSION = _IOW('v', 2, long);
+ unsigned IOCTL_GIO_CMAP = GIO_CMAP;
+ unsigned IOCTL_GIO_FONT = GIO_FONT;
+ unsigned IOCTL_GIO_UNIMAP = GIO_UNIMAP;
+
+From 8c3238510ce63c75024c0288eade5c933f6d322e Mon Sep 17 00:00:00 2001
+From: Ian Lance Taylor <iant@golang.org>
+Date: Tue, 12 Jul 2022 19:42:43 -0700
+Subject: [PATCH] libgo: don't include <linux/fs.h> when building
+ gen-sysinfo.go
+
+Removing this doesn't change anything at least with glibc 2.33.
+The include was added in https://go.dev/cl/6100049 but it's not
+clear why.
+
+Fixes PR go/106266
+
+Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/417294
+(cherry picked from commit f35d65517a59565758107c5b1a51a5fa382f8d1a)
+--- a/libgo/sysinfo.c
++++ b/libgo/sysinfo.c
+@@ -150,9 +150,6 @@
+ #if defined(HAVE_LINUX_ETHER_H)
+ #include <linux/ether.h>
+ #endif
+-#if defined(HAVE_LINUX_FS_H)
+-#include <linux/fs.h>
+-#endif
+ #if defined(HAVE_LINUX_REBOOT_H)
+ #include <linux/reboot.h>
+ #endif
diff --git a/10.4.0/gentoo/76_all_d_compiler_for_build_pie.patch b/10.4.0/gentoo/76_all_d_compiler_for_build_pie.patch
new file mode 100644
index 0000000..97996ea
--- /dev/null
+++ b/10.4.0/gentoo/76_all_d_compiler_for_build_pie.patch
@@ -0,0 +1,63 @@
+https://bugs.gentoo.org/855902
+https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d3ae0f515d0c675d42f4f18fc267e8e75f6b6f26
+
+From d3ae0f515d0c675d42f4f18fc267e8e75f6b6f26 Mon Sep 17 00:00:00 2001
+From: Iain Buclaw <ibuclaw@gdcproject.org>
+Date: Sun, 16 Jun 2019 18:12:47 +0200
+Subject: [PATCH] d: Use COMPILER_FOR_BUILD to build all D front-end generator
+ programs
+
+This means the correct config headers are included when building the
+D front-end in a Canadian cross configuration.
+
+gcc/d/ChangeLog:
+
+ * Make-lang.in (DMDGEN_COMPILE): Remove.
+ (d/%.dmdgen.o): Use COMPILER_FOR_BUILD and BUILD_COMPILERFLAGS to
+ build all D generator programs.
+ (D_SYSTEM_H): New macro.
+ (d/idgen.dmdgen.o): Add dependencies to build.
+ (d/impcnvgen.dmdgen.o): Likewise.
+ * d-system.h: Include bconfig.h if GENERATOR_FILE is defined.
+--- a/gcc/d/Make-lang.in
++++ b/gcc/d/Make-lang.in
+@@ -52,7 +52,6 @@ d-warn = $(filter-out -pedantic -Woverloaded-virtual, $(STRICT_WARN))
+ # Also filter out warnings for missing format attributes in the D Frontend.
+ DMD_WARN_CXXFLAGS = $(filter-out -Wmissing-format-attribute, $(WARN_CXXFLAGS))
+ DMD_COMPILE = $(subst $(WARN_CXXFLAGS), $(DMD_WARN_CXXFLAGS), $(COMPILE))
+-DMDGEN_COMPILE = $(subst $(COMPILER), $(COMPILER_FOR_BUILD), $(DMD_COMPILE))
+
+ # D Frontend object files.
+ D_FRONTEND_OBJS = \
+@@ -360,6 +359,15 @@ d/id.h: d/id.c
+ d/impcnvtab.c: d/impcnvgen$(build_exeext)
+ cd d && ./impcnvgen$(build_exeext)
+
++# Compile the generator programs.
+ d/%.dmdgen.o: $(srcdir)/d/dmd/%.c
+- $(DMDGEN_COMPILE) $(D_INCLUDES) $<
+- $(POSTCOMPILE)
++ $(COMPILER_FOR_BUILD) -c $(BUILD_COMPILERFLAGS) $(D_INCLUDES) \
++ $(BUILD_CPPFLAGS) -o $@ $<
++
++# Header dependencies for the generator programs.
++D_SYSTEM_H = d/dmd/root/dsystem.h d/d-system.h
++
++d/idgen.dmdgen.o: d/dmd/idgen.c $(D_SYSTEM_H) $(BCONFIG_H) $(SYSTEM_H)
++
++d/impcnvgen.dmdgen.o: d/dmd/impcnvgen.c d/dmd/mtype.h $(D_SYSTEM_H) \
++ $(BCONFIG_H) $(SYSTEM_H)
+--- a/gcc/d/d-system.h
++++ b/gcc/d/d-system.h
+@@ -19,7 +19,11 @@
+ #ifndef GCC_D_SYSTEM_H
+ #define GCC_D_SYSTEM_H
+
++#ifdef GENERATOR_FILE
++#include "bconfig.h"
++#else
+ #include "config.h"
++#endif
+ #include "system.h"
+
+ /* Used by the dmd front-end to determine if we have POSIX-style IO. */
diff --git a/10.4.0/gentoo/README.history b/10.4.0/gentoo/README.history
index f86d4e4..a60e657 100644
--- a/10.4.0/gentoo/README.history
+++ b/10.4.0/gentoo/README.history
@@ -1,3 +1,18 @@
+5 22 Aug 2022
+ + 34_all_drop_CFLAGS_sed.patch
+
+4 22 Aug 2022
+ + 76_all_d_compiler_for_build_pie.patch
+
+3 22 Aug 2022
+ + 75_all_glibc_236.patch
+
+2 03 Jul 2022
+ + 33_all_msgfmt-libstdc++-link.patch
+
+1 22 May 2022
+ U 22_all_libstdcxx-no-vtv.patch
+
0 27 November 2021
+ 01_all_default-fortify-source.patch
+ 02_all_default-warn-format-security.patch
diff --git a/10.4.0/musl/25_all_multilib_pure64.patch b/10.4.0/musl/25_all_multilib_pure64.patch
new file mode 100644
index 0000000..19fd5c9
--- /dev/null
+++ b/10.4.0/musl/25_all_multilib_pure64.patch
@@ -0,0 +1,86 @@
+diff -Naur gcc-9.3.0.orig/gcc/config/aarch64/t-aarch64-linux gcc-9.3.0/gcc/config/aarch64/t-aarch64-linux
+--- gcc-9.3.0.orig/gcc/config/aarch64/t-aarch64-linux 2020-10-05 02:59:12.767988285 -0700
++++ gcc-9.3.0/gcc/config/aarch64/t-aarch64-linux 2020-10-05 03:03:32.310816444 -0700
+@@ -22,7 +22,7 @@
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+diff -Naur gcc-9.3.0.orig/gcc/config/i386/t-linux64 gcc-9.3.0/gcc/config/i386/t-linux64
+--- gcc-9.3.0.orig/gcc/config/i386/t-linux64 2020-10-05 02:59:12.757989347 -0700
++++ gcc-9.3.0/gcc/config/i386/t-linux64 2020-10-05 03:24:58.878825272 -0700
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
+-MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
++MULTILIB_OSDIRNAMES+= mx32=../libx32
+diff -Naur gcc-9.3.0.orig/gcc/config/rs6000/t-linux gcc-9.3.0/gcc/config/rs6000/t-linux
+--- gcc-9.3.0.orig/gcc/config/rs6000/t-linux 2020-10-05 02:59:12.767988285 -0700
++++ gcc-9.3.0/gcc/config/rs6000/t-linux 2020-10-05 03:03:32.310816444 -0700
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+
+diff -Naur gcc-9.3.0.orig/gcc/config/rs6000/t-linux64 gcc-9.3.0/gcc/config/rs6000/t-linux64
+--- gcc-9.3.0.orig/gcc/config/rs6000/t-linux64 2020-10-05 02:59:12.767988285 -0700
++++ gcc-9.3.0/gcc/config/rs6000/t-linux64 2020-10-05 03:03:32.310816444 -0700
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS := m64/m32
+ MULTILIB_DIRNAMES := 64 32
+ MULTILIB_EXTRA_OPTS :=
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ $(COMPILE) $<
+diff -Naur gcc-9.3.0.orig/gcc/config/rs6000/t-linux64bele gcc-9.3.0/gcc/config/rs6000/t-linux64bele
+--- gcc-9.3.0.orig/gcc/config/rs6000/t-linux64bele 2020-10-05 02:59:12.767988285 -0700
++++ gcc-9.3.0/gcc/config/rs6000/t-linux64bele 2020-10-05 03:03:32.310816444 -0700
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mlittle
+ MULTILIB_DIRNAMES += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
+diff -Naur gcc-9.3.0.orig/gcc/config/rs6000/t-linux64lebe gcc-9.3.0/gcc/config/rs6000/t-linux64lebe
+--- gcc-9.3.0.orig/gcc/config/rs6000/t-linux64lebe 2020-10-05 02:59:12.777987222 -0700
++++ gcc-9.3.0/gcc/config/rs6000/t-linux64lebe 2020-10-05 03:03:32.310816444 -0700
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mbig
+ MULTILIB_DIRNAMES += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
diff --git a/10.4.0/musl/50_all_cpu_indicator.patch b/10.4.0/musl/50_all_cpu_indicator.patch
new file mode 100644
index 0000000..6141a83
--- /dev/null
+++ b/10.4.0/musl/50_all_cpu_indicator.patch
@@ -0,0 +1,46 @@
+From d16a8ceb1c3c8a7ec381090b4c316ff4c55661c0 Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 7 May 2020 21:14:11 -0500
+Subject: [PATCH] convert "__cpu_indicator_init" to
+ "__cpu_indicator_init_local"
+
+---
+ gcc/config/i386/i386-expand.c | 4 ++--
+ libgcc/config/i386/cpuinfo.c | 6 +++---
+ 2 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c
+index 48f00c5fc..78650b202 100644
+--- a/gcc/config/i386/i386-expand.c
++++ b/gcc/config/i386/i386-expand.c
+@@ -10941,10 +10941,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
+ {
+ case IX86_BUILTIN_CPU_INIT:
+ {
+- /* Make it call __cpu_indicator_init in libgcc. */
++ /* Make it call __cpu_indicator_init_local in libgcc. */
+ tree call_expr, fndecl, type;
+ type = build_function_type_list (integer_type_node, NULL_TREE);
+- fndecl = build_fn_decl ("__cpu_indicator_init", type);
++ fndecl = build_fn_decl ("__cpu_indicator_init_local", type);
+ call_expr = build_call_expr (fndecl, 0);
+ return expand_expr (call_expr, target, mode, EXPAND_NORMAL);
+ }
+diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c
+index 00322c586..f42bbb8af 100644
+--- a/libgcc/config/i386/cpuinfo.c
++++ b/libgcc/config/i386/cpuinfo.c
+@@ -508,7 +508,7 @@ __cpu_indicator_init (void)
+ return 0;
+ }
+
+-#if defined SHARED && defined USE_ELF_SYMVER
+-__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0");
+-__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0");
++#ifndef SHARED
++int __cpu_indicator_init_local (void)
++ __attribute__ ((weak, alias ("__cpu_indicator_init")));
+ #endif
+--
+2.26.2
+
diff --git a/10.4.0/musl/50_all_posix_memalign.patch b/10.4.0/musl/50_all_posix_memalign.patch
new file mode 100644
index 0000000..a288e1d
--- /dev/null
+++ b/10.4.0/musl/50_all_posix_memalign.patch
@@ -0,0 +1,29 @@
+diff -Naur gcc-7.1.0.orig/gcc/config/i386/pmm_malloc.h gcc-7.1.0/gcc/config/i386/pmm_malloc.h
+--- gcc-7.1.0.orig/gcc/config/i386/pmm_malloc.h 2017-01-01 04:07:43.000000000 -0800
++++ gcc-7.1.0/gcc/config/i386/pmm_malloc.h 2017-05-07 11:35:22.878398460 -0700
+@@ -27,12 +27,13 @@
+ #include <stdlib.h>
+
+ /* We can't depend on <stdlib.h> since the prototype of posix_memalign
+- may not be visible. */
++ may not be visible and we can't pollute the namespace either. */
+ #ifndef __cplusplus
+-extern int posix_memalign (void **, size_t, size_t);
++extern int __gcc_posix_memalign (void **, size_t, size_t)
+ #else
+-extern "C" int posix_memalign (void **, size_t, size_t) throw ();
++extern "C" int __gcc_posix_memalign (void **, size_t, size_t) throw ()
+ #endif
++__asm__("posix_memalign");
+
+ static __inline void *
+ _mm_malloc (size_t __size, size_t __alignment)
+@@ -42,7 +43,7 @@
+ return malloc (__size);
+ if (__alignment == 2 || (sizeof (void *) == 8 && __alignment == 4))
+ __alignment = sizeof (void *);
+- if (posix_memalign (&__ptr, __alignment, __size) == 0)
++ if (__gcc_posix_memalign (&__ptr, __alignment, __size) == 0)
+ return __ptr;
+ else
+ return NULL;
diff --git a/10.4.0/musl/nocross/50_all_libssp_unconditionally.patch b/10.4.0/musl/nocross/50_all_libssp_unconditionally.patch
new file mode 100644
index 0000000..7e4c58a
--- /dev/null
+++ b/10.4.0/musl/nocross/50_all_libssp_unconditionally.patch
@@ -0,0 +1,24 @@
+https://bugs.gentoo.org/706210
+https://bugs.gentoo.org/747346
+
+Author: Timo Teräs <timo.teras@iki.fi>
+
+"Alpine musl package provides libssp_nonshared.a. We link to it unconditionally,
+as otherwise we get link failures if some objects are -fstack-protector built
+and final link happens with -fno-stack-protector. This seems to be the common
+case when bootstrapping gcc, the piepatches do not seem to fully fix the
+crosstoolchain and bootstrap sequence wrt. stack-protector flag usage."
+
+(We do the same in Gentoo.)
+--- gcc-6.1.0/gcc/gcc.c.orig
++++ gcc-6.1.0/gcc/gcc.c
+@@ -870,8 +870,7 @@
+
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+- "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ "|fstack-protector-strong|fstack-protector-explicit" \
diff --git a/12.0.0/gentoo/01_all_default-fortify-source.patch b/10.5.0/gentoo/01_all_default-fortify-source.patch
index d307474..d307474 100644
--- a/12.0.0/gentoo/01_all_default-fortify-source.patch
+++ b/10.5.0/gentoo/01_all_default-fortify-source.patch
diff --git a/10.5.0/gentoo/02_all_default-warn-format-security.patch b/10.5.0/gentoo/02_all_default-warn-format-security.patch
new file mode 100644
index 0000000..36201dc
--- /dev/null
+++ b/10.5.0/gentoo/02_all_default-warn-format-security.patch
@@ -0,0 +1,22 @@
+Enable -Wformat and -Wformat-security by default.
+
+--- a/gcc/c-family/c.opt
++++ b/gcc/c-family/c.opt
+@@ -599,7 +599,7 @@
+ of the destination region. Same as -Wformat-overflow=1.
+
+ 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
+@@ -620,7 +620,7 @@
+ 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.
+
+ Wformat-overflow=
diff --git a/12.0.0/gentoo/03_all_default-warn-trampolines.patch b/10.5.0/gentoo/03_all_default-warn-trampolines.patch
index 7a644cb..7a644cb 100644
--- a/12.0.0/gentoo/03_all_default-warn-trampolines.patch
+++ b/10.5.0/gentoo/03_all_default-warn-trampolines.patch
diff --git a/10.5.0/gentoo/04_all_nossp-on-nostdlib.patch b/10.5.0/gentoo/04_all_nossp-on-nostdlib.patch
new file mode 100644
index 0000000..6d9f00a
--- /dev/null
+++ b/10.5.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.c
++++ b/gcc/gcc.c
+@@ -874,6 +874,12 @@
+ #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} "
++#else
++#define NO_SSP_SPEC ""
++#endif
++
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+@@ -1155,7 +1161,7 @@
+ %{-version:--version}\
+ %{-help=*:--help=%*}\
+ %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}}\
+- %{fsyntax-only:-o %j} %{-param*}\
++ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\
+ %{coverage:-fprofile-arcs -ftest-coverage}\
+ %{fprofile-arcs|fprofile-generate*|coverage:\
+ %{!fprofile-update=single:\
diff --git a/10.5.0/gentoo/05_all_alpha-mieee-default.patch b/10.5.0/gentoo/05_all_alpha-mieee-default.patch
new file mode 100644
index 0000000..b266d77
--- /dev/null
+++ b/10.5.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 <vapier@gentoo.org>
+
+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
+@@ -96,6 +96,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 Report RejectNegative Mask(IEEE)
++Target Report Mask(IEEE)
+ Emit IEEE-conformant code, without inexact exceptions.
+
+ mieee-with-inexact
+
diff --git a/12.0.0/gentoo/06_all_ia64_note.GNU-stack.patch b/10.5.0/gentoo/06_all_ia64_note.GNU-stack.patch
index 66a787e..66a787e 100644
--- a/12.0.0/gentoo/06_all_ia64_note.GNU-stack.patch
+++ b/10.5.0/gentoo/06_all_ia64_note.GNU-stack.patch
diff --git a/10.5.0/gentoo/07_all_i386_libgcc_note.GNU-stack.patch b/10.5.0/gentoo/07_all_i386_libgcc_note.GNU-stack.patch
new file mode 100644
index 0000000..63dbabb
--- /dev/null
+++ b/10.5.0/gentoo/07_all_i386_libgcc_note.GNU-stack.patch
@@ -0,0 +1,54 @@
+--- a/libgcc/config/i386/resms64.h
++++ b/libgcc/config/i386/resms64.h
+@@ -57,3 +57,6 @@ MS2SYSV_STUB_END(resms64_17)
+ MS2SYSV_STUB_END(resms64_18)
+
+ #endif /* __x86_64__ */
++#if defined(__linux__) && defined(__ELF__)
++.section .note.GNU-stack,"",%progbits
++#endif
+--- a/libgcc/config/i386/resms64f.h
++++ b/libgcc/config/i386/resms64f.h
+@@ -55,3 +55,6 @@ MS2SYSV_STUB_END(resms64f_16)
+ MS2SYSV_STUB_END(resms64f_17)
+
+ #endif /* __x86_64__ */
++#if defined(__linux__) && defined(__ELF__)
++.section .note.GNU-stack,"",%progbits
++#endif
+--- a/libgcc/config/i386/resms64fx.h
++++ b/libgcc/config/i386/resms64fx.h
+@@ -62,3 +62,6 @@ MS2SYSV_STUB_END(resms64fx_16)
+ MS2SYSV_STUB_END(resms64fx_17)
+
+ #endif /* __x86_64__ */
++#if defined(__linux__) && defined(__ELF__)
++.section .note.GNU-stack,"",%progbits
++#endif
+--- a/libgcc/config/i386/resms64x.h
++++ b/libgcc/config/i386/resms64x.h
+@@ -63,3 +63,6 @@ MS2SYSV_STUB_END(resms64x_17)
+ MS2SYSV_STUB_END(resms64x_18)
+
+ #endif /* __x86_64__ */
++#if defined(__linux__) && defined(__ELF__)
++.section .note.GNU-stack,"",%progbits
++#endif
+--- a/libgcc/config/i386/savms64.h
++++ b/libgcc/config/i386/savms64.h
+@@ -57,3 +57,6 @@ MS2SYSV_STUB_END(savms64_17)
+ MS2SYSV_STUB_END(savms64_18)
+
+ #endif /* __x86_64__ */
++#if defined(__linux__) && defined(__ELF__)
++.section .note.GNU-stack,"",%progbits
++#endif
+--- a/libgcc/config/i386/savms64f.h
++++ b/libgcc/config/i386/savms64f.h
+@@ -55,3 +55,6 @@ MS2SYSV_STUB_END(savms64f_16)
+ MS2SYSV_STUB_END(savms64f_17)
+
+ #endif /* __x86_64__ */
++#if defined(__linux__) && defined(__ELF__)
++.section .note.GNU-stack,"",%progbits
++#endif
diff --git a/10.5.0/gentoo/08_all_libiberty-asprintf.patch b/10.5.0/gentoo/08_all_libiberty-asprintf.patch
new file mode 100644
index 0000000..83ae56e
--- /dev/null
+++ b/10.5.0/gentoo/08_all_libiberty-asprintf.patch
@@ -0,0 +1,18 @@
+2008-07-25 Magnus Granberg <zorry@ume.nu>
+
+ * include/libiberty.h (asprintf): Don't declare if defined as a macro
+
+--- a/include/libiberty.h
++++ b/include/libiberty.h
+@@ -645,8 +645,11 @@
+ /* Like sprintf but provides a pointer to malloc'd storage, which must
+ be freed by the caller. */
+
++/* asprintf may be declared as a macro by glibc with __USE_FORTIFY_LEVEL. */
++#ifndef asprintf
+ extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
+ #endif
++#endif
+
+ /* Like asprintf but allocates memory without fail. This works like
+ xmalloc. */
diff --git a/12.0.0/gentoo/08_all_libiberty-pic.patch b/10.5.0/gentoo/09_all_libiberty-pic.patch
index b6160a7..b6160a7 100644
--- a/12.0.0/gentoo/08_all_libiberty-pic.patch
+++ b/10.5.0/gentoo/09_all_libiberty-pic.patch
diff --git a/10.5.0/gentoo/10_all_nopie-all-flags.patch b/10.5.0/gentoo/10_all_nopie-all-flags.patch
new file mode 100644
index 0000000..5563182
--- /dev/null
+++ b/10.5.0/gentoo/10_all_nopie-all-flags.patch
@@ -0,0 +1,18 @@
+We need to pass NO_PIE_CFLAGS to ALL_* so gcc don't fail when
+we compile it with older gcc and pie.
+
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -991,10 +991,10 @@ ALL_CXXFLAGS = $(T_CFLAGS) $(CFLAGS-$@)
+ ALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS)
+
+ # This is the variable to use when using $(COMPILER).
+-ALL_COMPILERFLAGS = $(ALL_CXXFLAGS)
++ALL_COMPILERFLAGS = $(NO_PIE_CFLAGS) $(ALL_CXXFLAGS)
+
+ # This is the variable to use when using $(LINKER).
+-ALL_LINKERFLAGS = $(ALL_CXXFLAGS)
++ALL_LINKERFLAGS = $(NO_PIE_CFLAGS) $(ALL_CXXFLAGS)
+
+ # Build and host support libraries.
+
diff --git a/10.5.0/gentoo/11_all_sh-drop-sysroot-suffix.patch b/10.5.0/gentoo/11_all_sh-drop-sysroot-suffix.patch
new file mode 100644
index 0000000..b1c3591
--- /dev/null
+++ b/10.5.0/gentoo/11_all_sh-drop-sysroot-suffix.patch
@@ -0,0 +1,26 @@
+From 5eeeff19bb4978a8d3c0d53bc81744bc25d82993 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+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 <slyfox@gentoo.org>
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -2866,8 +2866,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/10.5.0/gentoo/12_all_ia64-TEXTREL.patch b/10.5.0/gentoo/12_all_ia64-TEXTREL.patch
new file mode 100644
index 0000000..5059e4d
--- /dev/null
+++ b/10.5.0/gentoo/12_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.c
++++ b/gcc/config/ia64/ia64.c
+@@ -10838,12 +10838,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/10.5.0/gentoo/13_all_disable-systemtap-switch.patch b/10.5.0/gentoo/13_all_disable-systemtap-switch.patch
new file mode 100644
index 0000000..d4ecefa
--- /dev/null
+++ b/10.5.0/gentoo/13_all_disable-systemtap-switch.patch
@@ -0,0 +1,115 @@
+From bb510ed7ea82093c924b027489db6f92250a85b3 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Sat, 12 May 2018 12:56:46 +0100
+Subject: [PATCH] gcc/configure.ac: add --disable-systemtap switch
+
+Before the change systemtap probes were enabled
+if target headers had sys/sdt.h at ./configure time.
+
+After the change explicitly ask to enable or disable
+for probe support and not rely on automagic dependency
+discovery.
+
+Bug: https://bugs.gentoo.org/654748
+Bug: https://gcc.gnu.org/bugzilla/PR61257
+Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -988,6 +988,7 @@ enable_gnu_unique_object
+ enable_linker_build_id
+ enable_libssp
+ enable_default_ssp
++enable_systemtap
+ with_long_double_128
+ with_long_double_format
+ with_gc
+@@ -1740,6 +1741,7 @@ Optional Features:
+ compiler will always pass --build-id to linker
+ --enable-libssp enable linking against libssp
+ --enable-default-ssp enable Stack Smashing Protection as default
++ --disable-systemtap enable systemtap static probe points [default=auto]
+ --enable-maintainer-mode
+ enable make rules and dependencies not useful (and
+ sometimes confusing) to the casual installer
+@@ -29330,17 +29332,33 @@ fi
+
+ # Test for <sys/sdt.h> on the target.
+
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking sys/sdt.h in the target C library" >&5
++
++# Check whether --enable-systemtap was given.
++if test "${enable_systemtap+set}" = set; then :
++ enableval=$enable_systemtap; enable_systemtap=$enableval
++else
++ enable_systemtap=auto
++fi
++
++
++if test x$enable_systemtap != xno; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking sys/sdt.h in the target C library" >&5
+ $as_echo_n "checking sys/sdt.h in the target C library... " >&6; }
+-have_sys_sdt_h=no
+-if test -f $target_header_dir/sys/sdt.h; then
+- have_sys_sdt_h=yes
++ have_sys_sdt_h=no
++ if test -f $target_header_dir/sys/sdt.h ; then
++ have_sys_sdt_h=yes
+
+ $as_echo "#define HAVE_SYS_SDT_H 1" >>confdefs.h
+
+-fi
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_sys_sdt_h" >&5
++ fi
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_sys_sdt_h" >&5
+ $as_echo "$have_sys_sdt_h" >&6; }
++ if test x$enable_systemtap = xyes ; then
++ if test x$have_sys_sdt_h = xno ; then
++ as_fn_error $? "sys/sdt.h was not found" "$LINENO" 5
++ fi
++ fi
++fi
+
+ # Check if TFmode long double should be used by default or not.
+ # Some glibc targets used DFmode long double, but with glibc 2.4
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -6000,14 +6000,28 @@ AC_SUBST([enable_default_ssp])
+
+ # Test for <sys/sdt.h> on the target.
+ GCC_TARGET_TEMPLATE([HAVE_SYS_SDT_H])
+-AC_MSG_CHECKING(sys/sdt.h in the target C library)
+-have_sys_sdt_h=no
+-if test -f $target_header_dir/sys/sdt.h; then
+- have_sys_sdt_h=yes
+- AC_DEFINE(HAVE_SYS_SDT_H, 1,
+- [Define if your target C library provides sys/sdt.h])
+-fi
+-AC_MSG_RESULT($have_sys_sdt_h)
++
++AC_ARG_ENABLE(systemtap,
++[AS_HELP_STRING([--disable-systemtap],
++ [enable systemtap static probe points [default=auto]])],
++ enable_systemtap=$enableval,
++ enable_systemtap=auto)
++
++if test x$enable_systemtap != xno; then
++ AC_MSG_CHECKING(sys/sdt.h in the target C library)
++ have_sys_sdt_h=no
++ if test -f $target_header_dir/sys/sdt.h ; then
++ have_sys_sdt_h=yes
++ AC_DEFINE(HAVE_SYS_SDT_H, 1,
++ [Define if your target C library provides sys/sdt.h])
++ fi
++ AC_MSG_RESULT($have_sys_sdt_h)
++ if test x$enable_systemtap = xyes ; then
++ if test x$have_sys_sdt_h = xno ; then
++ AC_MSG_ERROR([sys/sdt.h was not found])
++ fi
++ fi
++fi
+
+ # Check if TFmode long double should be used by default or not.
+ # Some glibc targets used DFmode long double, but with glibc 2.4
+--
+2.17.0
+
diff --git a/10.5.0/gentoo/14_all_m68k-textrel-on-libgcc.patch b/10.5.0/gentoo/14_all_m68k-textrel-on-libgcc.patch
new file mode 100644
index 0000000..4cb8350
--- /dev/null
+++ b/10.5.0/gentoo/14_all_m68k-textrel-on-libgcc.patch
@@ -0,0 +1,87 @@
+https://gcc.gnu.org/PR86224
+
+From 1d89df42bdaf0745fd2a0d294471ac16f0553707 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Sat, 28 Jul 2018 11:33:27 +0100
+Subject: [PATCH] libgcc: m68k: avoid absolute relocation in shared library
+
+Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+--- a/libgcc/config/m68k/lb1sf68.S
++++ b/libgcc/config/m68k/lb1sf68.S
+@@ -435,7 +435,10 @@ $_exception_handler:
+ .text
+ FUNC(__mulsi3)
+ .globl SYM (__mulsi3)
++ .globl SYM (__mulsi3_internal)
++ .hidden SYM (__mulsi3_internal)
+ SYM (__mulsi3):
++SYM (__mulsi3_internal):
+ movew sp@(4), d0 /* x0 -> d0 */
+ muluw sp@(10), d0 /* x0*y1 */
+ movew sp@(6), d1 /* x1 -> d1 */
+@@ -458,7 +461,10 @@ SYM (__mulsi3):
+ .text
+ FUNC(__udivsi3)
+ .globl SYM (__udivsi3)
++ .globl SYM (__udivsi3_internal)
++ .hidden SYM (__udivsi3_internal)
+ SYM (__udivsi3):
++SYM (__udivsi3_internal):
+ #ifndef __mcoldfire__
+ movel d2, sp@-
+ movel sp@(12), d1 /* d1 = divisor */
+@@ -534,7 +540,10 @@ L2: subql IMM (1),d4
+ .text
+ FUNC(__divsi3)
+ .globl SYM (__divsi3)
++ .globl SYM (__divsi3_internal)
++ .hidden SYM (__divsi3_internal)
+ SYM (__divsi3):
++SYM (__divsi3_internal):
+ movel d2, sp@-
+
+ moveq IMM (1), d2 /* sign of result stored in d2 (=1 or =-1) */
+@@ -557,7 +566,7 @@ L1: movel sp@(8), d0 /* d0 = dividend */
+
+ L2: movel d1, sp@-
+ movel d0, sp@-
+- PICCALL SYM (__udivsi3) /* divide abs(dividend) by abs(divisor) */
++ PICCALL SYM (__udivsi3_internal) /* divide abs(dividend) by abs(divisor) */
+ addql IMM (8), sp
+
+ tstb d2
+@@ -577,13 +586,13 @@ SYM (__umodsi3):
+ movel sp@(4), d0 /* d0 = dividend */
+ movel d1, sp@-
+ movel d0, sp@-
+- PICCALL SYM (__udivsi3)
++ PICCALL SYM (__udivsi3_internal)
+ addql IMM (8), sp
+ movel sp@(8), d1 /* d1 = divisor */
+ #ifndef __mcoldfire__
+ movel d1, sp@-
+ movel d0, sp@-
+- PICCALL SYM (__mulsi3) /* d0 = (a/b)*b */
++ PICCALL SYM (__mulsi3_internal) /* d0 = (a/b)*b */
+ addql IMM (8), sp
+ #else
+ mulsl d1,d0
+@@ -603,13 +612,13 @@ SYM (__modsi3):
+ movel sp@(4), d0 /* d0 = dividend */
+ movel d1, sp@-
+ movel d0, sp@-
+- PICCALL SYM (__divsi3)
++ PICCALL SYM (__divsi3_internal)
+ addql IMM (8), sp
+ movel sp@(8), d1 /* d1 = divisor */
+ #ifndef __mcoldfire__
+ movel d1, sp@-
+ movel d0, sp@-
+- PICCALL SYM (__mulsi3) /* d0 = (a/b)*b */
++ PICCALL SYM (__mulsi3_internal) /* d0 = (a/b)*b */
+ addql IMM (8), sp
+ #else
+ mulsl d1,d0
+--
+2.18.0
+
diff --git a/12.0.0/gentoo/14_all_respect-build-cxxflags.patch b/10.5.0/gentoo/15_all_respect-build-cxxflags.patch
index 14139ea..14139ea 100644
--- a/12.0.0/gentoo/14_all_respect-build-cxxflags.patch
+++ b/10.5.0/gentoo/15_all_respect-build-cxxflags.patch
diff --git a/10.5.0/gentoo/16_all_libgfortran-Werror.patch b/10.5.0/gentoo/16_all_libgfortran-Werror.patch
new file mode 100644
index 0000000..1501057
--- /dev/null
+++ b/10.5.0/gentoo/16_all_libgfortran-Werror.patch
@@ -0,0 +1,28 @@
+libgfortran does not respect --disable-werror
+
+https://bugs.gentoo.org/433435
+http://gcc.gnu.org/PR54724
+
+
+--- a/libgfortran/configure.ac
++++ b/libgfortran/configure.ac
+@@ -146,7 +146,7 @@
+
+ # Add -Wall -fno-repack-arrays -fno-underscoring if we are using GCC.
+ if test "x$GCC" = "xyes"; then
+- AM_FCFLAGS="-I . -Wall -Werror -fimplicit-none -fno-repack-arrays -fno-underscoring"
++ AM_FCFLAGS="-I . -Wall -fimplicit-none -fno-repack-arrays -fno-underscoring"
+ ## We like to use C11 and C99 routines when available. This makes
+ ## sure that
+ ## __STDC_VERSION__ is set such that libc includes make them available.
+--- a/libgfortran/configure
++++ b/libgfortran/configure
+@@ -5981,7 +5981,7 @@
+
+ # Add -Wall -fno-repack-arrays -fno-underscoring if we are using GCC.
+ if test "x$GCC" = "xyes"; then
+- AM_FCFLAGS="-I . -Wall -Werror -fimplicit-none -fno-repack-arrays -fno-underscoring"
++ AM_FCFLAGS="-I . -Wall -fimplicit-none -fno-repack-arrays -fno-underscoring"
+ ## We like to use C11 and C99 routines when available. This makes
+ ## sure that
+ ## __STDC_VERSION__ is set such that libc includes make them available.
diff --git a/10.5.0/gentoo/17_all_libgomp-Werror.patch b/10.5.0/gentoo/17_all_libgomp-Werror.patch
new file mode 100644
index 0000000..ffcb076
--- /dev/null
+++ b/10.5.0/gentoo/17_all_libgomp-Werror.patch
@@ -0,0 +1,26 @@
+libgomp does not respect --disable-werror
+
+https://bugs.gentoo.org/229059
+http://gcc.gnu.org/PR38436
+--- a/libgomp/configure.ac
++++ b/libgomp/configure.ac
+@@ -123,7 +123,7 @@
+
+ # Add -Wall -Werror if we are using GCC.
+ if test "x$GCC" = "xyes"; then
+- XCFLAGS="$XCFLAGS -Wall -Werror"
++ XCFLAGS="$XCFLAGS -Wall"
+ fi
+
+ # Find other programs we need.
+--- a/libgomp/configure
++++ b/libgomp/configure
+@@ -4616,7 +4616,7 @@
+
+ # Add -Wall -Werror if we are using GCC.
+ if test "x$GCC" = "xyes"; then
+- XCFLAGS="$XCFLAGS -Wall -Werror"
++ XCFLAGS="$XCFLAGS -Wall"
+ fi
+
+ # Find other programs we need.
diff --git a/10.5.0/gentoo/18_all_libitm-Werror.patch b/10.5.0/gentoo/18_all_libitm-Werror.patch
new file mode 100644
index 0000000..c2b9164
--- /dev/null
+++ b/10.5.0/gentoo/18_all_libitm-Werror.patch
@@ -0,0 +1,25 @@
+libitm does not respect --disable-werror
+
+https://bugs.gentoo.org/475350
+--- a/libitm/configure.ac
++++ b/libitm/configure.ac
+@@ -263,7 +263,7 @@
+
+ # Add -Wall -Werror if we are using GCC.
+ if test "x$GCC" = "xyes"; then
+- XCFLAGS="$XCFLAGS -Wall -Werror"
++ XCFLAGS="$XCFLAGS -Wall"
+ fi
+
+ XCFLAGS="$XCFLAGS $XPCFLAGS"
+--- a/libitm/configure
++++ b/libitm/configure
+@@ -17864,7 +17864,7 @@
+
+ # Add -Wall -Werror if we are using GCC.
+ if test "x$GCC" = "xyes"; then
+- XCFLAGS="$XCFLAGS -Wall -Werror"
++ XCFLAGS="$XCFLAGS -Wall"
+ fi
+
+ XCFLAGS="$XCFLAGS $XPCFLAGS"
diff --git a/10.5.0/gentoo/19_all_libatomic-Werror.patch b/10.5.0/gentoo/19_all_libatomic-Werror.patch
new file mode 100644
index 0000000..c39ca37
--- /dev/null
+++ b/10.5.0/gentoo/19_all_libatomic-Werror.patch
@@ -0,0 +1,25 @@
+libatomic does not respect --disable-werror
+
+https://bugs.gentoo.org/475350
+--- a/libatomic/configure.ac
++++ b/libatomic/configure.ac
+@@ -253,7 +253,7 @@
+
+ # Add -Wall -Werror if we are using GCC.
+ if test "x$GCC" = "xyes"; then
+- XCFLAGS="$XCFLAGS -Wall -Werror"
++ XCFLAGS="$XCFLAGS -Wall"
+ fi
+
+ # Add CET specific flags if CET is enabled
+--- a/libatomic/configure
++++ b/libatomic/configure
+@@ -15571,7 +15571,7 @@
+
+ # Add -Wall -Werror if we are using GCC.
+ if test "x$GCC" = "xyes"; then
+- XCFLAGS="$XCFLAGS -Wall -Werror"
++ XCFLAGS="$XCFLAGS -Wall"
+ fi
+
+ # Add CET specific flags if CET is enabled
diff --git a/12.0.0/gentoo/18_all_libbacktrace-Werror.patch b/10.5.0/gentoo/20_all_libbacktrace-Werror.patch
index 57dd284..57dd284 100644
--- a/12.0.0/gentoo/18_all_libbacktrace-Werror.patch
+++ b/10.5.0/gentoo/20_all_libbacktrace-Werror.patch
diff --git a/12.0.0/gentoo/19_all_libsanitizer-Werror.patch b/10.5.0/gentoo/21_all_libsanitizer-Werror.patch
index 0e484a4..0e484a4 100644
--- a/12.0.0/gentoo/19_all_libsanitizer-Werror.patch
+++ b/10.5.0/gentoo/21_all_libsanitizer-Werror.patch
diff --git a/10.5.0/gentoo/22_all_libstdcxx-no-vtv.patch b/10.5.0/gentoo/22_all_libstdcxx-no-vtv.patch
new file mode 100644
index 0000000..4526af1
--- /dev/null
+++ b/10.5.0/gentoo/22_all_libstdcxx-no-vtv.patch
@@ -0,0 +1,79 @@
+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
+@@ -221,7 +221,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
+@@ -596,7 +596,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
+@@ -575,7 +575,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++17/Makefile.am
++++ b/libstdc++-v3/src/c++17/Makefile.am
+@@ -119,5 +119,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++17/Makefile.in
++++ b/libstdc++-v3/src/c++17/Makefile.in
+@@ -502,7 +502,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
+@@ -577,7 +577,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/10.5.0/gentoo/23_all_disable-riscv32-ABIs.patch b/10.5.0/gentoo/23_all_disable-riscv32-ABIs.patch
new file mode 100644
index 0000000..8bffc72
--- /dev/null
+++ b/10.5.0/gentoo/23_all_disable-riscv32-ABIs.patch
@@ -0,0 +1,52 @@
+Autogenerated patch disabling the 32bit RISCV support
+See https://gcc.gnu.org/PR90419
+
+--- a/gcc/config/riscv/t-linux-multilib
++++ b/gcc/config/riscv/t-linux-multilib
+@@ -1,40 +1,18 @@
+ # This file was generated by multilib-generator with the command:
+-# ./multilib-generator rv32imac-ilp32-rv32ima,rv32imaf,rv32imafd,rv32imafc,rv32imafdc- rv32imafdc-ilp32d-rv32imafd- rv64imac-lp64-rv64ima,rv64imaf,rv64imafd,rv64imafc,rv64imafdc- rv64imafdc-lp64d-rv64imafd-
+-MULTILIB_OPTIONS = march=rv32imac/march=rv32ima/march=rv32imaf/march=rv32imafd/march=rv32imafc/march=rv32imafdc/march=rv32g/march=rv32gc/march=rv64imac/march=rv64ima/march=rv64imaf/march=rv64imafd/march=rv64imafc/march=rv64imafdc/march=rv64g/march=rv64gc mabi=ilp32/mabi=ilp32d/mabi=lp64/mabi=lp64d
+-MULTILIB_DIRNAMES = rv32imac \
+-rv32ima \
+-rv32imaf \
+-rv32imafd \
+-rv32imafc \
+-rv32imafdc \
+-rv32g \
+-rv32gc \
+-rv64imac \
++# ./multilib-generator rv64imac-lp64-rv64ima,rv64imaf,rv64imafd,rv64imafc,rv64imafdc- rv64imafdc-lp64d-rv64imafd-
++MULTILIB_OPTIONS = march=rv64imac/march=rv64ima/march=rv64imaf/march=rv64imafd/march=rv64imafc/march=rv64imafdc/march=rv64g/march=rv64gc mabi=lp64/mabi=lp64d
++MULTILIB_DIRNAMES = rv64imac \
+ rv64ima \
+ rv64imaf \
+ rv64imafd \
+ rv64imafc \
+ rv64imafdc \
+ rv64g \
+-rv64gc ilp32 \
+-ilp32d \
+-lp64 \
++rv64gc lp64 \
+ lp64d
+-MULTILIB_REQUIRED = march=rv32imac/mabi=ilp32 \
+-march=rv32imafdc/mabi=ilp32d \
+-march=rv64imac/mabi=lp64 \
++MULTILIB_REQUIRED = march=rv64imac/mabi=lp64 \
+ march=rv64imafdc/mabi=lp64d
+-MULTILIB_REUSE = march.rv32imac/mabi.ilp32=march.rv32ima/mabi.ilp32 \
+-march.rv32imac/mabi.ilp32=march.rv32imaf/mabi.ilp32 \
+-march.rv32imac/mabi.ilp32=march.rv32imafd/mabi.ilp32 \
+-march.rv32imac/mabi.ilp32=march.rv32imafc/mabi.ilp32 \
+-march.rv32imac/mabi.ilp32=march.rv32imafdc/mabi.ilp32 \
+-march.rv32imac/mabi.ilp32=march.rv32g/mabi.ilp32 \
+-march.rv32imac/mabi.ilp32=march.rv32gc/mabi.ilp32 \
+-march.rv32imafdc/mabi.ilp32d=march.rv32imafd/mabi.ilp32d \
+-march.rv32imafdc/mabi.ilp32d=march.rv32gc/mabi.ilp32d \
+-march.rv32imafdc/mabi.ilp32d=march.rv32g/mabi.ilp32d \
+-march.rv64imac/mabi.lp64=march.rv64ima/mabi.lp64 \
++MULTILIB_REUSE = march.rv64imac/mabi.lp64=march.rv64ima/mabi.lp64 \
+ march.rv64imac/mabi.lp64=march.rv64imaf/mabi.lp64 \
+ march.rv64imac/mabi.lp64=march.rv64imafd/mabi.lp64 \
+ march.rv64imac/mabi.lp64=march.rv64imafc/mabi.lp64 \
diff --git a/12.0.0/gentoo/22_all_default_ssp-buffer-size.patch b/10.5.0/gentoo/24_all_default_ssp-buffer-size.patch
index ae5a707..ae5a707 100644
--- a/12.0.0/gentoo/22_all_default_ssp-buffer-size.patch
+++ b/10.5.0/gentoo/24_all_default_ssp-buffer-size.patch
diff --git a/10.5.0/gentoo/25_all_hppa-faster-synth_mult.patch b/10.5.0/gentoo/25_all_hppa-faster-synth_mult.patch
new file mode 100644
index 0000000..e9584e3
--- /dev/null
+++ b/10.5.0/gentoo/25_all_hppa-faster-synth_mult.patch
@@ -0,0 +1,40 @@
+From 73a841928cc1b86f43108d2383a6242e7e61a785 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Tue, 31 Mar 2020 23:58:05 +0100
+Subject: [PATCH] gcc/expmed.h: increase cache size from 10^3 to 10^6
+
+Without this patch is takes dev-libs/xxhash 1-2 hours
+to compile. With this patch - TODO measurements.
+
+It workarounds deficiency of synth_mult() which evics
+cache entries as it calculates optimal multiplication
+algorithm. xxhash is especially hevyweight as it's a
+64-bit multiplication of large prime constants.
+
+Bug: https://gcc.gnu.org/PR87256
+Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+--- a/gcc/expmed.h
++++ b/gcc/expmed.h
+@@ -127,11 +127,14 @@ struct alg_hash_entry {
+ };
+
+ /* The number of cache/hash entries. */
+-#if HOST_BITS_PER_WIDE_INT == 64
+-#define NUM_ALG_HASH_ENTRIES 1031
+-#else
+-#define NUM_ALG_HASH_ENTRIES 307
+-#endif
++/*
++ * Workaround hppa2.0 synth_mult deficiency
++ * and allocate ~1 million slots:
++ * https://gcc.gnu.org/PR87256
++ * That should increase RAM usage up to ~24MB
++ * per process.
++ */
++#define NUM_ALG_HASH_ENTRIES 1000003
+
+ #define NUM_MODE_INT \
+ (MAX_MODE_INT - MIN_MODE_INT + 1)
+--
+2.26.0
+
diff --git a/10.5.0/gentoo/26_all_libcpp-ar.patch b/10.5.0/gentoo/26_all_libcpp-ar.patch
new file mode 100644
index 0000000..55f2944
--- /dev/null
+++ b/10.5.0/gentoo/26_all_libcpp-ar.patch
@@ -0,0 +1,143 @@
+https://bugs.gentoo.org/718004
+https://gcc.gnu.org/PR94657
+
+Make sue we use ${CHOST}-ar and not 'ar'.
+
+--- a/libcpp/configure.ac
++++ b/libcpp/configure.ac
+@@ -12,6 +12,7 @@ AC_PROG_INSTALL
+ AC_PROG_CC
+ AC_PROG_CXX
+ AC_PROG_RANLIB
++AC_CHECK_TOOL(AR, ar)
+
+ AC_USE_SYSTEM_EXTENSIONS
+ AC_SYS_LARGEFILE
+--- a/libcpp/Makefile.in
++++ b/libcpp/Makefile.in
+@@ -25,7 +25,7 @@ srcdir = @srcdir@
+ top_builddir = .
+ VPATH = @srcdir@
+ INSTALL = @INSTALL@
+-AR = ar
++AR = @AR@
+ ARFLAGS = cru
+ ACLOCAL = @ACLOCAL@
+ AUTOCONF = @AUTOCONF@
+--- a/libcpp/configure
++++ b/libcpp/configure
+@@ -657,6 +657,7 @@ ACLOCAL
+ EGREP
+ GREP
+ CPP
++AR
+ RANLIB
+ ac_ct_CXX
+ CXXFLAGS
+@@ -1038,6 +1039,7 @@ do
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
++
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+@@ -4006,6 +4008,98 @@ else
+ RANLIB="$ac_cv_prog_RANLIB"
+ fi
+
++if test -n "$ac_tool_prefix"; then
++ # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
++set dummy ${ac_tool_prefix}ar; ac_word=$2
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
++$as_echo_n "checking for $ac_word... " >&6; }
++if ${ac_cv_prog_AR+:} false; then :
++ $as_echo_n "(cached) " >&6
++else
++ if test -n "$AR"; then
++ ac_cv_prog_AR="$AR" # Let the user override the test.
++else
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_AR="${ac_tool_prefix}ar"
++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++ done
++IFS=$as_save_IFS
++
++fi
++fi
++AR=$ac_cv_prog_AR
++if test -n "$AR"; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
++$as_echo "$AR" >&6; }
++else
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++fi
++
++
++fi
++if test -z "$ac_cv_prog_AR"; then
++ ac_ct_AR=$AR
++ # Extract the first word of "ar", so it can be a program name with args.
++set dummy ar; ac_word=$2
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
++$as_echo_n "checking for $ac_word... " >&6; }
++if ${ac_cv_prog_ac_ct_AR+:} false; then :
++ $as_echo_n "(cached) " >&6
++else
++ if test -n "$ac_ct_AR"; then
++ ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
++else
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_ac_ct_AR="ar"
++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++ done
++IFS=$as_save_IFS
++
++fi
++fi
++ac_ct_AR=$ac_cv_prog_ac_ct_AR
++if test -n "$ac_ct_AR"; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
++$as_echo "$ac_ct_AR" >&6; }
++else
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++fi
++
++ if test "x$ac_ct_AR" = x; then
++ AR=""
++ else
++ case $cross_compiling:$ac_tool_warned in
++yes:)
++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
++ac_tool_warned=yes ;;
++esac
++ AR=$ac_ct_AR
++ fi
++else
++ AR="$ac_cv_prog_AR"
++fi
++
+
+
+ ac_ext=c
diff --git a/10.5.0/gentoo/27_all_EXTRA_OPTIONS-z-now.patch b/10.5.0/gentoo/27_all_EXTRA_OPTIONS-z-now.patch
new file mode 100644
index 0000000..93d31f2
--- /dev/null
+++ b/10.5.0/gentoo/27_all_EXTRA_OPTIONS-z-now.patch
@@ -0,0 +1,26 @@
+On Hardened we add some options like -z now
+
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -891,6 +891,12 @@
+ #endif
+ #endif
+
++#ifdef EXTRA_OPTIONS
++#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"
+@@ -1043,7 +1049,7 @@
+ %(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/10.5.0/gentoo/28_all_EXTRA_OPTIONS-fstack-clash-protection.patch b/10.5.0/gentoo/28_all_EXTRA_OPTIONS-fstack-clash-protection.patch
new file mode 100644
index 0000000..e821c03
--- /dev/null
+++ b/10.5.0/gentoo/28_all_EXTRA_OPTIONS-fstack-clash-protection.patch
@@ -0,0 +1,65 @@
+On Hardened we add some options like -fstack-clash-protection.
+
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -2367,7 +2367,7 @@ Common Alias(fstack-check=, specific, no
+ Insert stack checking code into the program. Same as -fstack-check=specific.
+
+ fstack-clash-protection
+-Common Report Var(flag_stack_clash_protection) Optimization
++Common Report 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
+@@ -1435,6 +1435,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. */
++#ifdef EXTRA_OPTIONS
++#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.c
++++ b/gcc/toplev.c
+@@ -1682,6 +1682,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
+@@ -225,7 +225,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.
+@@ -279,7 +290,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/12.0.0/gentoo/25_all_lto-intl-workaround-PR95194.patch b/10.5.0/gentoo/29_all_lto-intl-workaround-PR95194.patch
index 9613216..9613216 100644
--- a/12.0.0/gentoo/25_all_lto-intl-workaround-PR95194.patch
+++ b/10.5.0/gentoo/29_all_lto-intl-workaround-PR95194.patch
diff --git a/12.0.0/gentoo/26_all_plugin-objdump.patch b/10.5.0/gentoo/30_all_plugin-objdump.patch
index a9c33fd..a9c33fd 100644
--- a/12.0.0/gentoo/26_all_plugin-objdump.patch
+++ b/10.5.0/gentoo/30_all_plugin-objdump.patch
diff --git a/10.5.0/gentoo/31_all_fno-delayed-branch.patch b/10.5.0/gentoo/31_all_fno-delayed-branch.patch
new file mode 100644
index 0000000..35ba99e
--- /dev/null
+++ b/10.5.0/gentoo/31_all_fno-delayed-branch.patch
@@ -0,0 +1,36 @@
+From 6d0d3ae914bf19706550a539ef304c5875535ffc Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <siarheit@google.com>
+Date: Fri, 3 Jul 2020 22:50:33 +0100
+Subject: [PATCH] Disable -fdelayed-branch by default.
+
+From https://gcc.gnu.org/PR96015 / https://bugs.gentoo.org/729570.
+delayed branches are known to generate invalid code around
+__builtin_unreachable(); and mis-compiles python.
+
+Use blunt hammer and disable delayed slots until we have better fix.
+
+Reported-by: Jeroen Roovers
+Bug: https://gcc.gnu.org/PR96015
+Bug: https://bugs.gentoo.org/729570.
+Signed-off-by: Sergei Trofimovich <siarheit@google.com>
+--- a/gcc/opts.c
++++ b/gcc/opts.c
+@@ -458,7 +458,14 @@ static const struct default_options default_options_table[] =
+ /* -O1 (and not -Og) optimizations. */
+ { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fbranch_count_reg, NULL, 1 },
+ #if DELAY_SLOTS
+- { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fdelayed_branch, NULL, 1 },
++ /*
++ * From https://gcc.gnu.org/PR96015 / https://bugs.gentoo.org/729570.
++ * delayed branches are known to generate invalid code around
++ * __builtin_unreachable(); and mis-compiles python.
++ *
++ * Use blunt hammer and disable delayed slots until we have better fix.
++ */
++ /* { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fdelayed_branch, NULL, 1 }, */
+ #endif
+ { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fdse, NULL, 1 },
+ { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fif_conversion, NULL, 1 },
+--
+2.27.0
+
diff --git a/10.5.0/gentoo/32_all_vtv-slibtool.patch b/10.5.0/gentoo/32_all_vtv-slibtool.patch
new file mode 100644
index 0000000..a804ff7
--- /dev/null
+++ b/10.5.0/gentoo/32_all_vtv-slibtool.patch
@@ -0,0 +1,58 @@
+https://bugs.gentoo.org/767706
+https://gcc.gnu.org/PR99172
+
+From c2be82058fb40f3ae891c68d185ff53e07f14f45 Mon Sep 17 00:00:00 2001
+From: Caroline Tice <cmtice@google.com>
+Date: Fri, 12 Mar 2021 07:34:36 -0800
+Subject: [PATCH] libstdc++-v3: Update VTV vars for libtool link commands
+ [PR99172]
+
+This fixes PR 99172
+
+Currently when GCC is configured with --enable-vtable-verify, the
+libstdc++-v3 Makefiles add "-fvtable-verify=std
+-Wl,-u_vtable_map_vars_start,-u_vtable_map_vars_end" to libtool link
+commands. The "-fvtable-verify=std" piece causes alternate versions of
+libtool (such as slibtool) to fail, unable to find "-lvtv" (GNU
+libtool just removes that piece).
+
+This patch updates the libstdc++-v3 Makefiles to not pass
+"-fvtable-verify=std" to the libtool link commands.
+--- a/libstdc++-v3/src/Makefile.am
++++ b/libstdc++-v3/src/Makefile.am
+@@ -214,12 +214,14 @@ compatibility-condvar.o: compatibility-condvar.cc
+ # set this option because CONFIG_CXXFLAGS has to be after
+ # OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
+ # as the occasion calls for it.
+-AM_CXXFLAGS = \
++AM_CXXFLAGS_PRE = \
+ -std=gnu++98 \
+ $(glibcxx_compiler_pic_flag) \
+ $(XTEMPLATE_FLAGS) $(VTV_CXXFLAGS) \
+ $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
+
++AM_CXXFLAGS = $(filter-out -fvtable-verify=std,$(AM_CXXFLAGS_PRE))
++
+ # Libtool notes
+
+ # 1) In general, libtool expects an argument such as `--tag=CXX' when
+--- a/libstdc++-v3/src/Makefile.in
++++ b/libstdc++-v3/src/Makefile.in
+@@ -578,12 +578,13 @@ libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS) $(lt_host_flags)
+ # set this option because CONFIG_CXXFLAGS has to be after
+ # OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
+ # as the occasion calls for it.
+-AM_CXXFLAGS = \
++AM_CXXFLAGS_PRE = \
+ -std=gnu++98 \
+ $(glibcxx_compiler_pic_flag) \
+ $(XTEMPLATE_FLAGS) $(VTV_CXXFLAGS) \
+ $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
+
++AM_CXXFLAGS = $(filter-out -fvtable-verify=std,$(AM_CXXFLAGS_PRE))
+
+ # Libtool notes
+
+--
+2.30.2
+
diff --git a/10.5.0/gentoo/33_all_msgfmt-libstdc++-link.patch b/10.5.0/gentoo/33_all_msgfmt-libstdc++-link.patch
new file mode 100644
index 0000000..0d2f113
--- /dev/null
+++ b/10.5.0/gentoo/33_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/10.5.0/gentoo/34_all_drop_CFLAGS_sed.patch b/10.5.0/gentoo/34_all_drop_CFLAGS_sed.patch
new file mode 100644
index 0000000..0136628
--- /dev/null
+++ b/10.5.0/gentoo/34_all_drop_CFLAGS_sed.patch
@@ -0,0 +1,35 @@
+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
+@@ -5195,13 +5195,6 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
+ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+-# Remove the -O2: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[ ]//" -e "s/-O[gs][ ]//" -e "s/-O[0-9]*[ ]//" `
+- CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[ ]//" -e "s/-O[gs][ ]//" -e "s/-O[0-9]*[ ]//" ` ;;
+-esac
+
+
+
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -397,13 +397,6 @@ ACX_PROG_GNAT([-I"$srcdir"/ada/libgnat])
+ # Do configure tests with the C++ compiler, since that's what we build with.
+ AC_LANG(C++)
+
+-# Remove the -O2: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" `
+- CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" ` ;;
+-esac
+ AC_SUBST(CFLAGS)
+ AC_SUBST(CXXFLAGS)
+
diff --git a/10.5.0/gentoo/35_all_tar_libstdc++-link.patch b/10.5.0/gentoo/35_all_tar_libstdc++-link.patch
new file mode 100644
index 0000000..5e1a154
--- /dev/null
+++ b/10.5.0/gentoo/35_all_tar_libstdc++-link.patch
@@ -0,0 +1,57 @@
+From eae11e896edef4199a128bf6720b5bd4e5edc2f9 Mon Sep 17 00:00:00 2001
+From: Sam James <sam@gentoo.org>
+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 <sam@gentoo.org>
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -3833,10 +3833,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.
+@@ -3857,7 +3857,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/10.5.0/gentoo/75_all_d_compiler_for_build_pie.patch b/10.5.0/gentoo/75_all_d_compiler_for_build_pie.patch
new file mode 100644
index 0000000..97996ea
--- /dev/null
+++ b/10.5.0/gentoo/75_all_d_compiler_for_build_pie.patch
@@ -0,0 +1,63 @@
+https://bugs.gentoo.org/855902
+https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d3ae0f515d0c675d42f4f18fc267e8e75f6b6f26
+
+From d3ae0f515d0c675d42f4f18fc267e8e75f6b6f26 Mon Sep 17 00:00:00 2001
+From: Iain Buclaw <ibuclaw@gdcproject.org>
+Date: Sun, 16 Jun 2019 18:12:47 +0200
+Subject: [PATCH] d: Use COMPILER_FOR_BUILD to build all D front-end generator
+ programs
+
+This means the correct config headers are included when building the
+D front-end in a Canadian cross configuration.
+
+gcc/d/ChangeLog:
+
+ * Make-lang.in (DMDGEN_COMPILE): Remove.
+ (d/%.dmdgen.o): Use COMPILER_FOR_BUILD and BUILD_COMPILERFLAGS to
+ build all D generator programs.
+ (D_SYSTEM_H): New macro.
+ (d/idgen.dmdgen.o): Add dependencies to build.
+ (d/impcnvgen.dmdgen.o): Likewise.
+ * d-system.h: Include bconfig.h if GENERATOR_FILE is defined.
+--- a/gcc/d/Make-lang.in
++++ b/gcc/d/Make-lang.in
+@@ -52,7 +52,6 @@ d-warn = $(filter-out -pedantic -Woverloaded-virtual, $(STRICT_WARN))
+ # Also filter out warnings for missing format attributes in the D Frontend.
+ DMD_WARN_CXXFLAGS = $(filter-out -Wmissing-format-attribute, $(WARN_CXXFLAGS))
+ DMD_COMPILE = $(subst $(WARN_CXXFLAGS), $(DMD_WARN_CXXFLAGS), $(COMPILE))
+-DMDGEN_COMPILE = $(subst $(COMPILER), $(COMPILER_FOR_BUILD), $(DMD_COMPILE))
+
+ # D Frontend object files.
+ D_FRONTEND_OBJS = \
+@@ -360,6 +359,15 @@ d/id.h: d/id.c
+ d/impcnvtab.c: d/impcnvgen$(build_exeext)
+ cd d && ./impcnvgen$(build_exeext)
+
++# Compile the generator programs.
+ d/%.dmdgen.o: $(srcdir)/d/dmd/%.c
+- $(DMDGEN_COMPILE) $(D_INCLUDES) $<
+- $(POSTCOMPILE)
++ $(COMPILER_FOR_BUILD) -c $(BUILD_COMPILERFLAGS) $(D_INCLUDES) \
++ $(BUILD_CPPFLAGS) -o $@ $<
++
++# Header dependencies for the generator programs.
++D_SYSTEM_H = d/dmd/root/dsystem.h d/d-system.h
++
++d/idgen.dmdgen.o: d/dmd/idgen.c $(D_SYSTEM_H) $(BCONFIG_H) $(SYSTEM_H)
++
++d/impcnvgen.dmdgen.o: d/dmd/impcnvgen.c d/dmd/mtype.h $(D_SYSTEM_H) \
++ $(BCONFIG_H) $(SYSTEM_H)
+--- a/gcc/d/d-system.h
++++ b/gcc/d/d-system.h
+@@ -19,7 +19,11 @@
+ #ifndef GCC_D_SYSTEM_H
+ #define GCC_D_SYSTEM_H
+
++#ifdef GENERATOR_FILE
++#include "bconfig.h"
++#else
+ #include "config.h"
++#endif
+ #include "system.h"
+
+ /* Used by the dmd front-end to determine if we have POSIX-style IO. */
diff --git a/10.5.0/gentoo/76_all_configure-c89.patch b/10.5.0/gentoo/76_all_configure-c89.patch
new file mode 100644
index 0000000..9d65cb2
--- /dev/null
+++ b/10.5.0/gentoo/76_all_configure-c89.patch
@@ -0,0 +1,141 @@
+https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=6be2672e4ee41c566a9e072088cccca263bab5f7
+https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=885b6660c17fb91980b5682514ef54668e544b02
+
+From 942a325c81136138c4c199f8ab3e89a1945c3790 Mon Sep 17 00:00:00 2001
+From: Florian Weimer <fweimer@redhat.com>
+Date: Tue, 18 Oct 2022 16:58:48 +0200
+Subject: [PATCH 1/2] libsanitizer: Avoid implicit function declaration in
+ configure test
+
+libsanitizer/
+
+ * configure.ac (sanitizer_supported): Include <unistd.h> for
+ syscall prototype.
+ * configure: Regenerate.
+
+From 9a43d0e406c05d2d7136721443192bb6588c3113 Mon Sep 17 00:00:00 2001
+From: Florian Weimer <fweimer@redhat.com>
+Date: Tue, 18 Oct 2022 16:58:48 +0200
+Subject: [PATCH 2/2] libiberty: Fix C89-isms in configure tests
+
+libiberty/
+
+ * acinclude.m4 (ac_cv_func_strncmp_works): Add missing
+ int return type and parameter list to the definition of main.
+ Include <stdlib.h> and <string.h> for prototypes.
+ (ac_cv_c_stack_direction): Add missing
+ int return type and parameter list to the definitions of
+ main, find_stack_direction. Include <stdlib.h> for exit
+ prototype.
+ * configure: Regenerate.
+
+--- a/libiberty/aclocal.m4
++++ b/libiberty/aclocal.m4
+@@ -16,6 +16,8 @@ AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works,
+ [AC_TRY_RUN([
+ /* Test by Jim Wilson and Kaveh Ghazi.
+ Check whether strncmp reads past the end of its string parameters. */
++#include <stdlib.h>
++#include <string.h>
+ #include <sys/types.h>
+
+ #ifdef HAVE_FCNTL_H
+@@ -43,7 +45,8 @@ AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works,
+
+ #define MAP_LEN 0x10000
+
+-main ()
++int
++main (void)
+ {
+ #if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE)
+ char *p;
+@@ -149,7 +152,10 @@ if test $ac_cv_os_cray = yes; then
+ fi
+
+ AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction,
+-[AC_TRY_RUN([find_stack_direction ()
++[AC_TRY_RUN([#include <stdlib.h>
++
++int
++find_stack_direction (void)
+ {
+ static char *addr = 0;
+ auto char dummy;
+@@ -161,7 +167,9 @@ AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction,
+ else
+ return (&dummy > addr) ? 1 : -1;
+ }
+-main ()
++
++int
++main (void)
+ {
+ exit (find_stack_direction() < 0);
+ }],
+--- a/libiberty/configure
++++ b/libiberty/configure
+@@ -6718,7 +6718,10 @@ else
+ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+-find_stack_direction ()
++#include <stdlib.h>
++
++int
++find_stack_direction (void)
+ {
+ static char *addr = 0;
+ auto char dummy;
+@@ -6730,7 +6733,9 @@ find_stack_direction ()
+ else
+ return (&dummy > addr) ? 1 : -1;
+ }
+-main ()
++
++int
++main (void)
+ {
+ exit (find_stack_direction() < 0);
+ }
+@@ -7555,6 +7560,8 @@ else
+
+ /* Test by Jim Wilson and Kaveh Ghazi.
+ Check whether strncmp reads past the end of its string parameters. */
++#include <stdlib.h>
++#include <string.h>
+ #include <sys/types.h>
+
+ #ifdef HAVE_FCNTL_H
+@@ -7582,7 +7589,8 @@ else
+
+ #define MAP_LEN 0x10000
+
+-main ()
++int
++main (void)
+ {
+ #if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE)
+ char *p;
+--- a/libsanitizer/configure
++++ b/libsanitizer/configure
+@@ -16029,6 +16029,7 @@ case "$target" in
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+ #include <sys/syscall.h>
++#include <unistd.h>
+ int
+ main ()
+ {
+--- a/libsanitizer/configure.ac
++++ b/libsanitizer/configure.ac
+@@ -155,7 +155,8 @@ case "$target" in
+ *-*-linux*)
+ # Some old Linux distributions miss required syscalls.
+ sanitizer_supported=no
+- AC_TRY_COMPILE([#include <sys/syscall.h>],[
++ AC_TRY_COMPILE([#include <sys/syscall.h>
++#include <unistd.h>],[
+ syscall (__NR_gettid);
+ syscall (__NR_futex);
+ syscall (__NR_exit_group);
diff --git a/10.5.0/gentoo/77_all_all_PR109585_13_rtl-alias-analysis-typo.patch b/10.5.0/gentoo/77_all_all_PR109585_13_rtl-alias-analysis-typo.patch
new file mode 100644
index 0000000..b7b57d6
--- /dev/null
+++ b/10.5.0/gentoo/77_all_all_PR109585_13_rtl-alias-analysis-typo.patch
@@ -0,0 +1,79 @@
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109609
+https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=ef6051b36241bf130bf76af0b775248635dc616e
+
+From ef6051b36241bf130bf76af0b775248635dc616e Mon Sep 17 00:00:00 2001
+From: Richard Biener <rguenther@suse.de>
+Date: Mon, 24 Apr 2023 13:31:07 +0200
+Subject: [PATCH] rtl-optimization/109585 - alias analysis typo
+
+When r10-514-gc6b84edb6110dd2b4fb improved access path analysis
+it introduced a typo that triggers when there's an access to a
+trailing array in the first access path leading to false
+disambiguation.
+
+ PR rtl-optimization/109585
+ * tree-ssa-alias.c (aliasing_component_refs_p): Fix typo.
+
+ * gcc.dg/torture/pr109585.c: New testcase.
+
+(cherry picked from commit 6d4bd27a60447c7505cb4783e675e98a191a8904)
+---
+ gcc/testsuite/gcc.dg/torture/pr109585.c | 33 +++++++++++++++++++++++++
+ gcc/tree-ssa-alias.c | 2 +-
+ 2 files changed, 34 insertions(+), 1 deletion(-)
+ create mode 100644 gcc/testsuite/gcc.dg/torture/pr109585.c
+
+diff --git a/gcc/testsuite/gcc.dg/torture/pr109585.c b/gcc/testsuite/gcc.dg/torture/pr109585.c
+new file mode 100644
+index 00000000000..f92de7c1f2e
+--- /dev/null
++++ b/gcc/testsuite/gcc.dg/torture/pr109585.c
+@@ -0,0 +1,33 @@
++/* { dg-do run } */
++
++#include <stdlib.h>
++
++struct P {
++ long v;
++ struct P *n;
++};
++
++struct F {
++ long x;
++ struct P fam[];
++};
++
++int __attribute__((noipa))
++f(struct F *f, int i)
++{
++ struct P *p = f->fam;
++ asm("" : "+r"(f): "r"(p));
++ p->v = 0;
++ p->n = 0;
++ return f->fam->n != 0;
++}
++
++int
++main()
++{
++ struct F *m = malloc (sizeof (long) + 2 * sizeof (struct P));
++ m->fam[0].n = &m->fam[1];
++ if (f (m, 0))
++ abort ();
++ return 0;
++}
+diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
+index b1e7a2d5afc..be7b597266f 100644
+--- a/gcc/tree-ssa-alias.c
++++ b/gcc/tree-ssa-alias.c
+@@ -1326,7 +1326,7 @@ aliasing_component_refs_p (tree ref1,
+ /* If we didn't find a common base, try the other way around. */
+ if (cmp_outer <= 0
+ || (end_struct_ref1
+- && compare_type_sizes (TREE_TYPE (end_struct_ref1), type1) <= 0))
++ && compare_type_sizes (TREE_TYPE (end_struct_ref1), type2) <= 0))
+ {
+ int res = aliasing_component_refs_walk (ref2, type2, base2,
+ offset2, max_size2,
+--
+2.31.1
diff --git a/10.5.0/gentoo/README.history b/10.5.0/gentoo/README.history
new file mode 100644
index 0000000..f848c9c
--- /dev/null
+++ b/10.5.0/gentoo/README.history
@@ -0,0 +1,54 @@
+6 28 Apr 2023
+ + 77_all_all_PR109585_13_rtl-alias-analysis-typo.patch
+
+5 27 Jan 2023
+ - 77_all_driver_environ_putenv_PR106624.patch
+
+4 23 Jan 2023
+ + 77_all_driver_environ_putenv_PR106624.patch
+
+3 17 Dec 2022
+ U 35_all_tar_libstdc++-link.patch
+
+2 17 Dec 2022
+ + 35_all_tar_libstdc++-link.patch
+
+1 19 Nov 2022
+ + 76_all_configure-c89.patch
+
+0 22 Aug 2022
+ + 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
+ + 07_all_i386_libgcc_note.GNU-stack.patch
+ + 08_all_libiberty-asprintf.patch
+ + 09_all_libiberty-pic.patch
+ + 10_all_nopie-all-flags.patch
+ + 11_all_sh-drop-sysroot-suffix.patch
+ + 12_all_ia64-TEXTREL.patch
+ + 13_all_disable-systemtap-switch.patch
+ + 14_all_m68k-textrel-on-libgcc.patch
+ + 15_all_respect-build-cxxflags.patch
+ + 16_all_libgfortran-Werror.patch
+ + 17_all_libgomp-Werror.patch
+ + 18_all_libitm-Werror.patch
+ + 19_all_libatomic-Werror.patch
+ + 20_all_libbacktrace-Werror.patch
+ + 21_all_libsanitizer-Werror.patch
+ + 22_all_libstdcxx-no-vtv.patch
+ + 23_all_disable-riscv32-ABIs.patch
+ + 24_all_default_ssp-buffer-size.patch
+ + 25_all_hppa-faster-synth_mult.patch
+ + 26_all_libcpp-ar.patch
+ + 27_all_EXTRA_OPTIONS-z-now.patch
+ + 28_all_EXTRA_OPTIONS-fstack-clash-protection.patch
+ + 29_all_lto-intl-workaround-PR95194.patch
+ + 30_all_plugin-objdump.patch
+ + 31_all_fno-delayed-branch.patch
+ + 32_all_vtv-slibtool.patch
+ + 33_all_msgfmt-libstdc++-link.patch
+ + 34_all_drop_CFLAGS_sed.patch
+ + 75_all_d_compiler_for_build_pie.patch
diff --git a/10.5.0/musl/25_all_multilib_pure64.patch b/10.5.0/musl/25_all_multilib_pure64.patch
new file mode 100644
index 0000000..2442652
--- /dev/null
+++ b/10.5.0/musl/25_all_multilib_pure64.patch
@@ -0,0 +1,80 @@
+--- a/gcc/config/aarch64/t-aarch64-linux
++++ b/gcc/config/aarch64/t-aarch64-linux
+@@ -22,7 +22,7 @@
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+--- a/gcc/config/i386/t-linux64
++++ b/gcc/config/i386/t-linux64
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
+-MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
++MULTILIB_OSDIRNAMES+= mx32=../libx32
+--- a/gcc/config/rs6000/t-linux
++++ b/gcc/config/rs6000/t-linux
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+
+--- a/gcc/config/rs6000/t-linux64
++++ b/gcc/config/rs6000/t-linux64
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS := m64/m32
+ MULTILIB_DIRNAMES := 64 32
+ MULTILIB_EXTRA_OPTS :=
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ $(COMPILE) $<
+--- a/gcc/config/rs6000/t-linux64bele
++++ b/gcc/config/rs6000/t-linux64bele
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mlittle
+ MULTILIB_DIRNAMES += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/rs6000/t-linux64lebe
++++ b/gcc/config/rs6000/t-linux64lebe
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mbig
+ MULTILIB_DIRNAMES += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
diff --git a/10.5.0/musl/50_all_cpu_indicator.patch b/10.5.0/musl/50_all_cpu_indicator.patch
new file mode 100644
index 0000000..060b322
--- /dev/null
+++ b/10.5.0/musl/50_all_cpu_indicator.patch
@@ -0,0 +1,37 @@
+From d16a8ceb1c3c8a7ec381090b4c316ff4c55661c0 Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 7 May 2020 21:14:11 -0500
+Subject: [PATCH] convert "__cpu_indicator_init" to
+ "__cpu_indicator_init_local"
+
+--- a/gcc/config/i386/i386-expand.c
++++ b/gcc/config/i386/i386-expand.c
+@@ -10941,10 +10941,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
+ {
+ case IX86_BUILTIN_CPU_INIT:
+ {
+- /* Make it call __cpu_indicator_init in libgcc. */
++ /* Make it call __cpu_indicator_init_local in libgcc. */
+ tree call_expr, fndecl, type;
+ type = build_function_type_list (integer_type_node, NULL_TREE);
+- fndecl = build_fn_decl ("__cpu_indicator_init", type);
++ fndecl = build_fn_decl ("__cpu_indicator_init_local", type);
+ call_expr = build_call_expr (fndecl, 0);
+ return expand_expr (call_expr, target, mode, EXPAND_NORMAL);
+ }
+--- a/libgcc/config/i386/cpuinfo.c
++++ b/libgcc/config/i386/cpuinfo.c
+@@ -508,7 +508,7 @@ __cpu_indicator_init (void)
+ return 0;
+ }
+
+-#if defined SHARED && defined USE_ELF_SYMVER
+-__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0");
+-__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0");
++#ifndef SHARED
++int __cpu_indicator_init_local (void)
++ __attribute__ ((weak, alias ("__cpu_indicator_init")));
+ #endif
+--
+2.26.2
+
diff --git a/10.5.0/musl/50_all_libssp_unconditionally.patch b/10.5.0/musl/50_all_libssp_unconditionally.patch
new file mode 100644
index 0000000..42796f2
--- /dev/null
+++ b/10.5.0/musl/50_all_libssp_unconditionally.patch
@@ -0,0 +1,24 @@
+https://bugs.gentoo.org/706210
+https://bugs.gentoo.org/747346
+
+Author: Timo Teräs <timo.teras@iki.fi>
+
+"Alpine musl package provides libssp_nonshared.a. We link to it unconditionally,
+as otherwise we get link failures if some objects are -fstack-protector built
+and final link happens with -fno-stack-protector. This seems to be the common
+case when bootstrapping gcc, the piepatches do not seem to fully fix the
+crosstoolchain and bootstrap sequence wrt. stack-protector flag usage."
+
+(We do the same in Gentoo.)
+--- a/gcc/gcc.c.orig
++++ b/gcc/gcc.c
+@@ -870,8 +870,7 @@
+
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+- "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ "|fstack-protector-strong|fstack-protector-explicit" \
diff --git a/10.5.0/musl/50_all_posix_memalign.patch b/10.5.0/musl/50_all_posix_memalign.patch
new file mode 100644
index 0000000..dd75a93
--- /dev/null
+++ b/10.5.0/musl/50_all_posix_memalign.patch
@@ -0,0 +1,28 @@
+--- a/gcc/config/i386/pmm_malloc.h
++++ b/gcc/config/i386/pmm_malloc.h
+@@ -27,12 +27,13 @@
+ #include <stdlib.h>
+
+ /* We can't depend on <stdlib.h> since the prototype of posix_memalign
+- may not be visible. */
++ may not be visible and we can't pollute the namespace either. */
+ #ifndef __cplusplus
+-extern int posix_memalign (void **, size_t, size_t);
++extern int __gcc_posix_memalign (void **, size_t, size_t)
+ #else
+-extern "C" int posix_memalign (void **, size_t, size_t) throw ();
++extern "C" int __gcc_posix_memalign (void **, size_t, size_t) throw ()
+ #endif
++__asm__("posix_memalign");
+
+ static __inline void *
+ _mm_malloc (size_t __size, size_t __alignment)
+@@ -42,7 +43,7 @@
+ return malloc (__size);
+ if (__alignment == 2 || (sizeof (void *) == 8 && __alignment == 4))
+ __alignment = sizeof (void *);
+- if (posix_memalign (&__ptr, __alignment, __size) == 0)
++ if (__gcc_posix_memalign (&__ptr, __alignment, __size) == 0)
+ return __ptr;
+ else
+ return NULL;
diff --git a/11.2.0/musl/25_all_multilib_pure64.patch b/11.2.0/musl/25_all_multilib_pure64.patch
new file mode 100644
index 0000000..4ff0a25
--- /dev/null
+++ b/11.2.0/musl/25_all_multilib_pure64.patch
@@ -0,0 +1,89 @@
+https://bugs.gentoo.org/675954
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90077
+
+diff -Naur gcc-9.3.0.orig/gcc/config/aarch64/t-aarch64-linux gcc-9.3.0/gcc/config/aarch64/t-aarch64-linux
+--- gcc-9.3.0.orig/gcc/config/aarch64/t-aarch64-linux 2020-10-05 02:59:12.767988285 -0700
++++ gcc-9.3.0/gcc/config/aarch64/t-aarch64-linux 2020-10-05 03:03:32.310816444 -0700
+@@ -22,7 +22,7 @@
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+diff -Naur gcc-9.3.0.orig/gcc/config/i386/t-linux64 gcc-9.3.0/gcc/config/i386/t-linux64
+--- gcc-9.3.0.orig/gcc/config/i386/t-linux64 2020-10-05 02:59:12.757989347 -0700
++++ gcc-9.3.0/gcc/config/i386/t-linux64 2020-10-05 03:24:58.878825272 -0700
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
+-MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
++MULTILIB_OSDIRNAMES+= mx32=../libx32
+diff -Naur gcc-9.3.0.orig/gcc/config/rs6000/t-linux gcc-9.3.0/gcc/config/rs6000/t-linux
+--- gcc-9.3.0.orig/gcc/config/rs6000/t-linux 2020-10-05 02:59:12.767988285 -0700
++++ gcc-9.3.0/gcc/config/rs6000/t-linux 2020-10-05 03:03:32.310816444 -0700
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+
+diff -Naur gcc-9.3.0.orig/gcc/config/rs6000/t-linux64 gcc-9.3.0/gcc/config/rs6000/t-linux64
+--- gcc-9.3.0.orig/gcc/config/rs6000/t-linux64 2020-10-05 02:59:12.767988285 -0700
++++ gcc-9.3.0/gcc/config/rs6000/t-linux64 2020-10-05 03:03:32.310816444 -0700
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS := m64/m32
+ MULTILIB_DIRNAMES := 64 32
+ MULTILIB_EXTRA_OPTS :=
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ $(COMPILE) $<
+diff -Naur gcc-9.3.0.orig/gcc/config/rs6000/t-linux64bele gcc-9.3.0/gcc/config/rs6000/t-linux64bele
+--- gcc-9.3.0.orig/gcc/config/rs6000/t-linux64bele 2020-10-05 02:59:12.767988285 -0700
++++ gcc-9.3.0/gcc/config/rs6000/t-linux64bele 2020-10-05 03:03:32.310816444 -0700
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mlittle
+ MULTILIB_DIRNAMES += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
+diff -Naur gcc-9.3.0.orig/gcc/config/rs6000/t-linux64lebe gcc-9.3.0/gcc/config/rs6000/t-linux64lebe
+--- gcc-9.3.0.orig/gcc/config/rs6000/t-linux64lebe 2020-10-05 02:59:12.777987222 -0700
++++ gcc-9.3.0/gcc/config/rs6000/t-linux64lebe 2020-10-05 03:03:32.310816444 -0700
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mbig
+ MULTILIB_DIRNAMES += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
diff --git a/11.2.0/musl/50_all_cpu_indicator.patch b/11.2.0/musl/50_all_cpu_indicator.patch
new file mode 100644
index 0000000..6141a83
--- /dev/null
+++ b/11.2.0/musl/50_all_cpu_indicator.patch
@@ -0,0 +1,46 @@
+From d16a8ceb1c3c8a7ec381090b4c316ff4c55661c0 Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 7 May 2020 21:14:11 -0500
+Subject: [PATCH] convert "__cpu_indicator_init" to
+ "__cpu_indicator_init_local"
+
+---
+ gcc/config/i386/i386-expand.c | 4 ++--
+ libgcc/config/i386/cpuinfo.c | 6 +++---
+ 2 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c
+index 48f00c5fc..78650b202 100644
+--- a/gcc/config/i386/i386-expand.c
++++ b/gcc/config/i386/i386-expand.c
+@@ -10941,10 +10941,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
+ {
+ case IX86_BUILTIN_CPU_INIT:
+ {
+- /* Make it call __cpu_indicator_init in libgcc. */
++ /* Make it call __cpu_indicator_init_local in libgcc. */
+ tree call_expr, fndecl, type;
+ type = build_function_type_list (integer_type_node, NULL_TREE);
+- fndecl = build_fn_decl ("__cpu_indicator_init", type);
++ fndecl = build_fn_decl ("__cpu_indicator_init_local", type);
+ call_expr = build_call_expr (fndecl, 0);
+ return expand_expr (call_expr, target, mode, EXPAND_NORMAL);
+ }
+diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c
+index 00322c586..f42bbb8af 100644
+--- a/libgcc/config/i386/cpuinfo.c
++++ b/libgcc/config/i386/cpuinfo.c
+@@ -508,7 +508,7 @@ __cpu_indicator_init (void)
+ return 0;
+ }
+
+-#if defined SHARED && defined USE_ELF_SYMVER
+-__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0");
+-__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0");
++#ifndef SHARED
++int __cpu_indicator_init_local (void)
++ __attribute__ ((weak, alias ("__cpu_indicator_init")));
+ #endif
+--
+2.26.2
+
diff --git a/11.2.0/musl/50_all_posix_memalign.patch b/11.2.0/musl/50_all_posix_memalign.patch
new file mode 100644
index 0000000..a288e1d
--- /dev/null
+++ b/11.2.0/musl/50_all_posix_memalign.patch
@@ -0,0 +1,29 @@
+diff -Naur gcc-7.1.0.orig/gcc/config/i386/pmm_malloc.h gcc-7.1.0/gcc/config/i386/pmm_malloc.h
+--- gcc-7.1.0.orig/gcc/config/i386/pmm_malloc.h 2017-01-01 04:07:43.000000000 -0800
++++ gcc-7.1.0/gcc/config/i386/pmm_malloc.h 2017-05-07 11:35:22.878398460 -0700
+@@ -27,12 +27,13 @@
+ #include <stdlib.h>
+
+ /* We can't depend on <stdlib.h> since the prototype of posix_memalign
+- may not be visible. */
++ may not be visible and we can't pollute the namespace either. */
+ #ifndef __cplusplus
+-extern int posix_memalign (void **, size_t, size_t);
++extern int __gcc_posix_memalign (void **, size_t, size_t)
+ #else
+-extern "C" int posix_memalign (void **, size_t, size_t) throw ();
++extern "C" int __gcc_posix_memalign (void **, size_t, size_t) throw ()
+ #endif
++__asm__("posix_memalign");
+
+ static __inline void *
+ _mm_malloc (size_t __size, size_t __alignment)
+@@ -42,7 +43,7 @@
+ return malloc (__size);
+ if (__alignment == 2 || (sizeof (void *) == 8 && __alignment == 4))
+ __alignment = sizeof (void *);
+- if (posix_memalign (&__ptr, __alignment, __size) == 0)
++ if (__gcc_posix_memalign (&__ptr, __alignment, __size) == 0)
+ return __ptr;
+ else
+ return NULL;
diff --git a/11.2.0/musl/nocross/50_all_libssp_unconditionally.patch b/11.2.0/musl/nocross/50_all_libssp_unconditionally.patch
new file mode 100644
index 0000000..7e4c58a
--- /dev/null
+++ b/11.2.0/musl/nocross/50_all_libssp_unconditionally.patch
@@ -0,0 +1,24 @@
+https://bugs.gentoo.org/706210
+https://bugs.gentoo.org/747346
+
+Author: Timo Teräs <timo.teras@iki.fi>
+
+"Alpine musl package provides libssp_nonshared.a. We link to it unconditionally,
+as otherwise we get link failures if some objects are -fstack-protector built
+and final link happens with -fno-stack-protector. This seems to be the common
+case when bootstrapping gcc, the piepatches do not seem to fully fix the
+crosstoolchain and bootstrap sequence wrt. stack-protector flag usage."
+
+(We do the same in Gentoo.)
+--- gcc-6.1.0/gcc/gcc.c.orig
++++ gcc-6.1.0/gcc/gcc.c
+@@ -870,8 +870,7 @@
+
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+- "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ "|fstack-protector-strong|fstack-protector-explicit" \
diff --git a/11.3.0/gentoo/26_all_enable-cet.patch b/11.3.0/gentoo/26_all_enable-cet.patch
index 77678a9..38bb34a 100644
--- a/11.3.0/gentoo/26_all_enable-cet.patch
+++ b/11.3.0/gentoo/26_all_enable-cet.patch
@@ -1,53 +1,35 @@
-From c1f37f6e3a4fcdefb6b3dfc3d84fc42920a70c00 Mon Sep 17 00:00:00 2001
+From 83efc6ce009021f27b602c1dfcf65338f761b095 Mon Sep 17 00:00:00 2001
From: Sam James <sam@gentoo.org>
-Date: Sat, 27 Nov 2021 19:16:02 +0000
+Date: Tue, 28 Dec 2021 03:42:53 +0000
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)
- for now to avoid accidentally enabling it on other arches.
+- -DEXTRA_OPTIONS_CF to be passed during build (via toolchain.eclass).
Only supported on amd64.
+
---
- gcc/common.opt | 2 +-
- gcc/config/i386/i386-options.c | 5 +++++
+ gcc/config/i386/i386-options.c | 3 +++
gcc/defaults.h | 13 +++++++++++++
- gcc/flag-types.h | 1 +
- gcc/toplev.c | 4 +++-
- 5 files changed, 23 insertions(+), 2 deletions(-)
+ 2 files changed, 16 insertions(+)
-diff --git a/gcc/common.opt b/gcc/common.opt
-index a88778b4e..4993a7ec3 100644
---- a/gcc/common.opt
-+++ b/gcc/common.opt
-@@ -1783,7 +1783,7 @@ fcf-protection
- Common RejectNegative Alias(fcf-protection=,full)
-
- fcf-protection=
--Common Joined RejectNegative Enum(cf_protection_level) Var(flag_cf_protection) Init(CF_NONE)
-+Common Joined RejectNegative Enum(cf_protection_level) Var(flag_cf_protection) Init(CF_UNSET)
- -fcf-protection=[full|branch|return|none|check] Instrument functions with checks to verify jump/call/return control-flow transfer
- instructions have valid targets.
-
diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c
-index 18d2c0b9f..4fb76f2a1 100644
+index 19632b5..fac61af 100644
--- a/gcc/config/i386/i386-options.c
+++ b/gcc/config/i386/i386-options.c
-@@ -3037,6 +3037,11 @@ ix86_option_override_internal (bool main_args_p,
+@@ -3049,6 +3049,9 @@ ix86_option_override_internal (bool main_args_p,
= build_target_option_node (opts, opts_set);
}
-+ if (flag_cf_protection == CF_UNSET)
-+ {
-+ flag_cf_protection = DEFAULT_FLAG_CF;
-+ }
++ if (TARGET_64BIT && TARGET_CMOV)
++ SET_OPTION_IF_UNSET (opts, opts_set, flag_cf_protection, DEFAULT_FLAG_CF);
+
if (opts->x_flag_cf_protection != CF_NONE)
{
if ((opts->x_flag_cf_protection & CF_BRANCH) == CF_BRANCH
diff --git a/gcc/defaults.h b/gcc/defaults.h
-index 0f6cd78c5..5694412b7 100644
+index 0f6cd78..5694412 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -1463,6 +1463,19 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
@@ -70,32 +52,6 @@ index 0f6cd78c5..5694412b7 100644
/* 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
-diff --git a/gcc/flag-types.h b/gcc/flag-types.h
-index a038c8fb7..61be0b128 100644
---- a/gcc/flag-types.h
-+++ b/gcc/flag-types.h
-@@ -389,6 +389,7 @@ enum gfc_convert
- /* Control-Flow Protection values. */
- enum cf_protection_level
- {
-+ CF_UNSET = -1,
- CF_NONE = 0,
- CF_BRANCH = 1 << 0,
- CF_RETURN = 1 << 1,
-diff --git a/gcc/toplev.c b/gcc/toplev.c
-index ea0a2a1b0..d110c84ee 100644
---- a/gcc/toplev.c
-+++ b/gcc/toplev.c
-@@ -1297,7 +1297,9 @@ process_options (void)
- "%<-floop-nest-optimize%>, %<-floop-parallelize-all%>)");
- #endif
-
-- if (flag_cf_protection != CF_NONE
-+ /* Gentoo: we add CF_UNSET here just to be safe, but we only patch the default
-+ for amd64 + when CET is definitely enabled anyway. */
-+ if ((flag_cf_protection != CF_NONE) && (flag_cf_protection != CF_UNSET)
- && !(flag_cf_protection & CF_SET))
- {
- if (flag_cf_protection == CF_FULL)
--
2.34.1
+
diff --git a/11.3.0/gentoo/27_all_msgfmt-libstdc++-link.patch b/11.3.0/gentoo/27_all_msgfmt-libstdc++-link.patch
new file mode 100644
index 0000000..0d2f113
--- /dev/null
+++ b/11.3.0/gentoo/27_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/11.3.0/gentoo/28_all_drop_CFLAGS_sed.patch b/11.3.0/gentoo/28_all_drop_CFLAGS_sed.patch
new file mode 100644
index 0000000..0a9fa13
--- /dev/null
+++ b/11.3.0/gentoo/28_all_drop_CFLAGS_sed.patch
@@ -0,0 +1,35 @@
+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
+@@ -5265,13 +5265,6 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
+ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+-# Remove the -O2: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[ ]//" -e "s/-O[gs][ ]//" -e "s/-O[0-9]*[ ]//" `
+- CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[ ]//" -e "s/-O[gs][ ]//" -e "s/-O[0-9]*[ ]//" ` ;;
+-esac
+
+
+
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -439,13 +439,6 @@ ACX_PROG_GNAT([-I"$srcdir"/ada/libgnat])
+ # Do configure tests with the C++ compiler, since that's what we build with.
+ AC_LANG(C++)
+
+-# Remove the -O2: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" `
+- CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" ` ;;
+-esac
+ AC_SUBST(CFLAGS)
+ AC_SUBST(CXXFLAGS)
+
diff --git a/11.3.0/gentoo/75_all_x86_PR99703_12_no-cet-for-i486.patch b/11.3.0/gentoo/75_all_x86_PR99703_12_no-cet-for-i486.patch
new file mode 100644
index 0000000..5d3afc1
--- /dev/null
+++ b/11.3.0/gentoo/75_all_x86_PR99703_12_no-cet-for-i486.patch
@@ -0,0 +1,389 @@
+https://bugs.gentoo.org/777117
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99703
+
+From: "H.J. Lu" <hjl.tools@gmail.com>
+Date: Fri, 12 Feb 2021 16:30:23 -0800
+Subject: GCC_CET_HOST_FLAGS: Check if host supports multi-byte NOPs
+
+Backport of fd7eb4bc94cafa745eba75c64fa483a1689a5aad to GCC 11
+
+Sync with binutils for PR binutils/27397. Check if host supports
+multi-byte NOPs before enabling CET on host.
+
+config/
+
+ PR bootstrap/99703
+ * cet.m4 (GCC_CET_HOST_FLAGS): Check if host supports multi-byte
+ NOPs.
+
+All applicable configure scripts have been regenerated. Patch hunks
+which only updated line numbers have been excluded to reduce conflicts.
+
+diff --git a/config/cet.m4 b/config/cet.m4
+index c67fb4f35b6..7718be1afe8 100644
+--- a/config/cet.m4
++++ b/config/cet.m4
+@@ -130,6 +130,18 @@ fi
+ if test x$may_have_cet = xyes; then
+ if test x$cross_compiling = xno; then
+ AC_TRY_RUN([
++int
++main ()
++{
++ asm ("endbr32");
++ return 0;
++}
++ ],
++ [have_multi_byte_nop=yes],
++ [have_multi_byte_nop=no])
++ have_cet=no
++ if test x$have_multi_byte_nop = xyes; then
++ AC_TRY_RUN([
+ static void
+ foo (void)
+ {
+@@ -155,9 +167,10 @@ main ()
+ bar ();
+ return 0;
+ }
+- ],
+- [have_cet=no],
+- [have_cet=yes])
++ ],
++ [have_cet=no],
++ [have_cet=yes])
++ fi
+ if test x$enable_cet = xno -a x$have_cet = xyes; then
+ AC_MSG_ERROR([Intel CET must be enabled on Intel CET enabled host])
+ fi
+diff --git a/gcc/configure b/gcc/configure
+index 708328e1670..e6e4d9e270e 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -32416,6 +32416,34 @@ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
++int
++main ()
++{
++ asm ("endbr32");
++ return 0;
++}
++
++_ACEOF
++if ac_fn_cxx_try_run "$LINENO"; then :
++ have_multi_byte_nop=yes
++else
++ have_multi_byte_nop=no
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++ conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++ have_cet=no
++ if test x$have_multi_byte_nop = xyes; then
++ if test "$cross_compiling" = yes; then :
++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++as_fn_error $? "cannot run test program while cross compiling
++See \`config.log' for more details" "$LINENO" 5; }
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
+ static void
+ foo (void)
+ {
+@@ -32452,6 +32480,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+ fi
+
++ fi
+ if test x$enable_cet = xno -a x$have_cet = xyes; then
+ as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5
+ fi
+diff --git a/libbacktrace/configure b/libbacktrace/configure
+index 9b66bf5563a..a2f33c0f35d 100755
+--- a/libbacktrace/configure
++++ b/libbacktrace/configure
+@@ -12517,6 +12517,34 @@ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
++int
++main ()
++{
++ asm ("endbr32");
++ return 0;
++}
++
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++ have_multi_byte_nop=yes
++else
++ have_multi_byte_nop=no
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++ conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++ have_cet=no
++ if test x$have_multi_byte_nop = xyes; then
++ if test "$cross_compiling" = yes; then :
++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++as_fn_error $? "cannot run test program while cross compiling
++See \`config.log' for more details" "$LINENO" 5; }
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
+ static void
+ foo (void)
+ {
+@@ -12553,6 +12581,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+ fi
+
++ fi
+ if test x$enable_cet = xno -a x$have_cet = xyes; then
+ as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5
+ fi
+diff --git a/libcc1/configure b/libcc1/configure
+index 600e41cf5ea..b198b0b9074 100755
+--- a/libcc1/configure
++++ b/libcc1/configure
+@@ -14653,6 +14653,34 @@ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
++int
++main ()
++{
++ asm ("endbr32");
++ return 0;
++}
++
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++ have_multi_byte_nop=yes
++else
++ have_multi_byte_nop=no
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++ conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++ have_cet=no
++ if test x$have_multi_byte_nop = xyes; then
++ if test "$cross_compiling" = yes; then :
++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++as_fn_error $? "cannot run test program while cross compiling
++See \`config.log' for more details" "$LINENO" 5; }
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
+ static void
+ foo (void)
+ {
+@@ -14689,6 +14717,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+ fi
+
++ fi
+ if test x$enable_cet = xno -a x$have_cet = xyes; then
+ as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5
+ fi
+diff --git a/libcpp/configure b/libcpp/configure
+index 7e28606f605..9674cd9c7a7 100755
+--- a/libcpp/configure
++++ b/libcpp/configure
+@@ -7668,6 +7668,34 @@ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
++int
++main ()
++{
++ asm ("endbr32");
++ return 0;
++}
++
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++ have_multi_byte_nop=yes
++else
++ have_multi_byte_nop=no
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++ conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++ have_cet=no
++ if test x$have_multi_byte_nop = xyes; then
++ if test "$cross_compiling" = yes; then :
++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++as_fn_error $? "cannot run test program while cross compiling
++See \`config.log' for more details" "$LINENO" 5; }
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
+ static void
+ foo (void)
+ {
+@@ -7704,6 +7732,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+ fi
+
++ fi
+ if test x$enable_cet = xno -a x$have_cet = xyes; then
+ as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5
+ fi
+diff --git a/libdecnumber/configure b/libdecnumber/configure
+index 6b62f8ba665..da5302f9315 100755
+--- a/libdecnumber/configure
++++ b/libdecnumber/configure
+@@ -5321,6 +5321,34 @@ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
++int
++main ()
++{
++ asm ("endbr32");
++ return 0;
++}
++
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++ have_multi_byte_nop=yes
++else
++ have_multi_byte_nop=no
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++ conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++ have_cet=no
++ if test x$have_multi_byte_nop = xyes; then
++ if test "$cross_compiling" = yes; then :
++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++as_fn_error $? "cannot run test program while cross compiling
++See \`config.log' for more details" "$LINENO" 5; }
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
+ static void
+ foo (void)
+ {
+@@ -5357,6 +5385,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+ fi
+
++ fi
+ if test x$enable_cet = xno -a x$have_cet = xyes; then
+ as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5
+ fi
+diff --git a/libiberty/configure b/libiberty/configure
+index 61c62a33b3a..14a555c4ed6 100755
+--- a/libiberty/configure
++++ b/libiberty/configure
+@@ -5396,6 +5396,34 @@ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
++int
++main ()
++{
++ asm ("endbr32");
++ return 0;
++}
++
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++ have_multi_byte_nop=yes
++else
++ have_multi_byte_nop=no
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++ conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++ have_cet=no
++ if test x$have_multi_byte_nop = xyes; then
++ if test "$cross_compiling" = yes; then :
++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++as_fn_error $? "cannot run test program while cross compiling
++See \`config.log' for more details" "$LINENO" 5; }
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
+ static void
+ foo (void)
+ {
+@@ -5432,6 +5460,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+ fi
+
++ fi
+ if test x$enable_cet = xno -a x$have_cet = xyes; then
+ as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5
+ fi
+diff --git a/lto-plugin/configure b/lto-plugin/configure
+index 22a4357a58e..26aad9dd699 100755
+--- a/lto-plugin/configure
++++ b/lto-plugin/configure
+@@ -5791,6 +5791,34 @@ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
++int
++main ()
++{
++ asm ("endbr32");
++ return 0;
++}
++
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++ have_multi_byte_nop=yes
++else
++ have_multi_byte_nop=no
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++ conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++ have_cet=no
++ if test x$have_multi_byte_nop = xyes; then
++ if test "$cross_compiling" = yes; then :
++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++as_fn_error $? "cannot run test program while cross compiling
++See \`config.log' for more details" "$LINENO" 5; }
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
+ static void
+ foo (void)
+ {
+@@ -5827,6 +5855,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+ fi
+
++ fi
+ if test x$enable_cet = xno -a x$have_cet = xyes; then
+ as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5
+ fi
+--
+2.34.1
diff --git a/11.3.0/gentoo/76_all_all_PR103910_12_ICE-on-PCH.patch b/11.3.0/gentoo/76_all_all_PR103910_12_ICE-on-PCH.patch
new file mode 100644
index 0000000..358b9b3
--- /dev/null
+++ b/11.3.0/gentoo/76_all_all_PR103910_12_ICE-on-PCH.patch
@@ -0,0 +1,35 @@
+https://bugs.gentoo.org/822690
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103910
+
+From d243f4009d8071b734df16cd70f4c5d09a373769 Mon Sep 17 00:00:00 2001
+From: Andrew Pinski <apinski@marvell.com>
+Date: Wed, 5 Jan 2022 22:00:07 +0000
+Subject: [PATCH] Fix target/103910: missing GTY on x86_mfence causing PCH
+ usage to ICE
+
+With -O3 -march=opteron, a mfence builtin is added after the loop
+to say the nontemporal stores are no longer needed. This all good
+without precompiled headers as the function decl that is referneced
+by x86_mfence is referenced in another variable but with precompiled
+headers, x86_mfence is all messed up and the decl was GC'ed away.
+This fixes the problem by marking x86_mfence as GTY to save/restore
+during precompiled headers just like most other variables in
+the header file.
+
+Committed as obvious after a bootstrap/test on x86_64-linux-gnu.
+
+gcc/ChangeLog:
+
+ PR target/103910
+ * config/i386/i386.h (x86_mfence): Mark with GTY.
+--- a/gcc/config/i386/i386.h
++++ b/gcc/config/i386/i386.h
+@@ -486,7 +486,7 @@ extern unsigned char ix86_prefetch_sse;
+
+ /* Fence to use after loop using storent. */
+
+-extern tree x86_mfence;
++extern GTY(()) tree x86_mfence;
+ #define FENCE_FOLLOWING_MOVNT x86_mfence
+
+ /* Once GDB has been enhanced to deal with functions without frame
diff --git a/11.3.0/gentoo/77_all_glibc_236.patch b/11.3.0/gentoo/77_all_glibc_236.patch
new file mode 100644
index 0000000..b9704e7
--- /dev/null
+++ b/11.3.0/gentoo/77_all_glibc_236.patch
@@ -0,0 +1,69 @@
+https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=d2356ebb0084a0d80dbfe33040c9afe938c15d19
+https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=a55184ada8e2887ca94c0ab07027617885beafc9
+https://bugs.gentoo.org/865879
+https://bugs.gentoo.org/864717
+
+Fix build w/ glibc 2.36.
+
+From d2356ebb0084a0d80dbfe33040c9afe938c15d19 Mon Sep 17 00:00:00 2001
+From: Martin Liska <mliska@suse.cz>
+Date: Mon, 11 Jul 2022 22:03:14 +0200
+Subject: [PATCH] libsanitizer: cherry-pick 9cf13067cb5088626ba7 from upstream
+
+9cf13067cb5088626ba7ee1ec4c42ec59c7995a0 [sanitizer] Remove #include <linux/fs.h> to resolve fsconfig_command/mount_attr conflict with glibc 2.36
+
+(cherry picked from commit 2701442d0cf6292f6624443c15813d6d1a3562fe)
+--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
+@@ -72,7 +72,9 @@
+ #include <sys/vt.h>
+ #include <linux/cdrom.h>
+ #include <linux/fd.h>
++#if SANITIZER_ANDROID
+ #include <linux/fs.h>
++#endif
+ #include <linux/hdreg.h>
+ #include <linux/input.h>
+ #include <linux/ioctl.h>
+@@ -828,10 +830,10 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+ unsigned IOCTL_EVIOCGPROP = IOCTL_NOT_PRESENT;
+ unsigned IOCTL_EVIOCSKEYCODE_V2 = IOCTL_NOT_PRESENT;
+ #endif
+- unsigned IOCTL_FS_IOC_GETFLAGS = FS_IOC_GETFLAGS;
+- unsigned IOCTL_FS_IOC_GETVERSION = FS_IOC_GETVERSION;
+- unsigned IOCTL_FS_IOC_SETFLAGS = FS_IOC_SETFLAGS;
+- unsigned IOCTL_FS_IOC_SETVERSION = FS_IOC_SETVERSION;
++ unsigned IOCTL_FS_IOC_GETFLAGS = _IOR('f', 1, long);
++ unsigned IOCTL_FS_IOC_GETVERSION = _IOR('v', 1, long);
++ unsigned IOCTL_FS_IOC_SETFLAGS = _IOW('f', 2, long);
++ unsigned IOCTL_FS_IOC_SETVERSION = _IOW('v', 2, long);
+ unsigned IOCTL_GIO_CMAP = GIO_CMAP;
+ unsigned IOCTL_GIO_FONT = GIO_FONT;
+ unsigned IOCTL_GIO_UNIMAP = GIO_UNIMAP;
+
+From a55184ada8e2887ca94c0ab07027617885beafc9 Mon Sep 17 00:00:00 2001
+From: Ian Lance Taylor <iant@golang.org>
+Date: Tue, 12 Jul 2022 19:42:43 -0700
+Subject: [PATCH] libgo: don't include <linux/fs.h> when building
+ gen-sysinfo.go
+
+Removing this doesn't change anything at least with glibc 2.33.
+The include was added in https://go.dev/cl/6100049 but it's not
+clear why.
+
+Fixes PR go/106266
+
+Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/417294
+(cherry picked from commit f35d65517a59565758107c5b1a51a5fa382f8d1a)
+--- a/libgo/sysinfo.c
++++ b/libgo/sysinfo.c
+@@ -158,9 +158,6 @@
+ #if defined(HAVE_LINUX_ETHER_H)
+ #include <linux/ether.h>
+ #endif
+-#if defined(HAVE_LINUX_FS_H)
+-#include <linux/fs.h>
+-#endif
+ #if defined(HAVE_LINUX_REBOOT_H)
+ #include <linux/reboot.h>
+ #endif
diff --git a/11.3.0/gentoo/README.history b/11.3.0/gentoo/README.history
index 2fe9c27..c62f0cb 100644
--- a/11.3.0/gentoo/README.history
+++ b/11.3.0/gentoo/README.history
@@ -1,3 +1,24 @@
+7 22 August 2022
+ + 28_all_drop_CFLAGS_sed.patch
+
+6 22 August 2022
+ + 77_all_glibc_236.patch
+
+5 3 July 2022
+ + 27_all_msgfmt-libstdc++-link.patch
+
+4 8 January 2022
+ + 76_all_all_PR103910_12_ICE-on-PCH.patch
+
+3 28 December 2021
+ U 26_all_enable-cet.patch
+
+2 18 December 2021
+ + 75_all_x86_PR99703_12_no-cet-for-i486.patch
+
+1 7 December 2021
+ U 26_all_enable-cet.patch
+
0 27 November 2021
+ 01_all_default-fortify-source.patch
+ 02_all_default-warn-format-security.patch
diff --git a/11.3.0/musl/25_all_multilib_pure64.patch b/11.3.0/musl/25_all_multilib_pure64.patch
new file mode 100644
index 0000000..4ff0a25
--- /dev/null
+++ b/11.3.0/musl/25_all_multilib_pure64.patch
@@ -0,0 +1,89 @@
+https://bugs.gentoo.org/675954
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90077
+
+diff -Naur gcc-9.3.0.orig/gcc/config/aarch64/t-aarch64-linux gcc-9.3.0/gcc/config/aarch64/t-aarch64-linux
+--- gcc-9.3.0.orig/gcc/config/aarch64/t-aarch64-linux 2020-10-05 02:59:12.767988285 -0700
++++ gcc-9.3.0/gcc/config/aarch64/t-aarch64-linux 2020-10-05 03:03:32.310816444 -0700
+@@ -22,7 +22,7 @@
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+diff -Naur gcc-9.3.0.orig/gcc/config/i386/t-linux64 gcc-9.3.0/gcc/config/i386/t-linux64
+--- gcc-9.3.0.orig/gcc/config/i386/t-linux64 2020-10-05 02:59:12.757989347 -0700
++++ gcc-9.3.0/gcc/config/i386/t-linux64 2020-10-05 03:24:58.878825272 -0700
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
+-MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
++MULTILIB_OSDIRNAMES+= mx32=../libx32
+diff -Naur gcc-9.3.0.orig/gcc/config/rs6000/t-linux gcc-9.3.0/gcc/config/rs6000/t-linux
+--- gcc-9.3.0.orig/gcc/config/rs6000/t-linux 2020-10-05 02:59:12.767988285 -0700
++++ gcc-9.3.0/gcc/config/rs6000/t-linux 2020-10-05 03:03:32.310816444 -0700
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+
+diff -Naur gcc-9.3.0.orig/gcc/config/rs6000/t-linux64 gcc-9.3.0/gcc/config/rs6000/t-linux64
+--- gcc-9.3.0.orig/gcc/config/rs6000/t-linux64 2020-10-05 02:59:12.767988285 -0700
++++ gcc-9.3.0/gcc/config/rs6000/t-linux64 2020-10-05 03:03:32.310816444 -0700
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS := m64/m32
+ MULTILIB_DIRNAMES := 64 32
+ MULTILIB_EXTRA_OPTS :=
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ $(COMPILE) $<
+diff -Naur gcc-9.3.0.orig/gcc/config/rs6000/t-linux64bele gcc-9.3.0/gcc/config/rs6000/t-linux64bele
+--- gcc-9.3.0.orig/gcc/config/rs6000/t-linux64bele 2020-10-05 02:59:12.767988285 -0700
++++ gcc-9.3.0/gcc/config/rs6000/t-linux64bele 2020-10-05 03:03:32.310816444 -0700
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mlittle
+ MULTILIB_DIRNAMES += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
+diff -Naur gcc-9.3.0.orig/gcc/config/rs6000/t-linux64lebe gcc-9.3.0/gcc/config/rs6000/t-linux64lebe
+--- gcc-9.3.0.orig/gcc/config/rs6000/t-linux64lebe 2020-10-05 02:59:12.777987222 -0700
++++ gcc-9.3.0/gcc/config/rs6000/t-linux64lebe 2020-10-05 03:03:32.310816444 -0700
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mbig
+ MULTILIB_DIRNAMES += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
diff --git a/11.3.0/musl/50_all_cpu_indicator.patch b/11.3.0/musl/50_all_cpu_indicator.patch
new file mode 100644
index 0000000..6141a83
--- /dev/null
+++ b/11.3.0/musl/50_all_cpu_indicator.patch
@@ -0,0 +1,46 @@
+From d16a8ceb1c3c8a7ec381090b4c316ff4c55661c0 Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 7 May 2020 21:14:11 -0500
+Subject: [PATCH] convert "__cpu_indicator_init" to
+ "__cpu_indicator_init_local"
+
+---
+ gcc/config/i386/i386-expand.c | 4 ++--
+ libgcc/config/i386/cpuinfo.c | 6 +++---
+ 2 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c
+index 48f00c5fc..78650b202 100644
+--- a/gcc/config/i386/i386-expand.c
++++ b/gcc/config/i386/i386-expand.c
+@@ -10941,10 +10941,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
+ {
+ case IX86_BUILTIN_CPU_INIT:
+ {
+- /* Make it call __cpu_indicator_init in libgcc. */
++ /* Make it call __cpu_indicator_init_local in libgcc. */
+ tree call_expr, fndecl, type;
+ type = build_function_type_list (integer_type_node, NULL_TREE);
+- fndecl = build_fn_decl ("__cpu_indicator_init", type);
++ fndecl = build_fn_decl ("__cpu_indicator_init_local", type);
+ call_expr = build_call_expr (fndecl, 0);
+ return expand_expr (call_expr, target, mode, EXPAND_NORMAL);
+ }
+diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c
+index 00322c586..f42bbb8af 100644
+--- a/libgcc/config/i386/cpuinfo.c
++++ b/libgcc/config/i386/cpuinfo.c
+@@ -508,7 +508,7 @@ __cpu_indicator_init (void)
+ return 0;
+ }
+
+-#if defined SHARED && defined USE_ELF_SYMVER
+-__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0");
+-__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0");
++#ifndef SHARED
++int __cpu_indicator_init_local (void)
++ __attribute__ ((weak, alias ("__cpu_indicator_init")));
+ #endif
+--
+2.26.2
+
diff --git a/11.3.0/musl/50_all_posix_memalign.patch b/11.3.0/musl/50_all_posix_memalign.patch
new file mode 100644
index 0000000..a288e1d
--- /dev/null
+++ b/11.3.0/musl/50_all_posix_memalign.patch
@@ -0,0 +1,29 @@
+diff -Naur gcc-7.1.0.orig/gcc/config/i386/pmm_malloc.h gcc-7.1.0/gcc/config/i386/pmm_malloc.h
+--- gcc-7.1.0.orig/gcc/config/i386/pmm_malloc.h 2017-01-01 04:07:43.000000000 -0800
++++ gcc-7.1.0/gcc/config/i386/pmm_malloc.h 2017-05-07 11:35:22.878398460 -0700
+@@ -27,12 +27,13 @@
+ #include <stdlib.h>
+
+ /* We can't depend on <stdlib.h> since the prototype of posix_memalign
+- may not be visible. */
++ may not be visible and we can't pollute the namespace either. */
+ #ifndef __cplusplus
+-extern int posix_memalign (void **, size_t, size_t);
++extern int __gcc_posix_memalign (void **, size_t, size_t)
+ #else
+-extern "C" int posix_memalign (void **, size_t, size_t) throw ();
++extern "C" int __gcc_posix_memalign (void **, size_t, size_t) throw ()
+ #endif
++__asm__("posix_memalign");
+
+ static __inline void *
+ _mm_malloc (size_t __size, size_t __alignment)
+@@ -42,7 +43,7 @@
+ return malloc (__size);
+ if (__alignment == 2 || (sizeof (void *) == 8 && __alignment == 4))
+ __alignment = sizeof (void *);
+- if (posix_memalign (&__ptr, __alignment, __size) == 0)
++ if (__gcc_posix_memalign (&__ptr, __alignment, __size) == 0)
+ return __ptr;
+ else
+ return NULL;
diff --git a/11.3.0/musl/nocross/50_all_libssp_unconditionally.patch b/11.3.0/musl/nocross/50_all_libssp_unconditionally.patch
new file mode 100644
index 0000000..7e4c58a
--- /dev/null
+++ b/11.3.0/musl/nocross/50_all_libssp_unconditionally.patch
@@ -0,0 +1,24 @@
+https://bugs.gentoo.org/706210
+https://bugs.gentoo.org/747346
+
+Author: Timo Teräs <timo.teras@iki.fi>
+
+"Alpine musl package provides libssp_nonshared.a. We link to it unconditionally,
+as otherwise we get link failures if some objects are -fstack-protector built
+and final link happens with -fno-stack-protector. This seems to be the common
+case when bootstrapping gcc, the piepatches do not seem to fully fix the
+crosstoolchain and bootstrap sequence wrt. stack-protector flag usage."
+
+(We do the same in Gentoo.)
+--- gcc-6.1.0/gcc/gcc.c.orig
++++ gcc-6.1.0/gcc/gcc.c
+@@ -870,8 +870,7 @@
+
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+- "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ "|fstack-protector-strong|fstack-protector-explicit" \
diff --git a/11.4.0/gentoo/01_all_default-fortify-source.patch b/11.4.0/gentoo/01_all_default-fortify-source.patch
new file mode 100644
index 0000000..d307474
--- /dev/null
+++ b/11.4.0/gentoo/01_all_default-fortify-source.patch
@@ -0,0 +1,22 @@
+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.c
++++ b/gcc/c-family/c-cppbuiltin.c
+@@ -951,6 +951,12 @@ 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)
++ /* Fortify Source enabled by default for optimization levels > 0 */
++ if (optimize)
++ builtin_define_with_int_value ("_FORTIFY_SOURCE", 2);
++#endif
++
+ /* Misc. */
+ if (flag_gnu89_inline)
+ cpp_define (pfile, "__GNUC_GNU_INLINE__");
diff --git a/11.4.0/gentoo/02_all_default-warn-format-security.patch b/11.4.0/gentoo/02_all_default-warn-format-security.patch
new file mode 100644
index 0000000..13fa24a
--- /dev/null
+++ b/11.4.0/gentoo/02_all_default-warn-format-security.patch
@@ -0,0 +1,22 @@
+Enable -Wformat and -Wformat-security by default.
+
+--- a/gcc/c-family/c.opt
++++ b/gcc/c-family/c.opt
+@@ -637,7 +637,7 @@
+ of the destination region. Same as -Wformat-overflow=1.
+
+ 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
+@@ -658,7 +658,7 @@
+ 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.
+
+ Wformat-overflow=
diff --git a/11.4.0/gentoo/03_all_default-warn-trampolines.patch b/11.4.0/gentoo/03_all_default-warn-trampolines.patch
new file mode 100644
index 0000000..7a644cb
--- /dev/null
+++ b/11.4.0/gentoo/03_all_default-warn-trampolines.patch
@@ -0,0 +1,13 @@
+Enable -Wtrampolines by default.
+
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -712,7 +712,7 @@ Common Var(warn_system_headers) Warning
+ Do not suppress warnings from system headers.
+
+ Wtrampolines
+-Common Var(warn_trampolines) Warning
++Common Var(warn_trampolines) Init(1) Warning
+ Warn whenever a trampoline is generated.
+
+ Wtype-limits
diff --git a/11.4.0/gentoo/04_all_nossp-on-nostdlib.patch b/11.4.0/gentoo/04_all_nossp-on-nostdlib.patch
new file mode 100644
index 0000000..20afef1
--- /dev/null
+++ b/11.4.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.c
++++ b/gcc/gcc.c
+@@ -977,6 +977,12 @@
+ #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} "
++#else
++#define NO_SSP_SPEC ""
++#endif
++
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+@@ -1273,7 +1279,7 @@
+ %{-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|fprofile-generate*|coverage:\
+ %{!fprofile-update=single:\
diff --git a/12.0.0/gentoo/05_all_alpha-mieee-default.patch b/11.4.0/gentoo/05_all_alpha-mieee-default.patch
index cf33f14..cf33f14 100644
--- a/12.0.0/gentoo/05_all_alpha-mieee-default.patch
+++ b/11.4.0/gentoo/05_all_alpha-mieee-default.patch
diff --git a/11.4.0/gentoo/06_all_ia64_note.GNU-stack.patch b/11.4.0/gentoo/06_all_ia64_note.GNU-stack.patch
new file mode 100644
index 0000000..66a787e
--- /dev/null
+++ b/11.4.0/gentoo/06_all_ia64_note.GNU-stack.patch
@@ -0,0 +1,92 @@
+http://gcc.gnu.org/PR21098
+
+
+2004-09-20 Jakub Jelinek <jakub@redhat.com>
+
+ * 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 <jakub@redhat.com>
+
+ * config/ia64/linux.h (TARGET_ASM_FILE_END): Define.
+
+
+--- a/gcc/config/ia64/linux.h
++++ b/gcc/config/ia64/linux.h
+@@ -24,6 +24,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
+@@ -352,7 +352,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
+@@ -252,3 +252,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
+@@ -119,3 +119,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/11.4.0/gentoo/07_all_libiberty-asprintf.patch b/11.4.0/gentoo/07_all_libiberty-asprintf.patch
new file mode 100644
index 0000000..702ae3c
--- /dev/null
+++ b/11.4.0/gentoo/07_all_libiberty-asprintf.patch
@@ -0,0 +1,18 @@
+2008-07-25 Magnus Granberg <zorry@ume.nu>
+
+ * include/libiberty.h (asprintf): Don't declare if defined as a macro
+
+--- a/include/libiberty.h
++++ b/include/libiberty.h
+@@ -652,8 +652,11 @@
+ /* Like sprintf but provides a pointer to malloc'd storage, which must
+ be freed by the caller. */
+
++/* asprintf may be declared as a macro by glibc with __USE_FORTIFY_LEVEL. */
++#ifndef asprintf
+ extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
+ #endif
++#endif
+
+ /* Like asprintf but allocates memory without fail. This works like
+ xmalloc. */
diff --git a/11.4.0/gentoo/08_all_libiberty-pic.patch b/11.4.0/gentoo/08_all_libiberty-pic.patch
new file mode 100644
index 0000000..b6160a7
--- /dev/null
+++ b/11.4.0/gentoo/08_all_libiberty-pic.patch
@@ -0,0 +1,10 @@
+--- a/libiberty/Makefile.in
++++ b/libiberty/Makefile.in
+@@ -246,6 +246,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/11.4.0/gentoo/09_all_nopie-all-flags.patch b/11.4.0/gentoo/09_all_nopie-all-flags.patch
new file mode 100644
index 0000000..5563182
--- /dev/null
+++ b/11.4.0/gentoo/09_all_nopie-all-flags.patch
@@ -0,0 +1,18 @@
+We need to pass NO_PIE_CFLAGS to ALL_* so gcc don't fail when
+we compile it with older gcc and pie.
+
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -991,10 +991,10 @@ ALL_CXXFLAGS = $(T_CFLAGS) $(CFLAGS-$@)
+ ALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS)
+
+ # This is the variable to use when using $(COMPILER).
+-ALL_COMPILERFLAGS = $(ALL_CXXFLAGS)
++ALL_COMPILERFLAGS = $(NO_PIE_CFLAGS) $(ALL_CXXFLAGS)
+
+ # This is the variable to use when using $(LINKER).
+-ALL_LINKERFLAGS = $(ALL_CXXFLAGS)
++ALL_LINKERFLAGS = $(NO_PIE_CFLAGS) $(ALL_CXXFLAGS)
+
+ # Build and host support libraries.
+
diff --git a/11.4.0/gentoo/10_all_sh-drop-sysroot-suffix.patch b/11.4.0/gentoo/10_all_sh-drop-sysroot-suffix.patch
new file mode 100644
index 0000000..b1c3591
--- /dev/null
+++ b/11.4.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 <slyfox@gentoo.org>
+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 <slyfox@gentoo.org>
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -2866,8 +2866,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/11.4.0/gentoo/11_all_ia64-TEXTREL.patch b/11.4.0/gentoo/11_all_ia64-TEXTREL.patch
new file mode 100644
index 0000000..5059e4d
--- /dev/null
+++ b/11.4.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.c
++++ b/gcc/config/ia64/ia64.c
+@@ -10838,12 +10838,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/11.4.0/gentoo/12_all_disable-systemtap-switch.patch b/11.4.0/gentoo/12_all_disable-systemtap-switch.patch
new file mode 100644
index 0000000..d4ecefa
--- /dev/null
+++ b/11.4.0/gentoo/12_all_disable-systemtap-switch.patch
@@ -0,0 +1,115 @@
+From bb510ed7ea82093c924b027489db6f92250a85b3 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Sat, 12 May 2018 12:56:46 +0100
+Subject: [PATCH] gcc/configure.ac: add --disable-systemtap switch
+
+Before the change systemtap probes were enabled
+if target headers had sys/sdt.h at ./configure time.
+
+After the change explicitly ask to enable or disable
+for probe support and not rely on automagic dependency
+discovery.
+
+Bug: https://bugs.gentoo.org/654748
+Bug: https://gcc.gnu.org/bugzilla/PR61257
+Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -988,6 +988,7 @@ enable_gnu_unique_object
+ enable_linker_build_id
+ enable_libssp
+ enable_default_ssp
++enable_systemtap
+ with_long_double_128
+ with_long_double_format
+ with_gc
+@@ -1740,6 +1741,7 @@ Optional Features:
+ compiler will always pass --build-id to linker
+ --enable-libssp enable linking against libssp
+ --enable-default-ssp enable Stack Smashing Protection as default
++ --disable-systemtap enable systemtap static probe points [default=auto]
+ --enable-maintainer-mode
+ enable make rules and dependencies not useful (and
+ sometimes confusing) to the casual installer
+@@ -29330,17 +29332,33 @@ fi
+
+ # Test for <sys/sdt.h> on the target.
+
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking sys/sdt.h in the target C library" >&5
++
++# Check whether --enable-systemtap was given.
++if test "${enable_systemtap+set}" = set; then :
++ enableval=$enable_systemtap; enable_systemtap=$enableval
++else
++ enable_systemtap=auto
++fi
++
++
++if test x$enable_systemtap != xno; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking sys/sdt.h in the target C library" >&5
+ $as_echo_n "checking sys/sdt.h in the target C library... " >&6; }
+-have_sys_sdt_h=no
+-if test -f $target_header_dir/sys/sdt.h; then
+- have_sys_sdt_h=yes
++ have_sys_sdt_h=no
++ if test -f $target_header_dir/sys/sdt.h ; then
++ have_sys_sdt_h=yes
+
+ $as_echo "#define HAVE_SYS_SDT_H 1" >>confdefs.h
+
+-fi
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_sys_sdt_h" >&5
++ fi
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_sys_sdt_h" >&5
+ $as_echo "$have_sys_sdt_h" >&6; }
++ if test x$enable_systemtap = xyes ; then
++ if test x$have_sys_sdt_h = xno ; then
++ as_fn_error $? "sys/sdt.h was not found" "$LINENO" 5
++ fi
++ fi
++fi
+
+ # Check if TFmode long double should be used by default or not.
+ # Some glibc targets used DFmode long double, but with glibc 2.4
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -6000,14 +6000,28 @@ AC_SUBST([enable_default_ssp])
+
+ # Test for <sys/sdt.h> on the target.
+ GCC_TARGET_TEMPLATE([HAVE_SYS_SDT_H])
+-AC_MSG_CHECKING(sys/sdt.h in the target C library)
+-have_sys_sdt_h=no
+-if test -f $target_header_dir/sys/sdt.h; then
+- have_sys_sdt_h=yes
+- AC_DEFINE(HAVE_SYS_SDT_H, 1,
+- [Define if your target C library provides sys/sdt.h])
+-fi
+-AC_MSG_RESULT($have_sys_sdt_h)
++
++AC_ARG_ENABLE(systemtap,
++[AS_HELP_STRING([--disable-systemtap],
++ [enable systemtap static probe points [default=auto]])],
++ enable_systemtap=$enableval,
++ enable_systemtap=auto)
++
++if test x$enable_systemtap != xno; then
++ AC_MSG_CHECKING(sys/sdt.h in the target C library)
++ have_sys_sdt_h=no
++ if test -f $target_header_dir/sys/sdt.h ; then
++ have_sys_sdt_h=yes
++ AC_DEFINE(HAVE_SYS_SDT_H, 1,
++ [Define if your target C library provides sys/sdt.h])
++ fi
++ AC_MSG_RESULT($have_sys_sdt_h)
++ if test x$enable_systemtap = xyes ; then
++ if test x$have_sys_sdt_h = xno ; then
++ AC_MSG_ERROR([sys/sdt.h was not found])
++ fi
++ fi
++fi
+
+ # Check if TFmode long double should be used by default or not.
+ # Some glibc targets used DFmode long double, but with glibc 2.4
+--
+2.17.0
+
diff --git a/11.4.0/gentoo/13_all_m68k-textrel-on-libgcc.patch b/11.4.0/gentoo/13_all_m68k-textrel-on-libgcc.patch
new file mode 100644
index 0000000..4cb8350
--- /dev/null
+++ b/11.4.0/gentoo/13_all_m68k-textrel-on-libgcc.patch
@@ -0,0 +1,87 @@
+https://gcc.gnu.org/PR86224
+
+From 1d89df42bdaf0745fd2a0d294471ac16f0553707 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Sat, 28 Jul 2018 11:33:27 +0100
+Subject: [PATCH] libgcc: m68k: avoid absolute relocation in shared library
+
+Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+--- a/libgcc/config/m68k/lb1sf68.S
++++ b/libgcc/config/m68k/lb1sf68.S
+@@ -435,7 +435,10 @@ $_exception_handler:
+ .text
+ FUNC(__mulsi3)
+ .globl SYM (__mulsi3)
++ .globl SYM (__mulsi3_internal)
++ .hidden SYM (__mulsi3_internal)
+ SYM (__mulsi3):
++SYM (__mulsi3_internal):
+ movew sp@(4), d0 /* x0 -> d0 */
+ muluw sp@(10), d0 /* x0*y1 */
+ movew sp@(6), d1 /* x1 -> d1 */
+@@ -458,7 +461,10 @@ SYM (__mulsi3):
+ .text
+ FUNC(__udivsi3)
+ .globl SYM (__udivsi3)
++ .globl SYM (__udivsi3_internal)
++ .hidden SYM (__udivsi3_internal)
+ SYM (__udivsi3):
++SYM (__udivsi3_internal):
+ #ifndef __mcoldfire__
+ movel d2, sp@-
+ movel sp@(12), d1 /* d1 = divisor */
+@@ -534,7 +540,10 @@ L2: subql IMM (1),d4
+ .text
+ FUNC(__divsi3)
+ .globl SYM (__divsi3)
++ .globl SYM (__divsi3_internal)
++ .hidden SYM (__divsi3_internal)
+ SYM (__divsi3):
++SYM (__divsi3_internal):
+ movel d2, sp@-
+
+ moveq IMM (1), d2 /* sign of result stored in d2 (=1 or =-1) */
+@@ -557,7 +566,7 @@ L1: movel sp@(8), d0 /* d0 = dividend */
+
+ L2: movel d1, sp@-
+ movel d0, sp@-
+- PICCALL SYM (__udivsi3) /* divide abs(dividend) by abs(divisor) */
++ PICCALL SYM (__udivsi3_internal) /* divide abs(dividend) by abs(divisor) */
+ addql IMM (8), sp
+
+ tstb d2
+@@ -577,13 +586,13 @@ SYM (__umodsi3):
+ movel sp@(4), d0 /* d0 = dividend */
+ movel d1, sp@-
+ movel d0, sp@-
+- PICCALL SYM (__udivsi3)
++ PICCALL SYM (__udivsi3_internal)
+ addql IMM (8), sp
+ movel sp@(8), d1 /* d1 = divisor */
+ #ifndef __mcoldfire__
+ movel d1, sp@-
+ movel d0, sp@-
+- PICCALL SYM (__mulsi3) /* d0 = (a/b)*b */
++ PICCALL SYM (__mulsi3_internal) /* d0 = (a/b)*b */
+ addql IMM (8), sp
+ #else
+ mulsl d1,d0
+@@ -603,13 +612,13 @@ SYM (__modsi3):
+ movel sp@(4), d0 /* d0 = dividend */
+ movel d1, sp@-
+ movel d0, sp@-
+- PICCALL SYM (__divsi3)
++ PICCALL SYM (__divsi3_internal)
+ addql IMM (8), sp
+ movel sp@(8), d1 /* d1 = divisor */
+ #ifndef __mcoldfire__
+ movel d1, sp@-
+ movel d0, sp@-
+- PICCALL SYM (__mulsi3) /* d0 = (a/b)*b */
++ PICCALL SYM (__mulsi3_internal) /* d0 = (a/b)*b */
+ addql IMM (8), sp
+ #else
+ mulsl d1,d0
+--
+2.18.0
+
diff --git a/11.4.0/gentoo/14_all_respect-build-cxxflags.patch b/11.4.0/gentoo/14_all_respect-build-cxxflags.patch
new file mode 100644
index 0000000..14139ea
--- /dev/null
+++ b/11.4.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
+@@ -170,6 +170,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.
+@@ -710,6 +711,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
+@@ -172,6 +172,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/11.4.0/gentoo/15_all_libgomp-Werror.patch b/11.4.0/gentoo/15_all_libgomp-Werror.patch
new file mode 100644
index 0000000..deda157
--- /dev/null
+++ b/11.4.0/gentoo/15_all_libgomp-Werror.patch
@@ -0,0 +1,26 @@
+libgomp does not respect --disable-werror
+
+https://bugs.gentoo.org/229059
+http://gcc.gnu.org/PR38436
+--- a/libgomp/configure.ac
++++ b/libgomp/configure.ac
+@@ -123,7 +123,7 @@
+
+ # Add -Wall -Werror if we are using GCC.
+ if test "x$GCC" = "xyes"; then
+- XCFLAGS="$XCFLAGS -Wall -Werror"
++ XCFLAGS="$XCFLAGS -Wall"
+ fi
+
+ # Find other programs we need.
+--- a/libgomp/configure
++++ b/libgomp/configure
+@@ -4613,7 +4613,7 @@
+
+ # Add -Wall -Werror if we are using GCC.
+ if test "x$GCC" = "xyes"; then
+- XCFLAGS="$XCFLAGS -Wall -Werror"
++ XCFLAGS="$XCFLAGS -Wall"
+ fi
+
+ # Find other programs we need.
diff --git a/11.4.0/gentoo/16_all_libitm-Werror.patch b/11.4.0/gentoo/16_all_libitm-Werror.patch
new file mode 100644
index 0000000..c8e991c
--- /dev/null
+++ b/11.4.0/gentoo/16_all_libitm-Werror.patch
@@ -0,0 +1,25 @@
+libitm does not respect --disable-werror
+
+https://bugs.gentoo.org/475350
+--- a/libitm/configure.ac
++++ b/libitm/configure.ac
+@@ -263,7 +263,7 @@
+
+ # Add -Wall -Werror if we are using GCC.
+ if test "x$GCC" = "xyes"; then
+- XCFLAGS="$XCFLAGS -Wall -Werror"
++ XCFLAGS="$XCFLAGS -Wall"
+ fi
+
+ XCFLAGS="$XCFLAGS $XPCFLAGS"
+--- a/libitm/configure
++++ b/libitm/configure
+@@ -17854,7 +17854,7 @@
+
+ # Add -Wall -Werror if we are using GCC.
+ if test "x$GCC" = "xyes"; then
+- XCFLAGS="$XCFLAGS -Wall -Werror"
++ XCFLAGS="$XCFLAGS -Wall"
+ fi
+
+ XCFLAGS="$XCFLAGS $XPCFLAGS"
diff --git a/11.4.0/gentoo/17_all_libatomic-Werror.patch b/11.4.0/gentoo/17_all_libatomic-Werror.patch
new file mode 100644
index 0000000..7b29b04
--- /dev/null
+++ b/11.4.0/gentoo/17_all_libatomic-Werror.patch
@@ -0,0 +1,25 @@
+libatomic does not respect --disable-werror
+
+https://bugs.gentoo.org/475350
+--- a/libatomic/configure.ac
++++ b/libatomic/configure.ac
+@@ -253,7 +253,7 @@
+
+ # Add -Wall -Werror if we are using GCC.
+ if test "x$GCC" = "xyes"; then
+- XCFLAGS="$XCFLAGS -Wall -Werror"
++ XCFLAGS="$XCFLAGS -Wall"
+ fi
+
+ # Add CET specific flags if CET is enabled
+--- a/libatomic/configure
++++ b/libatomic/configure
+@@ -15562,7 +15562,7 @@
+
+ # Add -Wall -Werror if we are using GCC.
+ if test "x$GCC" = "xyes"; then
+- XCFLAGS="$XCFLAGS -Wall -Werror"
++ XCFLAGS="$XCFLAGS -Wall"
+ fi
+
+ # Add CET specific flags if CET is enabled
diff --git a/11.4.0/gentoo/18_all_libbacktrace-Werror.patch b/11.4.0/gentoo/18_all_libbacktrace-Werror.patch
new file mode 100644
index 0000000..57dd284
--- /dev/null
+++ b/11.4.0/gentoo/18_all_libbacktrace-Werror.patch
@@ -0,0 +1,17 @@
+libbacktrace does not respect --disable-werror
+
+https://bugs.gentoo.org/667104
+--- a/libbacktrace/configure
++++ b/libbacktrace/configure
+@@ -11634,3 +11634,3 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ if test -n "${with_target_subdir}"; then
+- WARN_FLAGS="$WARN_FLAGS -Werror"
++ WARN_FLAGS="$WARN_FLAGS"
+ fi
+--- a/libbacktrace/configure.ac
++++ b/libbacktrace/configure.ac
+@@ -138,3 +138,3 @@ ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \
+ if test -n "${with_target_subdir}"; then
+- WARN_FLAGS="$WARN_FLAGS -Werror"
++ WARN_FLAGS="$WARN_FLAGS"
+ fi
diff --git a/11.4.0/gentoo/19_all_libsanitizer-Werror.patch b/11.4.0/gentoo/19_all_libsanitizer-Werror.patch
new file mode 100644
index 0000000..0e484a4
--- /dev/null
+++ b/11.4.0/gentoo/19_all_libsanitizer-Werror.patch
@@ -0,0 +1,17 @@
+libsanitizer does not respect --disable-werror
+
+https://bugs.gentoo.org/667104
+--- a/libsanitizer/libbacktrace/Makefile.am
++++ b/libsanitizer/libbacktrace/Makefile.am
+@@ -37,3 +37,3 @@ AM_CPPFLAGS = -I $(top_srcdir)/../include -I $(top_srcdir)/../libgcc \
+ WARN_FLAGS = -W -Wall -Wwrite-strings -Wmissing-format-attribute \
+- -Wcast-qual -Werror
++ -Wcast-qual
+ C_WARN_FLAGS = $(WARN_FLAGS) -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition
+--- a/libsanitizer/libbacktrace/Makefile.in
++++ b/libsanitizer/libbacktrace/Makefile.in
+@@ -297,3 +297,3 @@ AM_CPPFLAGS = -I $(top_srcdir)/../include -I $(top_srcdir)/../libgcc \
+ WARN_FLAGS = -W -Wall -Wwrite-strings -Wmissing-format-attribute \
+- -Wcast-qual -Werror
++ -Wcast-qual
+
diff --git a/11.4.0/gentoo/20_all_libstdcxx-no-vtv.patch b/11.4.0/gentoo/20_all_libstdcxx-no-vtv.patch
new file mode 100644
index 0000000..c079698
--- /dev/null
+++ b/11.4.0/gentoo/20_all_libstdcxx-no-vtv.patch
@@ -0,0 +1,97 @@
+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
+@@ -266,7 +266,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
+@@ -630,7 +630,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
+@@ -580,7 +580,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++17/Makefile.am
++++ b/libstdc++-v3/src/c++17/Makefile.am
+@@ -132,5 +132,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++17/Makefile.in
++++ b/libstdc++-v3/src/c++17/Makefile.in
+@@ -509,7 +509,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++20/Makefile.am
++++ b/libstdc++-v3/src/c++20/Makefile.am
+@@ -101,5 +101,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++20/Makefile.in
++++ b/libstdc++-v3/src/c++20/Makefile.in
+@@ -486,7 +486,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
+@@ -582,7 +582,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/11.4.0/gentoo/21_all_default_ssp-buffer-size.patch b/11.4.0/gentoo/21_all_default_ssp-buffer-size.patch
new file mode 100644
index 0000000..ae5a707
--- /dev/null
+++ b/11.4.0/gentoo/21_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
+@@ -849,7 +849,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/11.4.0/gentoo/22_all_EXTRA_OPTIONS-z-now.patch b/11.4.0/gentoo/22_all_EXTRA_OPTIONS-z-now.patch
new file mode 100644
index 0000000..630d900
--- /dev/null
+++ b/11.4.0/gentoo/22_all_EXTRA_OPTIONS-z-now.patch
@@ -0,0 +1,26 @@
+On Hardened we add some options like -z now
+
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -994,6 +994,12 @@
+ #endif
+ #endif
+
++#ifdef EXTRA_OPTIONS
++#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"
+@@ -1154,7 +1160,7 @@
+ %(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/12.0.0/gentoo/24_all_EXTRA_OPTIONS-fstack-clash-protection.patch b/11.4.0/gentoo/23_all_EXTRA_OPTIONS-fstack-clash-protection.patch
index e836c92..1db9de1 100644
--- a/12.0.0/gentoo/24_all_EXTRA_OPTIONS-fstack-clash-protection.patch
+++ b/11.4.0/gentoo/23_all_EXTRA_OPTIONS-fstack-clash-protection.patch
@@ -1,7 +1,7 @@
On Hardened we add some options like -fstack-clash-protection.
---- a/gcc/common.opt 2018-03-28 16:51:09.000000000 +0200
-+++ a/gcc/common.opt 2018-04-30 15:35:55.274096877 +0200
+--- a/gcc/common.opt
++++ b/gcc/common.opt
@@ -2367,7 +2367,7 @@ Common Alias(fstack-check=, specific, no
Insert stack checking code into the program. Same as -fstack-check=specific.
@@ -11,8 +11,8 @@ On Hardened we add some options like -fstack-clash-protection.
Insert code to probe each page of stack space as it is allocated to protect
from stack-clash style attacks.
---- a/gcc/defaults.h 2018-01-03 11:03:58.000000000 +0100
-+++ b/gcc/defaults.h 2018-05-01 12:41:29.522851451 +0200
+--- a/gcc/defaults.h
++++ b/gcc/defaults.h
@@ -1435,6 +1435,15 @@ see the files COPYING3 and COPYING.RUNTI
#define STACK_CHECK_MAX_VAR_SIZE (STACK_CHECK_MAX_FRAME_SIZE / 100)
#endif
@@ -29,8 +29,8 @@ On Hardened we add some options like -fstack-clash-protection.
/* 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.c 2018-02-13 17:18:37.000000000 +0100
-+++ b/gcc/toplev.c 2018-04-30 16:46:37.244027303 +0200
+--- a/gcc/toplev.c
++++ b/gcc/toplev.c
@@ -1682,6 +1682,10 @@ process_options (void)
/* -fstack-clash-protection is not currently supported on targets
@@ -43,8 +43,8 @@ On Hardened we add some options like -fstack-clash-protection.
{
warning_at (UNKNOWN_LOCATION, 0,
---- a/libgcc/Makefile.in 2011-11-22 04:01:02.000000000 +0100
-+++ b/libgcc/Makefile.in 2011-12-25 15:18:22.449610631 +0100
+--- a/libgcc/Makefile.in
++++ b/libgcc/Makefile.in
@@ -225,7 +225,7 @@ endif
LIBGCC2_DEBUG_CFLAGS = -g
LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \
diff --git a/11.4.0/gentoo/24_all_lto-intl-workaround-PR95194.patch b/11.4.0/gentoo/24_all_lto-intl-workaround-PR95194.patch
new file mode 100644
index 0000000..9613216
--- /dev/null
+++ b/11.4.0/gentoo/24_all_lto-intl-workaround-PR95194.patch
@@ -0,0 +1,20 @@
+Trick libintl not to use '_INTL_REDIRECT_ASM' mode as it's
+incompatible with LTO builds.
+
+glibc does not normally use libintl implementations and uses
+it's own primitives. But musl ond others do fall back to libintl.
+
+Reported-by: Andrew Savchenko
+Bug: https://bugs.gentoo.org/723370
+Bug: https://gcc.gnu.org/PR95194
+--- a/intl/libgnuintl.h
++++ b/intl/libgnuintl.h
+@@ -93,7 +93,7 @@ extern "C" {
+ If he doesn't, we choose the method. A third possible method is
+ _INTL_REDIRECT_ASM, supported only by GCC. */
+ #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
+-# if __GNUC__ >= 2 && !defined __APPLE_CC__ && (defined __STDC__ || defined __cplusplus)
++# if __GNUC__ >= 2 && !defined __APPLE_CC__ && (defined __STDC__ || defined __cplusplus) && USE_ASM_ALIASES_THAT_BREAK_LTO
+ # define _INTL_REDIRECT_ASM
+ # else
+ # ifdef __cplusplus
diff --git a/11.4.0/gentoo/25_all_plugin-objdump.patch b/11.4.0/gentoo/25_all_plugin-objdump.patch
new file mode 100644
index 0000000..a9c33fd
--- /dev/null
+++ b/11.4.0/gentoo/25_all_plugin-objdump.patch
@@ -0,0 +1,34 @@
+https://gcc.gnu.org/PR95648
+--- a/config/gcc-plugin.m4
++++ b/config/gcc-plugin.m4
+@@ -45,7 +45,7 @@ AC_DEFUN([GCC_ENABLE_PLUGINS],
+ ;;
+ *)
+ if test x$build = x$host; then
+- export_sym_check="objdump${exeext} -T"
++ export_sym_check="$ac_cv_prog_OBJDUMP -T"
+ elif test x$host = x$target; then
+ export_sym_check="$gcc_cv_objdump -T"
+ else
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -30386,7 +30386,7 @@ fi
+ ;;
+ *)
+ if test x$build = x$host; then
+- export_sym_check="objdump${exeext} -T"
++ export_sym_check="$ac_cv_prog_OBJDUMP -T"
+ elif test x$host = x$target; then
+ export_sym_check="$gcc_cv_objdump -T"
+ else
+--- a/libcc1/configure
++++ b/libcc1/configure
+@@ -14819,7 +14819,7 @@ fi
+ ;;
+ *)
+ if test x$build = x$host; then
+- export_sym_check="objdump${exeext} -T"
++ export_sym_check="$ac_cv_prog_OBJDUMP -T"
+ elif test x$host = x$target; then
+ export_sym_check="$gcc_cv_objdump -T"
+ else
diff --git a/11.4.0/gentoo/27_all_msgfmt-libstdc++-link.patch b/11.4.0/gentoo/27_all_msgfmt-libstdc++-link.patch
new file mode 100644
index 0000000..0d2f113
--- /dev/null
+++ b/11.4.0/gentoo/27_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/11.4.0/gentoo/28_all_drop_CFLAGS_sed.patch b/11.4.0/gentoo/28_all_drop_CFLAGS_sed.patch
new file mode 100644
index 0000000..0a9fa13
--- /dev/null
+++ b/11.4.0/gentoo/28_all_drop_CFLAGS_sed.patch
@@ -0,0 +1,35 @@
+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
+@@ -5265,13 +5265,6 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
+ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+-# Remove the -O2: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[ ]//" -e "s/-O[gs][ ]//" -e "s/-O[0-9]*[ ]//" `
+- CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[ ]//" -e "s/-O[gs][ ]//" -e "s/-O[0-9]*[ ]//" ` ;;
+-esac
+
+
+
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -439,13 +439,6 @@ ACX_PROG_GNAT([-I"$srcdir"/ada/libgnat])
+ # Do configure tests with the C++ compiler, since that's what we build with.
+ AC_LANG(C++)
+
+-# Remove the -O2: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" `
+- CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" ` ;;
+-esac
+ AC_SUBST(CFLAGS)
+ AC_SUBST(CXXFLAGS)
+
diff --git a/11.4.0/gentoo/29_all_tar_libstdc++-link.patch b/11.4.0/gentoo/29_all_tar_libstdc++-link.patch
new file mode 100644
index 0000000..680ab38
--- /dev/null
+++ b/11.4.0/gentoo/29_all_tar_libstdc++-link.patch
@@ -0,0 +1,57 @@
+From eae11e896edef4199a128bf6720b5bd4e5edc2f9 Mon Sep 17 00:00:00 2001
+From: Sam James <sam@gentoo.org>
+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 <sam@gentoo.org>
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -3902,10 +3902,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.
+@@ -3926,7 +3926,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/11.4.0/gentoo/75_all_x86_PR99703_12_no-cet-for-i486.patch b/11.4.0/gentoo/75_all_x86_PR99703_12_no-cet-for-i486.patch
new file mode 100644
index 0000000..f953e09
--- /dev/null
+++ b/11.4.0/gentoo/75_all_x86_PR99703_12_no-cet-for-i486.patch
@@ -0,0 +1,373 @@
+https://bugs.gentoo.org/777117
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99703
+
+From: "H.J. Lu" <hjl.tools@gmail.com>
+Date: Fri, 12 Feb 2021 16:30:23 -0800
+Subject: GCC_CET_HOST_FLAGS: Check if host supports multi-byte NOPs
+
+Backport of fd7eb4bc94cafa745eba75c64fa483a1689a5aad to GCC 11
+
+Sync with binutils for PR binutils/27397. Check if host supports
+multi-byte NOPs before enabling CET on host.
+
+config/
+
+ PR bootstrap/99703
+ * cet.m4 (GCC_CET_HOST_FLAGS): Check if host supports multi-byte
+ NOPs.
+
+All applicable configure scripts have been regenerated. Patch hunks
+which only updated line numbers have been excluded to reduce conflicts.
+
+--- a/config/cet.m4
++++ b/config/cet.m4
+@@ -130,6 +130,18 @@ fi
+ if test x$may_have_cet = xyes; then
+ if test x$cross_compiling = xno; then
+ AC_TRY_RUN([
++int
++main ()
++{
++ asm ("endbr32");
++ return 0;
++}
++ ],
++ [have_multi_byte_nop=yes],
++ [have_multi_byte_nop=no])
++ have_cet=no
++ if test x$have_multi_byte_nop = xyes; then
++ AC_TRY_RUN([
+ static void
+ foo (void)
+ {
+@@ -155,9 +167,10 @@ main ()
+ bar ();
+ return 0;
+ }
+- ],
+- [have_cet=no],
+- [have_cet=yes])
++ ],
++ [have_cet=no],
++ [have_cet=yes])
++ fi
+ if test x$enable_cet = xno -a x$have_cet = xyes; then
+ AC_MSG_ERROR([Intel CET must be enabled on Intel CET enabled host])
+ fi
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -32416,6 +32416,34 @@ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
++int
++main ()
++{
++ asm ("endbr32");
++ return 0;
++}
++
++_ACEOF
++if ac_fn_cxx_try_run "$LINENO"; then :
++ have_multi_byte_nop=yes
++else
++ have_multi_byte_nop=no
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++ conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++ have_cet=no
++ if test x$have_multi_byte_nop = xyes; then
++ if test "$cross_compiling" = yes; then :
++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++as_fn_error $? "cannot run test program while cross compiling
++See \`config.log' for more details" "$LINENO" 5; }
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
+ static void
+ foo (void)
+ {
+@@ -32452,6 +32480,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+ fi
+
++ fi
+ if test x$enable_cet = xno -a x$have_cet = xyes; then
+ as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5
+ fi
+--- a/libbacktrace/configure
++++ b/libbacktrace/configure
+@@ -12517,6 +12517,34 @@ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
++int
++main ()
++{
++ asm ("endbr32");
++ return 0;
++}
++
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++ have_multi_byte_nop=yes
++else
++ have_multi_byte_nop=no
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++ conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++ have_cet=no
++ if test x$have_multi_byte_nop = xyes; then
++ if test "$cross_compiling" = yes; then :
++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++as_fn_error $? "cannot run test program while cross compiling
++See \`config.log' for more details" "$LINENO" 5; }
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
+ static void
+ foo (void)
+ {
+@@ -12553,6 +12581,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+ fi
+
++ fi
+ if test x$enable_cet = xno -a x$have_cet = xyes; then
+ as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5
+ fi
+--- a/libcc1/configure
++++ b/libcc1/configure
+@@ -14653,6 +14653,34 @@ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
++int
++main ()
++{
++ asm ("endbr32");
++ return 0;
++}
++
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++ have_multi_byte_nop=yes
++else
++ have_multi_byte_nop=no
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++ conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++ have_cet=no
++ if test x$have_multi_byte_nop = xyes; then
++ if test "$cross_compiling" = yes; then :
++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++as_fn_error $? "cannot run test program while cross compiling
++See \`config.log' for more details" "$LINENO" 5; }
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
+ static void
+ foo (void)
+ {
+@@ -14689,6 +14717,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+ fi
+
++ fi
+ if test x$enable_cet = xno -a x$have_cet = xyes; then
+ as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5
+ fi
+--- a/libcpp/configure
++++ b/libcpp/configure
+@@ -7668,6 +7668,34 @@ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
++int
++main ()
++{
++ asm ("endbr32");
++ return 0;
++}
++
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++ have_multi_byte_nop=yes
++else
++ have_multi_byte_nop=no
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++ conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++ have_cet=no
++ if test x$have_multi_byte_nop = xyes; then
++ if test "$cross_compiling" = yes; then :
++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++as_fn_error $? "cannot run test program while cross compiling
++See \`config.log' for more details" "$LINENO" 5; }
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
+ static void
+ foo (void)
+ {
+@@ -7704,6 +7732,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+ fi
+
++ fi
+ if test x$enable_cet = xno -a x$have_cet = xyes; then
+ as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5
+ fi
+--- a/libdecnumber/configure
++++ b/libdecnumber/configure
+@@ -5321,6 +5321,34 @@ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
++int
++main ()
++{
++ asm ("endbr32");
++ return 0;
++}
++
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++ have_multi_byte_nop=yes
++else
++ have_multi_byte_nop=no
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++ conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++ have_cet=no
++ if test x$have_multi_byte_nop = xyes; then
++ if test "$cross_compiling" = yes; then :
++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++as_fn_error $? "cannot run test program while cross compiling
++See \`config.log' for more details" "$LINENO" 5; }
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
+ static void
+ foo (void)
+ {
+@@ -5357,6 +5385,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+ fi
+
++ fi
+ if test x$enable_cet = xno -a x$have_cet = xyes; then
+ as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5
+ fi
+--- a/libiberty/configure
++++ b/libiberty/configure
+@@ -5396,6 +5396,34 @@ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
++int
++main ()
++{
++ asm ("endbr32");
++ return 0;
++}
++
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++ have_multi_byte_nop=yes
++else
++ have_multi_byte_nop=no
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++ conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++ have_cet=no
++ if test x$have_multi_byte_nop = xyes; then
++ if test "$cross_compiling" = yes; then :
++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++as_fn_error $? "cannot run test program while cross compiling
++See \`config.log' for more details" "$LINENO" 5; }
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
+ static void
+ foo (void)
+ {
+@@ -5432,6 +5460,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+ fi
+
++ fi
+ if test x$enable_cet = xno -a x$have_cet = xyes; then
+ as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5
+ fi
+--- a/lto-plugin/configure
++++ b/lto-plugin/configure
+@@ -5791,6 +5791,34 @@ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
++int
++main ()
++{
++ asm ("endbr32");
++ return 0;
++}
++
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++ have_multi_byte_nop=yes
++else
++ have_multi_byte_nop=no
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++ conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++ have_cet=no
++ if test x$have_multi_byte_nop = xyes; then
++ if test "$cross_compiling" = yes; then :
++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++as_fn_error $? "cannot run test program while cross compiling
++See \`config.log' for more details" "$LINENO" 5; }
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
+ static void
+ foo (void)
+ {
+@@ -5827,6 +5855,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+ fi
+
++ fi
+ if test x$enable_cet = xno -a x$have_cet = xyes; then
+ as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5
+ fi
+--
+2.34.1
diff --git a/11.4.0/gentoo/76_all_all_PR103910_12_ICE-on-PCH.patch b/11.4.0/gentoo/76_all_all_PR103910_12_ICE-on-PCH.patch
new file mode 100644
index 0000000..358b9b3
--- /dev/null
+++ b/11.4.0/gentoo/76_all_all_PR103910_12_ICE-on-PCH.patch
@@ -0,0 +1,35 @@
+https://bugs.gentoo.org/822690
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103910
+
+From d243f4009d8071b734df16cd70f4c5d09a373769 Mon Sep 17 00:00:00 2001
+From: Andrew Pinski <apinski@marvell.com>
+Date: Wed, 5 Jan 2022 22:00:07 +0000
+Subject: [PATCH] Fix target/103910: missing GTY on x86_mfence causing PCH
+ usage to ICE
+
+With -O3 -march=opteron, a mfence builtin is added after the loop
+to say the nontemporal stores are no longer needed. This all good
+without precompiled headers as the function decl that is referneced
+by x86_mfence is referenced in another variable but with precompiled
+headers, x86_mfence is all messed up and the decl was GC'ed away.
+This fixes the problem by marking x86_mfence as GTY to save/restore
+during precompiled headers just like most other variables in
+the header file.
+
+Committed as obvious after a bootstrap/test on x86_64-linux-gnu.
+
+gcc/ChangeLog:
+
+ PR target/103910
+ * config/i386/i386.h (x86_mfence): Mark with GTY.
+--- a/gcc/config/i386/i386.h
++++ b/gcc/config/i386/i386.h
+@@ -486,7 +486,7 @@ extern unsigned char ix86_prefetch_sse;
+
+ /* Fence to use after loop using storent. */
+
+-extern tree x86_mfence;
++extern GTY(()) tree x86_mfence;
+ #define FENCE_FOLLOWING_MOVNT x86_mfence
+
+ /* Once GDB has been enhanced to deal with functions without frame
diff --git a/11.4.0/gentoo/README.history b/11.4.0/gentoo/README.history
new file mode 100644
index 0000000..8c88904
--- /dev/null
+++ b/11.4.0/gentoo/README.history
@@ -0,0 +1,65 @@
+12 9 Dec 2023
+
+ - 77_all_all_PR112823_13_libiberty-warning.patch
+
+11 2 Dec 2023
+ + 77_all_all_PR112823_13_libiberty-warning.patch
+
+10 5 May 2023
+ - 77_all_all_PR109585_13_rtl-alias-analysis-typo.patch
+
+9 28 Apr 2023
+ + 77_all_all_PR109585_13_rtl-alias-analysis-typo.patch
+
+8 28 Jan 2023
+ - 77_all_driver_environ_putenv_PR106624.patch
+
+7 23 Jan 2023
+ - 26_all_enable-cet.patch
+ + 77_all_driver_environ_putenv_PR106624.patch
+
+6 7 Jan 2023
+ - 77_all_configure-c89.patch
+
+5 17 Dec 2022
+ U 29_all_tar_libstdc++-link.patch
+
+4 17 Dec 2022
+ + 35_all_tar_libstdc++-link.patch
+
+3 19 Nov 2022
+ + 77_all_configure-c89.patch
+
+2 22 Aug 2022
+ + 28_all_drop_CFLAGS_sed.patch
+
+1 3 July 2022
+ + 27_all_msgfmt-libstdc++-link.patch
+
+0 22 May 2022
+ + 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
+ + 07_all_libiberty-asprintf.patch
+ + 08_all_libiberty-pic.patch
+ + 09_all_nopie-all-flags.patch
+ + 10_all_sh-drop-sysroot-suffix.patch
+ + 11_all_ia64-TEXTREL.patch
+ + 12_all_disable-systemtap-switch.patch
+ + 13_all_m68k-textrel-on-libgcc.patch
+ + 14_all_respect-build-cxxflags.patch
+ + 15_all_libgomp-Werror.patch
+ + 16_all_libitm-Werror.patch
+ + 17_all_libatomic-Werror.patch
+ + 18_all_libbacktrace-Werror.patch
+ + 19_all_libsanitizer-Werror.patch
+ + 20_all_libstdcxx-no-vtv.patch
+ + 21_all_default_ssp-buffer-size.patch
+ + 22_all_EXTRA_OPTIONS-z-now.patch
+ + 23_all_EXTRA_OPTIONS-fstack-clash-protection.patch
+ + 24_all_lto-intl-workaround-PR95194.patch
+ + 25_all_plugin-objdump.patch
+ + 26_all_enable-cet.patch
diff --git a/11.4.0/musl/25_all_multilib_pure64.patch b/11.4.0/musl/25_all_multilib_pure64.patch
new file mode 100644
index 0000000..d55c04c
--- /dev/null
+++ b/11.4.0/musl/25_all_multilib_pure64.patch
@@ -0,0 +1,83 @@
+https://bugs.gentoo.org/675954
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90077
+
+--- a/gcc/config/aarch64/t-aarch64-linux
++++ b/gcc/config/aarch64/t-aarch64-linux
+@@ -22,7 +22,7 @@
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+--- a/gcc/config/i386/t-linux64
++++ b/gcc/config/i386/t-linux64
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
+-MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
++MULTILIB_OSDIRNAMES+= mx32=../libx32
+--- a/gcc/config/rs6000/t-linux
++++ b/gcc/config/rs6000/t-linux
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+
+--- a/gcc/config/rs6000/t-linux64
++++ b/gcc/config/rs6000/t-linux64
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS := m64/m32
+ MULTILIB_DIRNAMES := 64 32
+ MULTILIB_EXTRA_OPTS :=
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ $(COMPILE) $<
+--- a/gcc/config/rs6000/t-linux64bele
++++ b/gcc/config/rs6000/t-linux64bele
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mlittle
+ MULTILIB_DIRNAMES += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/rs6000/t-linux64lebe
++++ b/gcc/config/rs6000/t-linux64lebe
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mbig
+ MULTILIB_DIRNAMES += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
diff --git a/11.4.0/musl/50_all_calloc_libgccjit.patch b/11.4.0/musl/50_all_calloc_libgccjit.patch
new file mode 100644
index 0000000..bbb6787
--- /dev/null
+++ b/11.4.0/musl/50_all_calloc_libgccjit.patch
@@ -0,0 +1,122 @@
+https://git.alpinelinux.org/aports/plain/main/gcc/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
+https://bugs.gentoo.org/828580
+https://bugs.gentoo.org/851555
+
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106102
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104799
+
+From 72f32e3383129ad139df76d9a063fac9b03079b1 Mon Sep 17 00:00:00 2001
+From: Alex McGrath <amk@amk.ie>
+Date: Wed, 13 Oct 2021 23:24:27 +0100
+Subject: [PATCH] Fix attempt to use poisoned calloc error in libgccjit
+
+This moves usages of pthread.h to above any usage of system.h as it
+included #pragma GCC poison calloc
+--- a/gcc/cp/mapper-client.cc
++++ b/gcc/cp/mapper-client.cc
+@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see
+ #define INCLUDE_STRING
+ #define INCLUDE_VECTOR
+ #define INCLUDE_MAP
++#include <pthread.h>
+ #include "system.h"
+
+ #include "line-map.h"
+--- a/gcc/cp/mapper-resolver.cc
++++ b/gcc/cp/mapper-resolver.cc
+@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see
+ #define INCLUDE_VECTOR
+ #define INCLUDE_ALGORITHM
+ #define INCLUDE_MAP
++#include <pthread.h>
+ #include "system.h"
+
+ // We don't want or need to be aware of networking
+--- a/gcc/cp/module.cc
++++ b/gcc/cp/module.cc
+@@ -204,6 +204,7 @@ Classes used:
+ #include "config.h"
+ #define INCLUDE_STRING
+ #define INCLUDE_VECTOR
++#include <pthread.h>
+ #include "system.h"
+ #include "coretypes.h"
+ #include "cp-tree.h"
+--- a/gcc/jit/jit-playback.c
++++ b/gcc/jit/jit-playback.c
+@@ -18,6 +18,8 @@ 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 <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -41,8 +43,6 @@ along with GCC; see the file COPYING3. If not see
+ #include "diagnostic.h"
+ #include "stmt.h"
+
+-#include <pthread.h>
+-
+ #include "jit-playback.h"
+ #include "jit-result.h"
+ #include "jit-builtins.h"
+--- a/gcc/jit/jit-recording.c
++++ b/gcc/jit/jit-recording.c
+@@ -18,6 +18,8 @@ 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 <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -25,8 +27,6 @@ along with GCC; see the file COPYING3. If not see
+ #include "pretty-print.h"
+ #include "toplev.h"
+
+-#include <pthread.h>
+-
+ #include "jit-builtins.h"
+ #include "jit-recording.h"
+ #include "jit-playback.h"
+--- a/gcc/jit/libgccjit.c
++++ b/gcc/jit/libgccjit.c
+@@ -18,13 +18,14 @@ 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 <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+ #include "timevar.h"
+ #include "typed-splay-tree.h"
+ #include "cppbuiltin.h"
+-#include <pthread.h>
+
+ #include "libgccjit.h"
+ #include "jit-recording.h"
+--- a/libcc1/libcc1plugin.cc
++++ b/libcc1/libcc1plugin.cc
+@@ -17,6 +17,7 @@
+ along with GCC; see the file COPYING3. If not see
+ <http://www.gnu.org/licenses/>. */
+
++#include <pthread.h>
+ #include <cc1plugin-config.h>
+
+ #undef PACKAGE_NAME
+--- a/libcc1/libcp1plugin.cc
++++ b/libcc1/libcp1plugin.cc
+@@ -18,6 +18,7 @@
+ along with GCC; see the file COPYING3. If not see
+ <http://www.gnu.org/licenses/>. */
+
++#include <pthread.h>
+ #include <cc1plugin-config.h>
+
+ #undef PACKAGE_NAME
diff --git a/11.4.0/musl/50_all_cpu_indicator.patch b/11.4.0/musl/50_all_cpu_indicator.patch
new file mode 100644
index 0000000..060b322
--- /dev/null
+++ b/11.4.0/musl/50_all_cpu_indicator.patch
@@ -0,0 +1,37 @@
+From d16a8ceb1c3c8a7ec381090b4c316ff4c55661c0 Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 7 May 2020 21:14:11 -0500
+Subject: [PATCH] convert "__cpu_indicator_init" to
+ "__cpu_indicator_init_local"
+
+--- a/gcc/config/i386/i386-expand.c
++++ b/gcc/config/i386/i386-expand.c
+@@ -10941,10 +10941,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
+ {
+ case IX86_BUILTIN_CPU_INIT:
+ {
+- /* Make it call __cpu_indicator_init in libgcc. */
++ /* Make it call __cpu_indicator_init_local in libgcc. */
+ tree call_expr, fndecl, type;
+ type = build_function_type_list (integer_type_node, NULL_TREE);
+- fndecl = build_fn_decl ("__cpu_indicator_init", type);
++ fndecl = build_fn_decl ("__cpu_indicator_init_local", type);
+ call_expr = build_call_expr (fndecl, 0);
+ return expand_expr (call_expr, target, mode, EXPAND_NORMAL);
+ }
+--- a/libgcc/config/i386/cpuinfo.c
++++ b/libgcc/config/i386/cpuinfo.c
+@@ -508,7 +508,7 @@ __cpu_indicator_init (void)
+ return 0;
+ }
+
+-#if defined SHARED && defined USE_ELF_SYMVER
+-__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0");
+-__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0");
++#ifndef SHARED
++int __cpu_indicator_init_local (void)
++ __attribute__ ((weak, alias ("__cpu_indicator_init")));
+ #endif
+--
+2.26.2
+
diff --git a/11.4.0/musl/50_all_libssp_unconditionally.patch b/11.4.0/musl/50_all_libssp_unconditionally.patch
new file mode 100644
index 0000000..42796f2
--- /dev/null
+++ b/11.4.0/musl/50_all_libssp_unconditionally.patch
@@ -0,0 +1,24 @@
+https://bugs.gentoo.org/706210
+https://bugs.gentoo.org/747346
+
+Author: Timo Teräs <timo.teras@iki.fi>
+
+"Alpine musl package provides libssp_nonshared.a. We link to it unconditionally,
+as otherwise we get link failures if some objects are -fstack-protector built
+and final link happens with -fno-stack-protector. This seems to be the common
+case when bootstrapping gcc, the piepatches do not seem to fully fix the
+crosstoolchain and bootstrap sequence wrt. stack-protector flag usage."
+
+(We do the same in Gentoo.)
+--- a/gcc/gcc.c.orig
++++ b/gcc/gcc.c
+@@ -870,8 +870,7 @@
+
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+- "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ "|fstack-protector-strong|fstack-protector-explicit" \
diff --git a/11.4.0/musl/50_all_posix_memalign.patch b/11.4.0/musl/50_all_posix_memalign.patch
new file mode 100644
index 0000000..dd75a93
--- /dev/null
+++ b/11.4.0/musl/50_all_posix_memalign.patch
@@ -0,0 +1,28 @@
+--- a/gcc/config/i386/pmm_malloc.h
++++ b/gcc/config/i386/pmm_malloc.h
+@@ -27,12 +27,13 @@
+ #include <stdlib.h>
+
+ /* We can't depend on <stdlib.h> since the prototype of posix_memalign
+- may not be visible. */
++ may not be visible and we can't pollute the namespace either. */
+ #ifndef __cplusplus
+-extern int posix_memalign (void **, size_t, size_t);
++extern int __gcc_posix_memalign (void **, size_t, size_t)
+ #else
+-extern "C" int posix_memalign (void **, size_t, size_t) throw ();
++extern "C" int __gcc_posix_memalign (void **, size_t, size_t) throw ()
+ #endif
++__asm__("posix_memalign");
+
+ static __inline void *
+ _mm_malloc (size_t __size, size_t __alignment)
+@@ -42,7 +43,7 @@
+ return malloc (__size);
+ if (__alignment == 2 || (sizeof (void *) == 8 && __alignment == 4))
+ __alignment = sizeof (void *);
+- if (posix_memalign (&__ptr, __alignment, __size) == 0)
++ if (__gcc_posix_memalign (&__ptr, __alignment, __size) == 0)
+ return __ptr;
+ else
+ return NULL;
diff --git a/12.1.0/gentoo/01_all_default-fortify-source.patch b/12.1.0/gentoo/01_all_default-fortify-source.patch
new file mode 100644
index 0000000..d9f001a
--- /dev/null
+++ b/12.1.0/gentoo/01_all_default-fortify-source.patch
@@ -0,0 +1,22 @@
+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,12 @@ 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)
++ /* Fortify Source enabled by default for optimization levels > 0 */
++ if (optimize)
++ builtin_define_with_int_value ("_FORTIFY_SOURCE", 2);
++#endif
++
+ /* Misc. */
+ if (flag_gnu89_inline)
+ cpp_define (pfile, "__GNUC_GNU_INLINE__");
diff --git a/12.1.0/gentoo/02_all_default-warn-format-security.patch b/12.1.0/gentoo/02_all_default-warn-format-security.patch
new file mode 100644
index 0000000..9723a1c
--- /dev/null
+++ b/12.1.0/gentoo/02_all_default-warn-format-security.patch
@@ -0,0 +1,22 @@
+Enable -Wformat and -Wformat-security by default.
+
+--- a/gcc/c-family/c.opt
++++ b/gcc/c-family/c.opt
+@@ -696,7 +696,7 @@ Warn about function calls with format strings that write past the end
+ of the destination region. Same as -Wformat-overflow=1.
+
+ 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
+@@ -717,7 +717,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.
+
+ Wformat-overflow=
diff --git a/12.1.0/gentoo/03_all_default-warn-trampolines.patch b/12.1.0/gentoo/03_all_default-warn-trampolines.patch
new file mode 100644
index 0000000..fb6d8bc
--- /dev/null
+++ b/12.1.0/gentoo/03_all_default-warn-trampolines.patch
@@ -0,0 +1,13 @@
+Enable -Wtrampolines by default.
+
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -798,7 +798,7 @@ Common Var(warn_system_headers) Warning
+ Do not suppress warnings from system headers.
+
+ 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/12.1.0/gentoo/04_all_nossp-on-nostdlib.patch b/12.1.0/gentoo/04_all_nossp-on-nostdlib.patch
new file mode 100644
index 0000000..b633d7f
--- /dev/null
+++ b/12.1.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
+@@ -984,6 +984,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} "
++#else
++#define NO_SSP_SPEC ""
++#endif
++
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+@@ -1280,7 +1286,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|fprofile-generate*|coverage:\
+ %{!fprofile-update=single:\
diff --git a/12.1.0/gentoo/05_all_alpha-mieee-default.patch b/12.1.0/gentoo/05_all_alpha-mieee-default.patch
new file mode 100644
index 0000000..fd1de71
--- /dev/null
+++ b/12.1.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 <vapier@gentoo.org>
+
+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/12.1.0/gentoo/06_all_ia64_note.GNU-stack.patch b/12.1.0/gentoo/06_all_ia64_note.GNU-stack.patch
new file mode 100644
index 0000000..7a1d4c6
--- /dev/null
+++ b/12.1.0/gentoo/06_all_ia64_note.GNU-stack.patch
@@ -0,0 +1,92 @@
+http://gcc.gnu.org/PR21098
+
+
+2004-09-20 Jakub Jelinek <jakub@redhat.com>
+
+ * 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 <jakub@redhat.com>
+
+ * 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/12.1.0/gentoo/07_all_libiberty-asprintf.patch b/12.1.0/gentoo/07_all_libiberty-asprintf.patch
new file mode 100644
index 0000000..1ed2ba3
--- /dev/null
+++ b/12.1.0/gentoo/07_all_libiberty-asprintf.patch
@@ -0,0 +1,18 @@
+2008-07-25 Magnus Granberg <zorry@ume.nu>
+
+ * include/libiberty.h (asprintf): Don't declare if defined as a macro
+
+--- a/include/libiberty.h
++++ b/include/libiberty.h
+@@ -652,8 +652,11 @@ extern void *bsearch_r (const void *, const void *,
+ /* Like sprintf but provides a pointer to malloc'd storage, which must
+ be freed by the caller. */
+
++/* asprintf may be declared as a macro by glibc with __USE_FORTIFY_LEVEL. */
++#ifndef asprintf
+ extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
+ #endif
++#endif
+
+ /* Like asprintf but allocates memory without fail. This works like
+ xmalloc. */
diff --git a/12.1.0/gentoo/08_all_libiberty-pic.patch b/12.1.0/gentoo/08_all_libiberty-pic.patch
new file mode 100644
index 0000000..3f0bae1
--- /dev/null
+++ b/12.1.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/12.1.0/gentoo/09_all_nopie-all-flags.patch b/12.1.0/gentoo/09_all_nopie-all-flags.patch
new file mode 100644
index 0000000..0f7c769
--- /dev/null
+++ b/12.1.0/gentoo/09_all_nopie-all-flags.patch
@@ -0,0 +1,18 @@
+We need to pass NO_PIE_CFLAGS to ALL_* so gcc don't fail when
+we compile it with older gcc and pie.
+
+--- a/gcc/Makefile.in 2015-06-25 19:18:12.000000000 +0200
++++ b/gcc/Makefile.in 2016-04-22 00:12:54.029178860 +0200
+@@ -1054,10 +1054,10 @@ ALL_CXXFLAGS = $(T_CFLAGS) $(CFLAGS-$@)
+ ALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS)
+
+ # This is the variable to use when using $(COMPILER).
+-ALL_COMPILERFLAGS = $(ALL_CXXFLAGS)
++ALL_COMPILERFLAGS = $(NO_PIE_CFLAGS) $(ALL_CXXFLAGS)
+
+ # This is the variable to use when using $(LINKER).
+-ALL_LINKERFLAGS = $(ALL_CXXFLAGS)
++ALL_LINKERFLAGS = $(NO_PIE_CFLAGS) $(ALL_CXXFLAGS)
+
+ # Build and host support libraries.
+
diff --git a/12.1.0/gentoo/10_all_sh-drop-sysroot-suffix.patch b/12.1.0/gentoo/10_all_sh-drop-sysroot-suffix.patch
new file mode 100644
index 0000000..fd3bda5
--- /dev/null
+++ b/12.1.0/gentoo/10_all_sh-drop-sysroot-suffix.patch
@@ -0,0 +1,32 @@
+From 5eeeff19bb4978a8d3c0d53bc81744bc25d82993 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+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 <slyfox@gentoo.org>
+---
+ gcc/config.gcc | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/gcc/config.gcc b/gcc/config.gcc
+index 55c314afdbd..c320f24f123 100644
+--- 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/12.1.0/gentoo/11_all_ia64-TEXTREL.patch b/12.1.0/gentoo/11_all_ia64-TEXTREL.patch
new file mode 100644
index 0000000..69347f5
--- /dev/null
+++ b/12.1.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
++++ a/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/12.1.0/gentoo/12_all_disable-systemtap-switch.patch b/12.1.0/gentoo/12_all_disable-systemtap-switch.patch
new file mode 100644
index 0000000..4d69141
--- /dev/null
+++ b/12.1.0/gentoo/12_all_disable-systemtap-switch.patch
@@ -0,0 +1,122 @@
+From bb510ed7ea82093c924b027489db6f92250a85b3 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Sat, 12 May 2018 12:56:46 +0100
+Subject: [PATCH] gcc/configure.ac: add --disable-systemtap switch
+
+Before the change systemtap probes were enabled
+if target headers had sys/sdt.h at ./configure time.
+
+After the change explicitly ask to enable or disable
+for probe support and not rely on automagic dependency
+discovery.
+
+Bug: https://bugs.gentoo.org/654748
+Bug: https://gcc.gnu.org/bugzilla/PR61257
+Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+---
+ gcc/configure | 34 ++++++++++++++++++++++++++--------
+ gcc/configure.ac | 30 ++++++++++++++++++++++--------
+ 2 files changed, 48 insertions(+), 16 deletions(-)
+
+diff --git a/gcc/configure b/gcc/configure
+index 3dcf7752b..c2049f117 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -1015,6 +1015,7 @@ enable_gnu_unique_object
+ enable_linker_build_id
+ enable_libssp
+ enable_default_ssp
++enable_systemtap
+ with_long_double_128
+ with_long_double_format
+ with_gc
+@@ -1773,6 +1774,7 @@ Optional Features:
+ compiler will always pass --build-id to linker
+ --enable-libssp enable linking against libssp
+ --enable-default-ssp enable Stack Smashing Protection as default
++ --disable-systemtap enable systemtap static probe points [default=auto]
+ --enable-maintainer-mode
+ enable make rules and dependencies not useful (and
+ sometimes confusing) to the casual installer
+@@ -31387,17 +31389,33 @@ fi
+
+ # Test for <sys/sdt.h> on the target.
+
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking sys/sdt.h in the target C library" >&5
++
++# Check whether --enable-systemtap was given.
++if test "${enable_systemtap+set}" = set; then :
++ enableval=$enable_systemtap; enable_systemtap=$enableval
++else
++ enable_systemtap=auto
++fi
++
++
++if test x$enable_systemtap != xno; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking sys/sdt.h in the target C library" >&5
+ $as_echo_n "checking sys/sdt.h in the target C library... " >&6; }
+-have_sys_sdt_h=no
+-if test -f $target_header_dir/sys/sdt.h; then
+- have_sys_sdt_h=yes
++ have_sys_sdt_h=no
++ if test -f $target_header_dir/sys/sdt.h ; then
++ have_sys_sdt_h=yes
+
+ $as_echo "#define HAVE_SYS_SDT_H 1" >>confdefs.h
+
+-fi
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_sys_sdt_h" >&5
++ fi
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_sys_sdt_h" >&5
+ $as_echo "$have_sys_sdt_h" >&6; }
++ if test x$enable_systemtap = xyes ; then
++ if test x$have_sys_sdt_h = xno ; then
++ as_fn_error $? "sys/sdt.h was not found" "$LINENO" 5
++ fi
++ fi
++fi
+
+ # Check if TFmode long double should be used by default or not.
+ # Some glibc targets used DFmode long double, but with glibc 2.4
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -6904,14 +6904,28 @@ AC_SUBST([enable_default_ssp])
+
+ # Test for <sys/sdt.h> on the target.
+ GCC_TARGET_TEMPLATE([HAVE_SYS_SDT_H])
+-AC_MSG_CHECKING(sys/sdt.h in the target C library)
+-have_sys_sdt_h=no
+-if test -f $target_header_dir/sys/sdt.h; then
+- have_sys_sdt_h=yes
+- AC_DEFINE(HAVE_SYS_SDT_H, 1,
+- [Define if your target C library provides sys/sdt.h])
+-fi
+-AC_MSG_RESULT($have_sys_sdt_h)
++
++AC_ARG_ENABLE(systemtap,
++[AS_HELP_STRING([--disable-systemtap],
++ [enable systemtap static probe points [default=auto]])],
++ enable_systemtap=$enableval,
++ enable_systemtap=auto)
++
++if test x$enable_systemtap != xno; then
++ AC_MSG_CHECKING(sys/sdt.h in the target C library)
++ have_sys_sdt_h=no
++ if test -f $target_header_dir/sys/sdt.h ; then
++ have_sys_sdt_h=yes
++ AC_DEFINE(HAVE_SYS_SDT_H, 1,
++ [Define if your target C library provides sys/sdt.h])
++ fi
++ AC_MSG_RESULT($have_sys_sdt_h)
++ if test x$enable_systemtap = xyes ; then
++ if test x$have_sys_sdt_h = xno ; then
++ AC_MSG_ERROR([sys/sdt.h was not found])
++ fi
++ fi
++fi
+
+ # Check if TFmode long double should be used by default or not.
+ # Some glibc targets used DFmode long double, but with glibc 2.4
+--
+2.17.0
+
diff --git a/12.1.0/gentoo/14_all_respect-build-cxxflags.patch b/12.1.0/gentoo/14_all_respect-build-cxxflags.patch
new file mode 100644
index 0000000..1f9a774
--- /dev/null
+++ b/12.1.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/12.1.0/gentoo/20_all_libstdcxx-no-vtv.patch b/12.1.0/gentoo/20_all_libstdcxx-no-vtv.patch
new file mode 100644
index 0000000..2719e2d
--- /dev/null
+++ b/12.1.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/12.1.0/gentoo/22_all_default_ssp-buffer-size.patch b/12.1.0/gentoo/22_all_default_ssp-buffer-size.patch
new file mode 100644
index 0000000..0e0dd42
--- /dev/null
+++ b/12.1.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/12.0.0/gentoo/23_all_EXTRA_OPTIONS-z-now.patch b/12.1.0/gentoo/23_all_EXTRA_OPTIONS-z-now.patch
index 121dec4..8874b32 100644
--- a/12.0.0/gentoo/23_all_EXTRA_OPTIONS-z-now.patch
+++ b/12.1.0/gentoo/23_all_EXTRA_OPTIONS-z-now.patch
@@ -1,8 +1,8 @@
On Hardened we add some options like -z now
---- a/gcc/gcc.c 2016-02-19 23:18:38.000000000 +0100
-+++ b/gcc/gcc.c 2016-05-02 22:56:10.185721270 +0200
-@@ -868,6 +868,12 @@ proper position among the other output f
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -1001,6 +1001,12 @@ proper position among the other output files. */
#endif
#endif
@@ -13,9 +13,9 @@ On Hardened we add some options like -z now
+#endif
+
#ifdef ENABLE_DEFAULT_PIE
- #define NO_PIE_SPEC "no-pie|static"
- #define PIE_SPEC NO_PIE_SPEC "|r|shared:;"
-@@ -1013,7 +1020,7 @@ proper position among the other output f
+ #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*} \
@@ -23,4 +23,4 @@ On Hardened we add some options like -z now
+ %{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:%{!nostartfiles:%S}} \
+ %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \
diff --git a/12.1.0/gentoo/24_all_EXTRA_OPTIONS-fstack-clash-protection.patch b/12.1.0/gentoo/24_all_EXTRA_OPTIONS-fstack-clash-protection.patch
new file mode 100644
index 0000000..e1b3c54
--- /dev/null
+++ b/12.1.0/gentoo/24_all_EXTRA_OPTIONS-fstack-clash-protection.patch
@@ -0,0 +1,65 @@
+On Hardened we add some options like -fstack-clash-protection.
+
+--- a/gcc/common.opt
++++ a/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. */
++#ifdef EXTRA_OPTIONS
++#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/12.1.0/gentoo/25_all_lto-intl-workaround-PR95194.patch b/12.1.0/gentoo/25_all_lto-intl-workaround-PR95194.patch
new file mode 100644
index 0000000..9613216
--- /dev/null
+++ b/12.1.0/gentoo/25_all_lto-intl-workaround-PR95194.patch
@@ -0,0 +1,20 @@
+Trick libintl not to use '_INTL_REDIRECT_ASM' mode as it's
+incompatible with LTO builds.
+
+glibc does not normally use libintl implementations and uses
+it's own primitives. But musl ond others do fall back to libintl.
+
+Reported-by: Andrew Savchenko
+Bug: https://bugs.gentoo.org/723370
+Bug: https://gcc.gnu.org/PR95194
+--- a/intl/libgnuintl.h
++++ b/intl/libgnuintl.h
+@@ -93,7 +93,7 @@ extern "C" {
+ If he doesn't, we choose the method. A third possible method is
+ _INTL_REDIRECT_ASM, supported only by GCC. */
+ #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
+-# if __GNUC__ >= 2 && !defined __APPLE_CC__ && (defined __STDC__ || defined __cplusplus)
++# if __GNUC__ >= 2 && !defined __APPLE_CC__ && (defined __STDC__ || defined __cplusplus) && USE_ASM_ALIASES_THAT_BREAK_LTO
+ # define _INTL_REDIRECT_ASM
+ # else
+ # ifdef __cplusplus
diff --git a/12.1.0/gentoo/26_all_enable-cet.patch b/12.1.0/gentoo/26_all_enable-cet.patch
new file mode 100644
index 0000000..1d0c04f
--- /dev/null
+++ b/12.1.0/gentoo/26_all_enable-cet.patch
@@ -0,0 +1,206 @@
+https://bugs.gentoo.org/822036
+https://salsa.debian.org/toolchain-team/gcc/-/blob/master/debian/patches/gcc-distro-specs.diff
+
+From: Sam James <sam@gentoo.org>
+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
+@@ -51,7 +51,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-ts:-fmodule-header %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(default_flag_cf_spec) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s%V}"
+ " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:"
+@@ -72,7 +72,7 @@ along with GCC; see the file COPYING3. If not see
+ " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}"
+ " %{fmodules-ts:-fmodule-header=system"
+ " %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(default_flag_cf_spec) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s%V}"
+ " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:"
+@@ -92,7 +92,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-ts:-fmodule-header=user %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(default_flag_cf_spec) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s%V}"
+ " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:"
+@@ -107,7 +107,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)}}"
+@@ -116,7 +116,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
+@@ -1007,6 +1007,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. */
++#ifdef EXTRA_OPTIONS_CF
++#define DEFAULT_FLAG_CF_SPEC " %{!m16:%{!m32:%{!fcf-protection*:%{!fno-cf-protection:-fcf-protection}}}}"
++#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"
+@@ -1209,6 +1221,7 @@ static const char *cpp_spec = CPP_SPEC;
+ static const char *cc1_spec = 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;
+@@ -1267,7 +1280,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.
+
+@@ -1456,9 +1469,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}\
+@@ -1472,18 +1485,18 @@ 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)\
+ %{!fsyntax-only:%{!S:-o %g.s} \
+ %{!fdump-ada-spec*:%{!o*:--output-pch=%i.gch}\
+ %W{o*:--output-pch=%*}}%V}}\
+ %{!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:%{!S:-o %g.s} \
+ %{!fdump-ada-spec*:%{!o*:--output-pch=%i.gch}\
+ %W{o*:--output-pch=%*}}%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},
+@@ -1715,6 +1728,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/12.1.0/gentoo/27_all_plugin-objdump.patch b/12.1.0/gentoo/27_all_plugin-objdump.patch
new file mode 100644
index 0000000..059bca5
--- /dev/null
+++ b/12.1.0/gentoo/27_all_plugin-objdump.patch
@@ -0,0 +1,34 @@
+https://gcc.gnu.org/PR95648
+--- a/config/gcc-plugin.m4
++++ b/config/gcc-plugin.m4
+@@ -45,7 +45,7 @@ AC_DEFUN([GCC_ENABLE_PLUGINS],
+ ;;
+ *)
+ if test x$build = x$host; then
+- export_sym_check="objdump${exeext} -T"
++ export_sym_check="$ac_cv_prog_OBJDUMP -T"
+ elif test x$host = x$target; then
+ export_sym_check="$gcc_cv_objdump -T"
+ else
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -32075,7 +32075,7 @@ fi
+ ;;
+ *)
+ if test x$build = x$host; then
+- export_sym_check="objdump${exeext} -T"
++ export_sym_check="$ac_cv_prog_OBJDUMP -T"
+ elif test x$host = x$target; then
+ export_sym_check="$gcc_cv_objdump -T"
+ else
+--- a/libcc1/configure
++++ b/libcc1/configure
+@@ -15034,7 +15034,7 @@ fi
+ ;;
+ *)
+ if test x$build = x$host; then
+- export_sym_check="objdump${exeext} -T"
++ export_sym_check="$ac_cv_prog_OBJDUMP -T"
+ elif test x$host = x$target; then
+ export_sym_check="$gcc_cv_objdump -T"
+ else
diff --git a/12.1.0/gentoo/28_all_drop_CFLAGS_sed.patch b/12.1.0/gentoo/28_all_drop_CFLAGS_sed.patch
new file mode 100644
index 0000000..764f34c
--- /dev/null
+++ b/12.1.0/gentoo/28_all_drop_CFLAGS_sed.patch
@@ -0,0 +1,35 @@
+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
+@@ -5388,13 +5388,6 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
+ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+-# Remove the -O2: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[ ]//" -e "s/-O[gs][ ]//" -e "s/-O[0-9]*[ ]//" `
+- CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[ ]//" -e "s/-O[gs][ ]//" -e "s/-O[0-9]*[ ]//" ` ;;
+-esac
+
+
+
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -440,13 +440,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 the -O2: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" `
+- CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" ` ;;
+-esac
+ AC_SUBST(CFLAGS)
+ AC_SUBST(CXXFLAGS)
+ AC_SUBST(GDCFLAGS)
diff --git a/12.1.0/gentoo/29_all_msgfmt-libstdc++-link.patch b/12.1.0/gentoo/29_all_msgfmt-libstdc++-link.patch
new file mode 100644
index 0000000..0d2f113
--- /dev/null
+++ b/12.1.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/12.1.0/gentoo/README.history b/12.1.0/gentoo/README.history
new file mode 100644
index 0000000..1602600
--- /dev/null
+++ b/12.1.0/gentoo/README.history
@@ -0,0 +1,98 @@
+9 3 Jul 2022
+ + 29_all_msgfmt-libstdc++-link.patch
+
+8 26 Jun 2022
+
+ + 28_all_drop_CFLAGS_sed.patch
+
+7 30 May 2022
+
+ U 26_all_enable-cet.patch
+
+6 29 May 2022
+
+ + 26_all_enable-cet.patch
+
+5 25 Apr 2022
+
+ - 01_all_default-fortify-source.patch
+ - 03_all_default-warn-trampolines.patch
+ - 05_all_alpha-mieee-default.patch
+ - 06_all_ia64_note.GNU-stack.patch
+ - 08_all_libiberty-pic.patch
+ - 09_all_nopie-all-flags.patch
+ - 10_all_sh-drop-sysroot-suffix.patch
+ - 11_all_ia64-TEXTREL.patch
+ - 12_all_disable-systemtap-switch.patch
+ - 13_all_m68k-textrel-on-libgcc.patch
+ - 14_all_respect-build-cxxflags.patch
+ U 20_all_libstdcxx-no-vtv.patch
+ - 22_all_default_ssp-buffer-size.patch
+ - 23_all_EXTRA_OPTIONS-z-now.patch
+ - 24_all_EXTRA_OPTIONS-fstack-clash-protection.patch
+ - 26_all_plugin-objdump.patch
+
+4 26 Mar 2022
+
+ U 01_all_default-fortify-source.patch
+ U 03_all_default-warn-trampolines.patch
+ U 05_all_alpha-mieee-default.patch
+ U 06_all_ia64_note.GNU-stack.patch
+ U 08_all_libiberty-pic.patch
+ U 09_all_nopie-all-flags.patch
+ U 10_all_sh-drop-sysroot-suffix.patch
+ U 11_all_ia64-TEXTREL.patch
+ U 12_all_disable-systemtap-switch.patch
+ - 13_all_m68k-textrel-on-libgcc.patch
+ U 14_all_respect-build-cxxflags.patch
+ U 20_all_libstdcxx-no-vtv.patch
+ U 22_all_default_ssp-buffer-size.patch
+ U 23_all_EXTRA_OPTIONS-z-now.patch
+ U 24_all_EXTRA_OPTIONS-fstack-clash-protection.patch
+ U 26_all_plugin-objdump.patch
+
+3 5 Feb 2022
+
+ U 01_all_default-fortify-source.patch
+ U 02_all_default-warn-format-security.patch
+ U 04_all_nossp-on-nostdlib.patch
+ U 07_all_libiberty-asprintf.patch
+ U 11_all_ia64-TEXTREL.patch
+ - 15_all_libgomp-Werror.patch
+ - 16_all_libitm-Werror.patch
+ - 17_all_libatomic-Werror.patch
+ - 18_all_libbacktrace-Werror.patch
+ - 19_all_libsanitizer-Werror.patch
+ U 23_all_EXTRA_OPTIONS-z-now.patch
+ U 24_all_EXTRA_OPTIONS-fstack-clash-protection.patch
+
+2 28 July 2021
+ - 21_all_disable-riscv32-ABIs.patch
+
+1 20 Apr 2021
+ + 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
+ + 07_all_libiberty-asprintf.patch
+ + 08_all_libiberty-pic.patch
+ + 09_all_nopie-all-flags.patch
+ + 10_all_sh-drop-sysroot-suffix.patch
+ + 11_all_ia64-TEXTREL.patch
+ + 12_all_disable-systemtap-switch.patch
+ + 13_all_m68k-textrel-on-libgcc.patch
+ + 14_all_respect-build-cxxflags.patch
+ + 15_all_libgomp-Werror.patch
+ + 16_all_libitm-Werror.patch
+ + 17_all_libatomic-Werror.patch
+ + 18_all_libbacktrace-Werror.patch
+ + 19_all_libsanitizer-Werror.patch
+ + 20_all_libstdcxx-no-vtv.patch
+ + 21_all_disable-riscv32-ABIs.patch
+ + 22_all_default_ssp-buffer-size.patch
+ + 23_all_EXTRA_OPTIONS-z-now.patch
+ + 24_all_EXTRA_OPTIONS-fstack-clash-protection.patch
+ + 25_all_lto-intl-workaround-PR95194.patch
+ + 26_all_plugin-objdump.patch
diff --git a/12.1.0/musl/25_all_multilib_pure64.patch b/12.1.0/musl/25_all_multilib_pure64.patch
new file mode 100644
index 0000000..4ff0a25
--- /dev/null
+++ b/12.1.0/musl/25_all_multilib_pure64.patch
@@ -0,0 +1,89 @@
+https://bugs.gentoo.org/675954
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90077
+
+diff -Naur gcc-9.3.0.orig/gcc/config/aarch64/t-aarch64-linux gcc-9.3.0/gcc/config/aarch64/t-aarch64-linux
+--- gcc-9.3.0.orig/gcc/config/aarch64/t-aarch64-linux 2020-10-05 02:59:12.767988285 -0700
++++ gcc-9.3.0/gcc/config/aarch64/t-aarch64-linux 2020-10-05 03:03:32.310816444 -0700
+@@ -22,7 +22,7 @@
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+diff -Naur gcc-9.3.0.orig/gcc/config/i386/t-linux64 gcc-9.3.0/gcc/config/i386/t-linux64
+--- gcc-9.3.0.orig/gcc/config/i386/t-linux64 2020-10-05 02:59:12.757989347 -0700
++++ gcc-9.3.0/gcc/config/i386/t-linux64 2020-10-05 03:24:58.878825272 -0700
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
+-MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
++MULTILIB_OSDIRNAMES+= mx32=../libx32
+diff -Naur gcc-9.3.0.orig/gcc/config/rs6000/t-linux gcc-9.3.0/gcc/config/rs6000/t-linux
+--- gcc-9.3.0.orig/gcc/config/rs6000/t-linux 2020-10-05 02:59:12.767988285 -0700
++++ gcc-9.3.0/gcc/config/rs6000/t-linux 2020-10-05 03:03:32.310816444 -0700
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+
+diff -Naur gcc-9.3.0.orig/gcc/config/rs6000/t-linux64 gcc-9.3.0/gcc/config/rs6000/t-linux64
+--- gcc-9.3.0.orig/gcc/config/rs6000/t-linux64 2020-10-05 02:59:12.767988285 -0700
++++ gcc-9.3.0/gcc/config/rs6000/t-linux64 2020-10-05 03:03:32.310816444 -0700
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS := m64/m32
+ MULTILIB_DIRNAMES := 64 32
+ MULTILIB_EXTRA_OPTS :=
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ $(COMPILE) $<
+diff -Naur gcc-9.3.0.orig/gcc/config/rs6000/t-linux64bele gcc-9.3.0/gcc/config/rs6000/t-linux64bele
+--- gcc-9.3.0.orig/gcc/config/rs6000/t-linux64bele 2020-10-05 02:59:12.767988285 -0700
++++ gcc-9.3.0/gcc/config/rs6000/t-linux64bele 2020-10-05 03:03:32.310816444 -0700
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mlittle
+ MULTILIB_DIRNAMES += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
+diff -Naur gcc-9.3.0.orig/gcc/config/rs6000/t-linux64lebe gcc-9.3.0/gcc/config/rs6000/t-linux64lebe
+--- gcc-9.3.0.orig/gcc/config/rs6000/t-linux64lebe 2020-10-05 02:59:12.777987222 -0700
++++ gcc-9.3.0/gcc/config/rs6000/t-linux64lebe 2020-10-05 03:03:32.310816444 -0700
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mbig
+ MULTILIB_DIRNAMES += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
diff --git a/12.1.0/musl/50_all_cpu_indicator.patch b/12.1.0/musl/50_all_cpu_indicator.patch
new file mode 100644
index 0000000..a7d199f
--- /dev/null
+++ b/12.1.0/musl/50_all_cpu_indicator.patch
@@ -0,0 +1,35 @@
+From d16a8ceb1c3c8a7ec381090b4c316ff4c55661c0 Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 7 May 2020 21:14:11 -0500
+Subject: [PATCH] convert "__cpu_indicator_init" to
+ "__cpu_indicator_init_local"
+
+--- a/gcc/config/i386/i386-expand.cc
++++ b/gcc/config/i386/i386-expand.cc
+@@ -12338,10 +12338,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
+ {
+ case IX86_BUILTIN_CPU_INIT:
+ {
+- /* Make it call __cpu_indicator_init in libgcc. */
++ /* Make it call __cpu_indicator_init_local in libgcc. */
+ tree call_expr, fndecl, type;
+ type = build_function_type_list (integer_type_node, NULL_TREE);
+- fndecl = build_fn_decl ("__cpu_indicator_init", type);
++ fndecl = build_fn_decl ("__cpu_indicator_init_local", type);
+ call_expr = build_call_expr (fndecl, 0);
+ return expand_expr (call_expr, target, mode, EXPAND_NORMAL);
+ }
+
+--- a/libgcc/config/i386/cpuinfo.c
++++ b/libgcc/config/i386/cpuinfo.c
+@@ -508,7 +508,7 @@ __cpu_indicator_init (void)
+ return 0;
+ }
+
+-#if defined SHARED && defined USE_ELF_SYMVER
+-__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0");
+-__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0");
++#ifndef SHARED
++int __cpu_indicator_init_local (void)
++ __attribute__ ((weak, alias ("__cpu_indicator_init")));
+ #endif
diff --git a/12.1.0/musl/50_all_posix_memalign.patch b/12.1.0/musl/50_all_posix_memalign.patch
new file mode 100644
index 0000000..a288e1d
--- /dev/null
+++ b/12.1.0/musl/50_all_posix_memalign.patch
@@ -0,0 +1,29 @@
+diff -Naur gcc-7.1.0.orig/gcc/config/i386/pmm_malloc.h gcc-7.1.0/gcc/config/i386/pmm_malloc.h
+--- gcc-7.1.0.orig/gcc/config/i386/pmm_malloc.h 2017-01-01 04:07:43.000000000 -0800
++++ gcc-7.1.0/gcc/config/i386/pmm_malloc.h 2017-05-07 11:35:22.878398460 -0700
+@@ -27,12 +27,13 @@
+ #include <stdlib.h>
+
+ /* We can't depend on <stdlib.h> since the prototype of posix_memalign
+- may not be visible. */
++ may not be visible and we can't pollute the namespace either. */
+ #ifndef __cplusplus
+-extern int posix_memalign (void **, size_t, size_t);
++extern int __gcc_posix_memalign (void **, size_t, size_t)
+ #else
+-extern "C" int posix_memalign (void **, size_t, size_t) throw ();
++extern "C" int __gcc_posix_memalign (void **, size_t, size_t) throw ()
+ #endif
++__asm__("posix_memalign");
+
+ static __inline void *
+ _mm_malloc (size_t __size, size_t __alignment)
+@@ -42,7 +43,7 @@
+ return malloc (__size);
+ if (__alignment == 2 || (sizeof (void *) == 8 && __alignment == 4))
+ __alignment = sizeof (void *);
+- if (posix_memalign (&__ptr, __alignment, __size) == 0)
++ if (__gcc_posix_memalign (&__ptr, __alignment, __size) == 0)
+ return __ptr;
+ else
+ return NULL;
diff --git a/12.1.0/musl/README.history b/12.1.0/musl/README.history
new file mode 100644
index 0000000..0999249
--- /dev/null
+++ b/12.1.0/musl/README.history
@@ -0,0 +1,27 @@
+6 03 Jul 2022
+ - 50_all_calloc_libgccjit.patch
+
+5 26 Jun 2022
+ U 50_all_calloc_libgccjit.patch
+
+4 26 Jun 2022
+ U 50_all_calloc_libgccjit.patch
+
+3 25 Apr 2022
+
+ U 50_all_calloc_libgccjit.patch
+
+2 25 Apr 2022
+
+ 25_all_multilib_pure64.patch
+ 50_all_posix_memalign.patch
+ U 50_all_calloc_libgccjit.patch
+ 50_all_cpu_indicator.patch
+ nocross/50_all_libssp_unconditionally.patch
+
+1 25 Apr 2022
+
+ + 25_all_multilib_pure64.patch
+ + 50_all_posix_memalign.patch
+ + 50_all_cpu_indicator.patch
+ + nocross/50_all_libssp_unconditionally.patch
diff --git a/12.1.0/musl/nocross/50_all_libssp_unconditionally.patch b/12.1.0/musl/nocross/50_all_libssp_unconditionally.patch
new file mode 100644
index 0000000..a3b5984
--- /dev/null
+++ b/12.1.0/musl/nocross/50_all_libssp_unconditionally.patch
@@ -0,0 +1,24 @@
+https://bugs.gentoo.org/706210
+https://bugs.gentoo.org/747346
+
+Author: Timo Teräs <timo.teras@iki.fi>
+
+"Alpine musl package provides libssp_nonshared.a. We link to it unconditionally,
+as otherwise we get link failures if some objects are -fstack-protector built
+and final link happens with -fno-stack-protector. This seems to be the common
+case when bootstrapping gcc, the piepatches do not seem to fully fix the
+crosstoolchain and bootstrap sequence wrt. stack-protector flag usage."
+
+(We do the same in Gentoo.)
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -870,8 +870,7 @@
+
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+- "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ "|fstack-protector-strong|fstack-protector-explicit" \
diff --git a/12.2.0/gentoo/01_all_default-fortify-source.patch b/12.2.0/gentoo/01_all_default-fortify-source.patch
new file mode 100644
index 0000000..4cdf5f6
--- /dev/null
+++ b/12.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/12.2.0/gentoo/02_all_default-warn-format-security.patch b/12.2.0/gentoo/02_all_default-warn-format-security.patch
new file mode 100644
index 0000000..9723a1c
--- /dev/null
+++ b/12.2.0/gentoo/02_all_default-warn-format-security.patch
@@ -0,0 +1,22 @@
+Enable -Wformat and -Wformat-security by default.
+
+--- a/gcc/c-family/c.opt
++++ b/gcc/c-family/c.opt
+@@ -696,7 +696,7 @@ Warn about function calls with format strings that write past the end
+ of the destination region. Same as -Wformat-overflow=1.
+
+ 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
+@@ -717,7 +717,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.
+
+ Wformat-overflow=
diff --git a/12.2.0/gentoo/03_all_default-warn-trampolines.patch b/12.2.0/gentoo/03_all_default-warn-trampolines.patch
new file mode 100644
index 0000000..fb6d8bc
--- /dev/null
+++ b/12.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
+@@ -798,7 +798,7 @@ Common Var(warn_system_headers) Warning
+ Do not suppress warnings from system headers.
+
+ 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/12.2.0/gentoo/04_all_nossp-on-nostdlib.patch b/12.2.0/gentoo/04_all_nossp-on-nostdlib.patch
new file mode 100644
index 0000000..b633d7f
--- /dev/null
+++ b/12.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
+@@ -984,6 +984,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} "
++#else
++#define NO_SSP_SPEC ""
++#endif
++
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+@@ -1280,7 +1286,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|fprofile-generate*|coverage:\
+ %{!fprofile-update=single:\
diff --git a/12.2.0/gentoo/05_all_alpha-mieee-default.patch b/12.2.0/gentoo/05_all_alpha-mieee-default.patch
new file mode 100644
index 0000000..fd1de71
--- /dev/null
+++ b/12.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 <vapier@gentoo.org>
+
+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/12.2.0/gentoo/06_all_ia64_note.GNU-stack.patch b/12.2.0/gentoo/06_all_ia64_note.GNU-stack.patch
new file mode 100644
index 0000000..7a1d4c6
--- /dev/null
+++ b/12.2.0/gentoo/06_all_ia64_note.GNU-stack.patch
@@ -0,0 +1,92 @@
+http://gcc.gnu.org/PR21098
+
+
+2004-09-20 Jakub Jelinek <jakub@redhat.com>
+
+ * 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 <jakub@redhat.com>
+
+ * 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/12.2.0/gentoo/07_all_libiberty-asprintf.patch b/12.2.0/gentoo/07_all_libiberty-asprintf.patch
new file mode 100644
index 0000000..1ed2ba3
--- /dev/null
+++ b/12.2.0/gentoo/07_all_libiberty-asprintf.patch
@@ -0,0 +1,18 @@
+2008-07-25 Magnus Granberg <zorry@ume.nu>
+
+ * include/libiberty.h (asprintf): Don't declare if defined as a macro
+
+--- a/include/libiberty.h
++++ b/include/libiberty.h
+@@ -652,8 +652,11 @@ extern void *bsearch_r (const void *, const void *,
+ /* Like sprintf but provides a pointer to malloc'd storage, which must
+ be freed by the caller. */
+
++/* asprintf may be declared as a macro by glibc with __USE_FORTIFY_LEVEL. */
++#ifndef asprintf
+ extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
+ #endif
++#endif
+
+ /* Like asprintf but allocates memory without fail. This works like
+ xmalloc. */
diff --git a/12.2.0/gentoo/08_all_libiberty-pic.patch b/12.2.0/gentoo/08_all_libiberty-pic.patch
new file mode 100644
index 0000000..3f0bae1
--- /dev/null
+++ b/12.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/12.2.0/gentoo/09_all_nopie-all-flags.patch b/12.2.0/gentoo/09_all_nopie-all-flags.patch
new file mode 100644
index 0000000..fe1cd80
--- /dev/null
+++ b/12.2.0/gentoo/09_all_nopie-all-flags.patch
@@ -0,0 +1,18 @@
+We need to pass NO_PIE_CFLAGS to ALL_* so gcc don't fail when
+we compile it with older gcc and pie.
+
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -1054,10 +1054,10 @@ ALL_CXXFLAGS = $(T_CFLAGS) $(CFLAGS-$@)
+ ALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS)
+
+ # This is the variable to use when using $(COMPILER).
+-ALL_COMPILERFLAGS = $(ALL_CXXFLAGS)
++ALL_COMPILERFLAGS = $(NO_PIE_CFLAGS) $(ALL_CXXFLAGS)
+
+ # This is the variable to use when using $(LINKER).
+-ALL_LINKERFLAGS = $(ALL_CXXFLAGS)
++ALL_LINKERFLAGS = $(NO_PIE_CFLAGS) $(ALL_CXXFLAGS)
+
+ # Build and host support libraries.
+
diff --git a/12.2.0/gentoo/10_all_sh-drop-sysroot-suffix.patch b/12.2.0/gentoo/10_all_sh-drop-sysroot-suffix.patch
new file mode 100644
index 0000000..e778f81
--- /dev/null
+++ b/12.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 <slyfox@gentoo.org>
+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 <slyfox@gentoo.org>
+--- 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/12.2.0/gentoo/11_all_ia64-TEXTREL.patch b/12.2.0/gentoo/11_all_ia64-TEXTREL.patch
new file mode 100644
index 0000000..f5d0a99
--- /dev/null
+++ b/12.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/12.2.0/gentoo/12_all_disable-systemtap-switch.patch b/12.2.0/gentoo/12_all_disable-systemtap-switch.patch
new file mode 100644
index 0000000..989036c
--- /dev/null
+++ b/12.2.0/gentoo/12_all_disable-systemtap-switch.patch
@@ -0,0 +1,115 @@
+From bb510ed7ea82093c924b027489db6f92250a85b3 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Sat, 12 May 2018 12:56:46 +0100
+Subject: [PATCH] gcc/configure.ac: add --disable-systemtap switch
+
+Before the change systemtap probes were enabled
+if target headers had sys/sdt.h at ./configure time.
+
+After the change explicitly ask to enable or disable
+for probe support and not rely on automagic dependency
+discovery.
+
+Bug: https://bugs.gentoo.org/654748
+Bug: https://gcc.gnu.org/bugzilla/PR61257
+Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -1015,6 +1015,7 @@ enable_gnu_unique_object
+ enable_linker_build_id
+ enable_libssp
+ enable_default_ssp
++enable_systemtap
+ with_long_double_128
+ with_long_double_format
+ with_gc
+@@ -1773,6 +1774,7 @@ Optional Features:
+ compiler will always pass --build-id to linker
+ --enable-libssp enable linking against libssp
+ --enable-default-ssp enable Stack Smashing Protection as default
++ --disable-systemtap enable systemtap static probe points [default=auto]
+ --enable-maintainer-mode
+ enable make rules and dependencies not useful (and
+ sometimes confusing) to the casual installer
+@@ -31387,17 +31389,33 @@ fi
+
+ # Test for <sys/sdt.h> on the target.
+
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking sys/sdt.h in the target C library" >&5
++
++# Check whether --enable-systemtap was given.
++if test "${enable_systemtap+set}" = set; then :
++ enableval=$enable_systemtap; enable_systemtap=$enableval
++else
++ enable_systemtap=auto
++fi
++
++
++if test x$enable_systemtap != xno; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking sys/sdt.h in the target C library" >&5
+ $as_echo_n "checking sys/sdt.h in the target C library... " >&6; }
+-have_sys_sdt_h=no
+-if test -f $target_header_dir/sys/sdt.h; then
+- have_sys_sdt_h=yes
++ have_sys_sdt_h=no
++ if test -f $target_header_dir/sys/sdt.h ; then
++ have_sys_sdt_h=yes
+
+ $as_echo "#define HAVE_SYS_SDT_H 1" >>confdefs.h
+
+-fi
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_sys_sdt_h" >&5
++ fi
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_sys_sdt_h" >&5
+ $as_echo "$have_sys_sdt_h" >&6; }
++ if test x$enable_systemtap = xyes ; then
++ if test x$have_sys_sdt_h = xno ; then
++ as_fn_error $? "sys/sdt.h was not found" "$LINENO" 5
++ fi
++ fi
++fi
+
+ # Check if TFmode long double should be used by default or not.
+ # Some glibc targets used DFmode long double, but with glibc 2.4
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -6904,14 +6904,28 @@ AC_SUBST([enable_default_ssp])
+
+ # Test for <sys/sdt.h> on the target.
+ GCC_TARGET_TEMPLATE([HAVE_SYS_SDT_H])
+-AC_MSG_CHECKING(sys/sdt.h in the target C library)
+-have_sys_sdt_h=no
+-if test -f $target_header_dir/sys/sdt.h; then
+- have_sys_sdt_h=yes
+- AC_DEFINE(HAVE_SYS_SDT_H, 1,
+- [Define if your target C library provides sys/sdt.h])
+-fi
+-AC_MSG_RESULT($have_sys_sdt_h)
++
++AC_ARG_ENABLE(systemtap,
++[AS_HELP_STRING([--disable-systemtap],
++ [enable systemtap static probe points [default=auto]])],
++ enable_systemtap=$enableval,
++ enable_systemtap=auto)
++
++if test x$enable_systemtap != xno; then
++ AC_MSG_CHECKING(sys/sdt.h in the target C library)
++ have_sys_sdt_h=no
++ if test -f $target_header_dir/sys/sdt.h ; then
++ have_sys_sdt_h=yes
++ AC_DEFINE(HAVE_SYS_SDT_H, 1,
++ [Define if your target C library provides sys/sdt.h])
++ fi
++ AC_MSG_RESULT($have_sys_sdt_h)
++ if test x$enable_systemtap = xyes ; then
++ if test x$have_sys_sdt_h = xno ; then
++ AC_MSG_ERROR([sys/sdt.h was not found])
++ fi
++ fi
++fi
+
+ # Check if TFmode long double should be used by default or not.
+ # Some glibc targets used DFmode long double, but with glibc 2.4
+--
+2.17.0
+
diff --git a/12.2.0/gentoo/14_all_respect-build-cxxflags.patch b/12.2.0/gentoo/14_all_respect-build-cxxflags.patch
new file mode 100644
index 0000000..1f9a774
--- /dev/null
+++ b/12.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/12.2.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch b/12.2.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch
new file mode 100644
index 0000000..2daf73b
--- /dev/null
+++ b/12.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
+@@ -957,6 +957,10 @@ c_cpp_builtins (cpp_reader *pfile)
+ cpp_define (pfile, "__cpp_rtti=199711L");
+ }
+
++ #ifdef DEF_GENTOO_GLIBCXX_ASSERTIONS
++ cpp_define (pfile, "_GLIBCXX_ASSERTIONS");
++ #endif
++
+ if (cxx_dialect >= cxx11)
+ cpp_define (pfile, "__GXX_EXPERIMENTAL_CXX0X__");
+
diff --git a/12.2.0/gentoo/20_all_libstdcxx-no-vtv.patch b/12.2.0/gentoo/20_all_libstdcxx-no-vtv.patch
new file mode 100644
index 0000000..2719e2d
--- /dev/null
+++ b/12.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/12.2.0/gentoo/22_all_default_ssp-buffer-size.patch b/12.2.0/gentoo/22_all_default_ssp-buffer-size.patch
new file mode 100644
index 0000000..0e0dd42
--- /dev/null
+++ b/12.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/12.2.0/gentoo/23_all_DEF_GENTOO_ZNOW-z-now.patch b/12.2.0/gentoo/23_all_DEF_GENTOO_ZNOW-z-now.patch
new file mode 100644
index 0000000..2ed7968
--- /dev/null
+++ b/12.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/12.2.0/gentoo/24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch b/12.2.0/gentoo/24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch
new file mode 100644
index 0000000..b13215d
--- /dev/null
+++ b/12.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. */
++#ifdef DEF_GENTOO_SCP
++#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/12.2.0/gentoo/25_all_lto-intl-workaround-PR95194.patch b/12.2.0/gentoo/25_all_lto-intl-workaround-PR95194.patch
new file mode 100644
index 0000000..9613216
--- /dev/null
+++ b/12.2.0/gentoo/25_all_lto-intl-workaround-PR95194.patch
@@ -0,0 +1,20 @@
+Trick libintl not to use '_INTL_REDIRECT_ASM' mode as it's
+incompatible with LTO builds.
+
+glibc does not normally use libintl implementations and uses
+it's own primitives. But musl ond others do fall back to libintl.
+
+Reported-by: Andrew Savchenko
+Bug: https://bugs.gentoo.org/723370
+Bug: https://gcc.gnu.org/PR95194
+--- a/intl/libgnuintl.h
++++ b/intl/libgnuintl.h
+@@ -93,7 +93,7 @@ extern "C" {
+ If he doesn't, we choose the method. A third possible method is
+ _INTL_REDIRECT_ASM, supported only by GCC. */
+ #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
+-# if __GNUC__ >= 2 && !defined __APPLE_CC__ && (defined __STDC__ || defined __cplusplus)
++# if __GNUC__ >= 2 && !defined __APPLE_CC__ && (defined __STDC__ || defined __cplusplus) && USE_ASM_ALIASES_THAT_BREAK_LTO
+ # define _INTL_REDIRECT_ASM
+ # else
+ # ifdef __cplusplus
diff --git a/12.2.0/gentoo/26_all_enable-cet.patch b/12.2.0/gentoo/26_all_enable-cet.patch
new file mode 100644
index 0000000..1d0c04f
--- /dev/null
+++ b/12.2.0/gentoo/26_all_enable-cet.patch
@@ -0,0 +1,206 @@
+https://bugs.gentoo.org/822036
+https://salsa.debian.org/toolchain-team/gcc/-/blob/master/debian/patches/gcc-distro-specs.diff
+
+From: Sam James <sam@gentoo.org>
+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
+@@ -51,7 +51,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-ts:-fmodule-header %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(default_flag_cf_spec) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s%V}"
+ " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:"
+@@ -72,7 +72,7 @@ along with GCC; see the file COPYING3. If not see
+ " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}"
+ " %{fmodules-ts:-fmodule-header=system"
+ " %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(default_flag_cf_spec) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s%V}"
+ " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:"
+@@ -92,7 +92,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-ts:-fmodule-header=user %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(default_flag_cf_spec) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s%V}"
+ " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:"
+@@ -107,7 +107,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)}}"
+@@ -116,7 +116,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
+@@ -1007,6 +1007,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. */
++#ifdef EXTRA_OPTIONS_CF
++#define DEFAULT_FLAG_CF_SPEC " %{!m16:%{!m32:%{!fcf-protection*:%{!fno-cf-protection:-fcf-protection}}}}"
++#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"
+@@ -1209,6 +1221,7 @@ static const char *cpp_spec = CPP_SPEC;
+ static const char *cc1_spec = 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;
+@@ -1267,7 +1280,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.
+
+@@ -1456,9 +1469,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}\
+@@ -1472,18 +1485,18 @@ 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)\
+ %{!fsyntax-only:%{!S:-o %g.s} \
+ %{!fdump-ada-spec*:%{!o*:--output-pch=%i.gch}\
+ %W{o*:--output-pch=%*}}%V}}\
+ %{!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:%{!S:-o %g.s} \
+ %{!fdump-ada-spec*:%{!o*:--output-pch=%i.gch}\
+ %W{o*:--output-pch=%*}}%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},
+@@ -1715,6 +1728,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/12.2.0/gentoo/27_all_plugin-objdump.patch b/12.2.0/gentoo/27_all_plugin-objdump.patch
new file mode 100644
index 0000000..059bca5
--- /dev/null
+++ b/12.2.0/gentoo/27_all_plugin-objdump.patch
@@ -0,0 +1,34 @@
+https://gcc.gnu.org/PR95648
+--- a/config/gcc-plugin.m4
++++ b/config/gcc-plugin.m4
+@@ -45,7 +45,7 @@ AC_DEFUN([GCC_ENABLE_PLUGINS],
+ ;;
+ *)
+ if test x$build = x$host; then
+- export_sym_check="objdump${exeext} -T"
++ export_sym_check="$ac_cv_prog_OBJDUMP -T"
+ elif test x$host = x$target; then
+ export_sym_check="$gcc_cv_objdump -T"
+ else
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -32075,7 +32075,7 @@ fi
+ ;;
+ *)
+ if test x$build = x$host; then
+- export_sym_check="objdump${exeext} -T"
++ export_sym_check="$ac_cv_prog_OBJDUMP -T"
+ elif test x$host = x$target; then
+ export_sym_check="$gcc_cv_objdump -T"
+ else
+--- a/libcc1/configure
++++ b/libcc1/configure
+@@ -15034,7 +15034,7 @@ fi
+ ;;
+ *)
+ if test x$build = x$host; then
+- export_sym_check="objdump${exeext} -T"
++ export_sym_check="$ac_cv_prog_OBJDUMP -T"
+ elif test x$host = x$target; then
+ export_sym_check="$gcc_cv_objdump -T"
+ else
diff --git a/12.2.0/gentoo/28_all_drop_CFLAGS_sed.patch b/12.2.0/gentoo/28_all_drop_CFLAGS_sed.patch
new file mode 100644
index 0000000..764f34c
--- /dev/null
+++ b/12.2.0/gentoo/28_all_drop_CFLAGS_sed.patch
@@ -0,0 +1,35 @@
+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
+@@ -5388,13 +5388,6 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
+ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+-# Remove the -O2: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[ ]//" -e "s/-O[gs][ ]//" -e "s/-O[0-9]*[ ]//" `
+- CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[ ]//" -e "s/-O[gs][ ]//" -e "s/-O[0-9]*[ ]//" ` ;;
+-esac
+
+
+
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -440,13 +440,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 the -O2: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" `
+- CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" ` ;;
+-esac
+ AC_SUBST(CFLAGS)
+ AC_SUBST(CXXFLAGS)
+ AC_SUBST(GDCFLAGS)
diff --git a/12.2.0/gentoo/29_all_msgfmt-libstdc++-link.patch b/12.2.0/gentoo/29_all_msgfmt-libstdc++-link.patch
new file mode 100644
index 0000000..0d2f113
--- /dev/null
+++ b/12.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/12.2.0/gentoo/30_all_tar_libstdc++-link.patch b/12.2.0/gentoo/30_all_tar_libstdc++-link.patch
new file mode 100644
index 0000000..149d614
--- /dev/null
+++ b/12.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 <sam@gentoo.org>
+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 <sam@gentoo.org>
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -3934,10 +3934,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.
+@@ -3958,7 +3958,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/12.2.0/gentoo/75_all_go_posix_shell_arithmetic_nonbash.patch b/12.2.0/gentoo/75_all_go_posix_shell_arithmetic_nonbash.patch
new file mode 100644
index 0000000..57e9060
--- /dev/null
+++ b/12.2.0/gentoo/75_all_go_posix_shell_arithmetic_nonbash.patch
@@ -0,0 +1,40 @@
+https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=cf1725610526fe347d2530455b32affc033fd7fc
+
+From cf1725610526fe347d2530455b32affc033fd7fc Mon Sep 17 00:00:00 2001
+From: Ian Lance Taylor <iant@golang.org>
+Date: Fri, 22 Jul 2022 11:38:20 -0700
+Subject: [PATCH] libgo: use POSIX shell arithmetic expansion
+MIME-Version: 1.0
+Content-Type: text/plain; charset=utf8
+Content-Transfer-Encoding: 8bit
+
+Avoid bash-specific ((expression)) syntax. As the bash syntax
+converts a non-zero value to a zero status (and a zero value to a 1
+status), and POSIX arithmetic expansion does not, we have to negate
+the result.
+
+Based on patch by Sören Tempel.
+
+Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/419154
+--- a/libgo/match.sh
++++ b/libgo/match.sh
+@@ -111,7 +111,7 @@ gobuild() {
+ if test "$goarch" != "386"; then
+ line=$(echo "$line" | sed -e "s/\\(${wrap}\\)386\\(${wrap}\\)/\10\2/g")
+ fi
+- (($line))
++ return $((!($line)))
+ }
+
+ matched=
+--- a/libgo/testsuite/gotest
++++ b/libgo/testsuite/gotest
+@@ -302,7 +302,7 @@ gobuild() {
+ if test "$goarch" != "386"; then
+ line=$(echo "$line" | sed -e "s/\\(${wrap}\\)386\\(${wrap}\\)/\10\2/g")
+ fi
+- (($line))
++ return $((!($line)))
+ }
+
+ case "x$gofiles" in
diff --git a/12.2.0/gentoo/76_all_all_PR109573_12_ICE-in-vectorizable_live_operation.patch b/12.2.0/gentoo/76_all_all_PR109573_12_ICE-in-vectorizable_live_operation.patch
new file mode 100644
index 0000000..bf3b48a
--- /dev/null
+++ b/12.2.0/gentoo/76_all_all_PR109573_12_ICE-in-vectorizable_live_operation.patch
@@ -0,0 +1,131 @@
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109573
+https://bugs.gentoo.org/904455
+
+From cddfe6bc40b3dc0806e260bbfb4cac82d609a258 Mon Sep 17 00:00:00 2001
+From: Richard Biener <rguenther@suse.de>
+Date: Fri, 21 Apr 2023 12:57:17 +0200
+Subject: [PATCH] tree-optimization/109573 - avoid ICEing on unexpected live
+ def
+
+The following relaxes the assert in vectorizable_live_operation
+where we catch currently unhandled cases to also allow an
+intermediate copy as it happens here but also relax the assert
+to checking only.
+
+ PR tree-optimization/109573
+ * tree-vect-loop.cc (vectorizable_live_operation): Allow
+ unhandled SSA copy as well. Demote assert to checking only.
+
+ * g++.dg/vect/pr109573.cc: New testcase.
+--- /dev/null
++++ b/gcc/testsuite/g++.dg/vect/pr109573.cc
+@@ -0,0 +1,91 @@
++// { dg-do compile }
++// { dg-require-effective-target c++20 }
++
++void *operator new(__SIZE_TYPE__, void *__p) { return __p; }
++template <typename _Head> struct _Head_base {
++ _Head _M_head_impl;
++};
++template <unsigned long, typename...> struct _Tuple_impl;
++template <unsigned long _Idx, typename _Head, typename... _Tail>
++struct _Tuple_impl<_Idx, _Head, _Tail...> : _Tuple_impl<_Idx + 1, _Tail...>,
++ _Head_base<_Head> {
++ template <typename _UHead, typename... _UTail>
++ _Tuple_impl(_UHead __head, _UTail... __tail)
++ : _Tuple_impl<_Idx + 1, _Tail...>(__tail...), _Head_base<_Head>(__head) {}
++};
++template <unsigned long _Idx, typename _Head> struct _Tuple_impl<_Idx, _Head> {
++ template <typename _UHead> _Tuple_impl(_UHead);
++};
++template <typename... _Elements> struct tuple : _Tuple_impl<0, _Elements...> {
++ template <typename... _UElements>
++ tuple(_UElements... __elements)
++ : _Tuple_impl<0, _Elements...>(__elements...) {}
++};
++unsigned long position_;
++struct Zone {
++ template <typename T, typename... Args> T *New(Args... args) {
++ return new (reinterpret_cast<void *>(position_)) T(args...);
++ }
++};
++struct Label {
++ int pos_;
++ int near_link_pos_;
++};
++enum Condition { below_equal };
++void bind(Label *);
++Zone *zone();
++unsigned long deopt_info_address();
++int MakeDeferredCode___trans_tmp_2, MakeDeferredCode___trans_tmp_3,
++ Prologue___trans_tmp_6, MakeDeferredCode___trans_tmp_1;
++struct MaglevAssembler {
++ template <typename Function, typename... Args>
++ void MakeDeferredCode(Function &&, Args &&...);
++ template <typename Function, typename... Args>
++ void JumpToDeferredIf(Condition, Function, Args... args) {
++ MakeDeferredCode(Function(), args...);
++ }
++ void Prologue();
++};
++struct ZoneLabelRef {
++ ZoneLabelRef(Zone *zone) : label_(zone->New<Label>()) {}
++ ZoneLabelRef(MaglevAssembler *) : ZoneLabelRef(zone()) {}
++ Label *operator*() { return label_; }
++ Label *label_;
++};
++template <typename Function>
++struct FunctionArgumentsTupleHelper
++ : FunctionArgumentsTupleHelper<decltype(&Function::operator())> {};
++template <typename C, typename R, typename... A>
++struct FunctionArgumentsTupleHelper<R (C::*)(A...) const> {
++ using Tuple = tuple<A...>;
++};
++template <typename> struct StripFirstTupleArg;
++template <typename T1, typename... T>
++struct StripFirstTupleArg<tuple<T1, T...>> {
++ using Stripped = tuple<T...>;
++};
++template <typename Function> struct DeferredCodeInfoImpl {
++ template <typename... InArgs>
++ DeferredCodeInfoImpl(int *, int, int, Function, InArgs... args)
++ : args(args...) {}
++ StripFirstTupleArg<
++ typename FunctionArgumentsTupleHelper<Function>::Tuple>::Stripped args;
++};
++template <typename Function, typename... Args>
++void MaglevAssembler::MakeDeferredCode(Function &&deferred_code_gen,
++ Args &&...args) {
++ zone()->New<DeferredCodeInfoImpl<Function>>(
++ &MakeDeferredCode___trans_tmp_1, MakeDeferredCode___trans_tmp_2,
++ MakeDeferredCode___trans_tmp_3, deferred_code_gen, args...);
++}
++void MaglevAssembler::Prologue() {
++ int *__trans_tmp_9;
++ ZoneLabelRef deferred_call_stack_guard_return(this);
++ __trans_tmp_9 = reinterpret_cast<int *>(deopt_info_address());
++ JumpToDeferredIf(
++ below_equal, [](MaglevAssembler, int *, ZoneLabelRef, int, int) {},
++ __trans_tmp_9, deferred_call_stack_guard_return, Prologue___trans_tmp_6,
++ 0);
++ Label __trans_tmp_7 = **deferred_call_stack_guard_return;
++ bind(&__trans_tmp_7);
++}
+--- a/gcc/tree-vect-loop.cc
++++ b/gcc/tree-vect-loop.cc
+@@ -10114,9 +10114,10 @@ vectorizable_live_operation (vec_info *vinfo,
+ use_stmt))
+ {
+ enum tree_code code = gimple_assign_rhs_code (use_stmt);
+- gcc_assert (code == CONSTRUCTOR
+- || code == VIEW_CONVERT_EXPR
+- || CONVERT_EXPR_CODE_P (code));
++ gcc_checking_assert (code == SSA_NAME
++ || code == CONSTRUCTOR
++ || code == VIEW_CONVERT_EXPR
++ || CONVERT_EXPR_CODE_P (code));
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+ "Using original scalar computation for "
+--
+2.31.1
diff --git a/12.2.0/gentoo/README.history b/12.2.0/gentoo/README.history
new file mode 100644
index 0000000..521b11e
--- /dev/null
+++ b/12.2.0/gentoo/README.history
@@ -0,0 +1,77 @@
+15 22 Apr 2023
+ + 76_all_all_PR109573_12_ICE-in-vectorizable_live_operation.patch
+
+14 13 Mar 2023
+ U 01_all_default-fortify-source.patch
+
+13 12 Feb 2023
+ - 76_all_all_PR107461_cxx_equivalence_non_dependent_calls.patch
+
+12 6 Feb 2023
+ + 76_all_all_PR107461_cxx_equivalence_non_dependent_calls.patch
+
+11 29 Jan 2023
+ - 76_all_driver_environ_putenv_PR106624.patch
+
+10 23 Jan 2023
+ + 76_all_driver_environ_putenv_PR106624.patch
+
+9 8 Jan 2023
+ - 76_all_libsanitizer-implicit-function-decls.patch
+ - 77_all_libiberty-fix-c89-isms-in-configure.patch
+
+8 28 Dec 2022
+ U 01_all_default-fortify-source.patch
+ + 15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch
+
+7 25 Dec 2022
+ - 78_all_Factor-out-jobserver_active_p.patch
+ - 79_all_lto-support-jobserver-style-fifo-for-recent-GNU-make.patch
+ - 80_all_lto-respect-jobserver-in-parallel-WPA-streaming.patch
+ - 81_all_jobserver-fix-fifo-mode-by-opening-pipe-in-proper-mo.patch
+
+6 17 Dec 2022
+ U 30_all_tar_libstdc++-link.patch
+
+5 17 Dec 2022
+ + 30_all_tar_libstdc++-link.patch
+
+4 9 Dec 2022
+ + 78_all_Factor-out-jobserver_active_p.patch
+ + 79_all_lto-support-jobserver-style-fifo-for-recent-GNU-make.patch
+ + 80_all_lto-respect-jobserver-in-parallel-WPA-streaming.patch
+ + 81_all_jobserver-fix-fifo-mode-by-opening-pipe-in-proper-mo.patch
+
+3 5 Dec 2022
+ - 23_all_EXTRA_OPTIONS-z-now.patch
+ + 23_all_DEF_GENTOO_ZNOW-z-now.patch
+ - 24_all_EXTRA_OPTIONS-fstack-clash-protection.patch
+ + 24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch
+
+2 19 Nov 2022
+ + 76_all_libsanitizer-implicit-function-decls.patch
+ + 77_all_libiberty-fix-c89-isms-in-configure.patch
+
+1 22 Aug 2022
+ + 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
+ + 07_all_libiberty-asprintf.patch
+ + 08_all_libiberty-pic.patch
+ + 09_all_nopie-all-flags.patch
+ + 10_all_sh-drop-sysroot-suffix.patch
+ + 11_all_ia64-TEXTREL.patch
+ + 12_all_disable-systemtap-switch.patch
+ + 14_all_respect-build-cxxflags.patch
+ + 20_all_libstdcxx-no-vtv.patch
+ + 22_all_default_ssp-buffer-size.patch
+ + 23_all_EXTRA_OPTIONS-z-now.patch
+ + 24_all_EXTRA_OPTIONS-fstack-clash-protection.patch
+ + 25_all_lto-intl-workaround-PR95194.patch
+ + 26_all_enable-cet.patch
+ + 27_all_plugin-objdump.patch
+ + 28_all_drop_CFLAGS_sed.patch
+ + 29_all_msgfmt-libstdc++-link.patch
diff --git a/12.2.0/musl/25_all_multilib_pure64.patch b/12.2.0/musl/25_all_multilib_pure64.patch
new file mode 100644
index 0000000..d55c04c
--- /dev/null
+++ b/12.2.0/musl/25_all_multilib_pure64.patch
@@ -0,0 +1,83 @@
+https://bugs.gentoo.org/675954
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90077
+
+--- a/gcc/config/aarch64/t-aarch64-linux
++++ b/gcc/config/aarch64/t-aarch64-linux
+@@ -22,7 +22,7 @@
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+--- a/gcc/config/i386/t-linux64
++++ b/gcc/config/i386/t-linux64
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
+-MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
++MULTILIB_OSDIRNAMES+= mx32=../libx32
+--- a/gcc/config/rs6000/t-linux
++++ b/gcc/config/rs6000/t-linux
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+
+--- a/gcc/config/rs6000/t-linux64
++++ b/gcc/config/rs6000/t-linux64
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS := m64/m32
+ MULTILIB_DIRNAMES := 64 32
+ MULTILIB_EXTRA_OPTS :=
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ $(COMPILE) $<
+--- a/gcc/config/rs6000/t-linux64bele
++++ b/gcc/config/rs6000/t-linux64bele
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mlittle
+ MULTILIB_DIRNAMES += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/rs6000/t-linux64lebe
++++ b/gcc/config/rs6000/t-linux64lebe
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mbig
+ MULTILIB_DIRNAMES += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
diff --git a/12.2.0/musl/50_all_cpu_indicator.patch b/12.2.0/musl/50_all_cpu_indicator.patch
new file mode 100644
index 0000000..a7d199f
--- /dev/null
+++ b/12.2.0/musl/50_all_cpu_indicator.patch
@@ -0,0 +1,35 @@
+From d16a8ceb1c3c8a7ec381090b4c316ff4c55661c0 Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 7 May 2020 21:14:11 -0500
+Subject: [PATCH] convert "__cpu_indicator_init" to
+ "__cpu_indicator_init_local"
+
+--- a/gcc/config/i386/i386-expand.cc
++++ b/gcc/config/i386/i386-expand.cc
+@@ -12338,10 +12338,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
+ {
+ case IX86_BUILTIN_CPU_INIT:
+ {
+- /* Make it call __cpu_indicator_init in libgcc. */
++ /* Make it call __cpu_indicator_init_local in libgcc. */
+ tree call_expr, fndecl, type;
+ type = build_function_type_list (integer_type_node, NULL_TREE);
+- fndecl = build_fn_decl ("__cpu_indicator_init", type);
++ fndecl = build_fn_decl ("__cpu_indicator_init_local", type);
+ call_expr = build_call_expr (fndecl, 0);
+ return expand_expr (call_expr, target, mode, EXPAND_NORMAL);
+ }
+
+--- a/libgcc/config/i386/cpuinfo.c
++++ b/libgcc/config/i386/cpuinfo.c
+@@ -508,7 +508,7 @@ __cpu_indicator_init (void)
+ return 0;
+ }
+
+-#if defined SHARED && defined USE_ELF_SYMVER
+-__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0");
+-__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0");
++#ifndef SHARED
++int __cpu_indicator_init_local (void)
++ __attribute__ ((weak, alias ("__cpu_indicator_init")));
+ #endif
diff --git a/12.2.0/musl/50_all_libssp_unconditionally.patch b/12.2.0/musl/50_all_libssp_unconditionally.patch
new file mode 100644
index 0000000..a3b5984
--- /dev/null
+++ b/12.2.0/musl/50_all_libssp_unconditionally.patch
@@ -0,0 +1,24 @@
+https://bugs.gentoo.org/706210
+https://bugs.gentoo.org/747346
+
+Author: Timo Teräs <timo.teras@iki.fi>
+
+"Alpine musl package provides libssp_nonshared.a. We link to it unconditionally,
+as otherwise we get link failures if some objects are -fstack-protector built
+and final link happens with -fno-stack-protector. This seems to be the common
+case when bootstrapping gcc, the piepatches do not seem to fully fix the
+crosstoolchain and bootstrap sequence wrt. stack-protector flag usage."
+
+(We do the same in Gentoo.)
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -870,8 +870,7 @@
+
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+- "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ "|fstack-protector-strong|fstack-protector-explicit" \
diff --git a/12.2.0/musl/50_all_posix_memalign.patch b/12.2.0/musl/50_all_posix_memalign.patch
new file mode 100644
index 0000000..dd75a93
--- /dev/null
+++ b/12.2.0/musl/50_all_posix_memalign.patch
@@ -0,0 +1,28 @@
+--- a/gcc/config/i386/pmm_malloc.h
++++ b/gcc/config/i386/pmm_malloc.h
+@@ -27,12 +27,13 @@
+ #include <stdlib.h>
+
+ /* We can't depend on <stdlib.h> since the prototype of posix_memalign
+- may not be visible. */
++ may not be visible and we can't pollute the namespace either. */
+ #ifndef __cplusplus
+-extern int posix_memalign (void **, size_t, size_t);
++extern int __gcc_posix_memalign (void **, size_t, size_t)
+ #else
+-extern "C" int posix_memalign (void **, size_t, size_t) throw ();
++extern "C" int __gcc_posix_memalign (void **, size_t, size_t) throw ()
+ #endif
++__asm__("posix_memalign");
+
+ static __inline void *
+ _mm_malloc (size_t __size, size_t __alignment)
+@@ -42,7 +43,7 @@
+ return malloc (__size);
+ if (__alignment == 2 || (sizeof (void *) == 8 && __alignment == 4))
+ __alignment = sizeof (void *);
+- if (posix_memalign (&__ptr, __alignment, __size) == 0)
++ if (__gcc_posix_memalign (&__ptr, __alignment, __size) == 0)
+ return __ptr;
+ else
+ return NULL;
diff --git a/12.2.0/musl/README.history b/12.2.0/musl/README.history
new file mode 100644
index 0000000..56093c5
--- /dev/null
+++ b/12.2.0/musl/README.history
@@ -0,0 +1,30 @@
+7 29 Jan 2022
+ U 50_all_libssp_unconditionally.patch
+
+6 03 Jul 2022
+ - 50_all_calloc_libgccjit.patch
+
+5 26 Jun 2022
+ U 50_all_calloc_libgccjit.patch
+
+4 26 Jun 2022
+ U 50_all_calloc_libgccjit.patch
+
+3 25 Apr 2022
+
+ U 50_all_calloc_libgccjit.patch
+
+2 25 Apr 2022
+
+ 25_all_multilib_pure64.patch
+ 50_all_posix_memalign.patch
+ U 50_all_calloc_libgccjit.patch
+ 50_all_cpu_indicator.patch
+ nocross/50_all_libssp_unconditionally.patch
+
+1 25 Apr 2022
+
+ + 25_all_multilib_pure64.patch
+ + 50_all_posix_memalign.patch
+ + 50_all_cpu_indicator.patch
+ + nocross/50_all_libssp_unconditionally.patch
diff --git a/12.3.0/gentoo/01_all_default-fortify-source.patch b/12.3.0/gentoo/01_all_default-fortify-source.patch
new file mode 100644
index 0000000..4cdf5f6
--- /dev/null
+++ b/12.3.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/12.3.0/gentoo/02_all_default-warn-format-security.patch b/12.3.0/gentoo/02_all_default-warn-format-security.patch
new file mode 100644
index 0000000..9723a1c
--- /dev/null
+++ b/12.3.0/gentoo/02_all_default-warn-format-security.patch
@@ -0,0 +1,22 @@
+Enable -Wformat and -Wformat-security by default.
+
+--- a/gcc/c-family/c.opt
++++ b/gcc/c-family/c.opt
+@@ -696,7 +696,7 @@ Warn about function calls with format strings that write past the end
+ of the destination region. Same as -Wformat-overflow=1.
+
+ 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
+@@ -717,7 +717,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.
+
+ Wformat-overflow=
diff --git a/12.3.0/gentoo/03_all_default-warn-trampolines.patch b/12.3.0/gentoo/03_all_default-warn-trampolines.patch
new file mode 100644
index 0000000..fb6d8bc
--- /dev/null
+++ b/12.3.0/gentoo/03_all_default-warn-trampolines.patch
@@ -0,0 +1,13 @@
+Enable -Wtrampolines by default.
+
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -798,7 +798,7 @@ Common Var(warn_system_headers) Warning
+ Do not suppress warnings from system headers.
+
+ 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/12.3.0/gentoo/04_all_nossp-on-nostdlib.patch b/12.3.0/gentoo/04_all_nossp-on-nostdlib.patch
new file mode 100644
index 0000000..b633d7f
--- /dev/null
+++ b/12.3.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
+@@ -984,6 +984,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} "
++#else
++#define NO_SSP_SPEC ""
++#endif
++
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+@@ -1280,7 +1286,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|fprofile-generate*|coverage:\
+ %{!fprofile-update=single:\
diff --git a/12.3.0/gentoo/05_all_alpha-mieee-default.patch b/12.3.0/gentoo/05_all_alpha-mieee-default.patch
new file mode 100644
index 0000000..fd1de71
--- /dev/null
+++ b/12.3.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 <vapier@gentoo.org>
+
+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/12.3.0/gentoo/06_all_ia64_note.GNU-stack.patch b/12.3.0/gentoo/06_all_ia64_note.GNU-stack.patch
new file mode 100644
index 0000000..7a1d4c6
--- /dev/null
+++ b/12.3.0/gentoo/06_all_ia64_note.GNU-stack.patch
@@ -0,0 +1,92 @@
+http://gcc.gnu.org/PR21098
+
+
+2004-09-20 Jakub Jelinek <jakub@redhat.com>
+
+ * 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 <jakub@redhat.com>
+
+ * 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/12.3.0/gentoo/07_all_libiberty-asprintf.patch b/12.3.0/gentoo/07_all_libiberty-asprintf.patch
new file mode 100644
index 0000000..1ed2ba3
--- /dev/null
+++ b/12.3.0/gentoo/07_all_libiberty-asprintf.patch
@@ -0,0 +1,18 @@
+2008-07-25 Magnus Granberg <zorry@ume.nu>
+
+ * include/libiberty.h (asprintf): Don't declare if defined as a macro
+
+--- a/include/libiberty.h
++++ b/include/libiberty.h
+@@ -652,8 +652,11 @@ extern void *bsearch_r (const void *, const void *,
+ /* Like sprintf but provides a pointer to malloc'd storage, which must
+ be freed by the caller. */
+
++/* asprintf may be declared as a macro by glibc with __USE_FORTIFY_LEVEL. */
++#ifndef asprintf
+ extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
+ #endif
++#endif
+
+ /* Like asprintf but allocates memory without fail. This works like
+ xmalloc. */
diff --git a/12.3.0/gentoo/08_all_libiberty-pic.patch b/12.3.0/gentoo/08_all_libiberty-pic.patch
new file mode 100644
index 0000000..3f0bae1
--- /dev/null
+++ b/12.3.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/12.3.0/gentoo/09_all_nopie-all-flags.patch b/12.3.0/gentoo/09_all_nopie-all-flags.patch
new file mode 100644
index 0000000..fe1cd80
--- /dev/null
+++ b/12.3.0/gentoo/09_all_nopie-all-flags.patch
@@ -0,0 +1,18 @@
+We need to pass NO_PIE_CFLAGS to ALL_* so gcc don't fail when
+we compile it with older gcc and pie.
+
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -1054,10 +1054,10 @@ ALL_CXXFLAGS = $(T_CFLAGS) $(CFLAGS-$@)
+ ALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS)
+
+ # This is the variable to use when using $(COMPILER).
+-ALL_COMPILERFLAGS = $(ALL_CXXFLAGS)
++ALL_COMPILERFLAGS = $(NO_PIE_CFLAGS) $(ALL_CXXFLAGS)
+
+ # This is the variable to use when using $(LINKER).
+-ALL_LINKERFLAGS = $(ALL_CXXFLAGS)
++ALL_LINKERFLAGS = $(NO_PIE_CFLAGS) $(ALL_CXXFLAGS)
+
+ # Build and host support libraries.
+
diff --git a/12.3.0/gentoo/10_all_sh-drop-sysroot-suffix.patch b/12.3.0/gentoo/10_all_sh-drop-sysroot-suffix.patch
new file mode 100644
index 0000000..e778f81
--- /dev/null
+++ b/12.3.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 <slyfox@gentoo.org>
+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 <slyfox@gentoo.org>
+--- 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/12.3.0/gentoo/11_all_ia64-TEXTREL.patch b/12.3.0/gentoo/11_all_ia64-TEXTREL.patch
new file mode 100644
index 0000000..f5d0a99
--- /dev/null
+++ b/12.3.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/12.3.0/gentoo/12_all_disable-systemtap-switch.patch b/12.3.0/gentoo/12_all_disable-systemtap-switch.patch
new file mode 100644
index 0000000..989036c
--- /dev/null
+++ b/12.3.0/gentoo/12_all_disable-systemtap-switch.patch
@@ -0,0 +1,115 @@
+From bb510ed7ea82093c924b027489db6f92250a85b3 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Sat, 12 May 2018 12:56:46 +0100
+Subject: [PATCH] gcc/configure.ac: add --disable-systemtap switch
+
+Before the change systemtap probes were enabled
+if target headers had sys/sdt.h at ./configure time.
+
+After the change explicitly ask to enable or disable
+for probe support and not rely on automagic dependency
+discovery.
+
+Bug: https://bugs.gentoo.org/654748
+Bug: https://gcc.gnu.org/bugzilla/PR61257
+Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -1015,6 +1015,7 @@ enable_gnu_unique_object
+ enable_linker_build_id
+ enable_libssp
+ enable_default_ssp
++enable_systemtap
+ with_long_double_128
+ with_long_double_format
+ with_gc
+@@ -1773,6 +1774,7 @@ Optional Features:
+ compiler will always pass --build-id to linker
+ --enable-libssp enable linking against libssp
+ --enable-default-ssp enable Stack Smashing Protection as default
++ --disable-systemtap enable systemtap static probe points [default=auto]
+ --enable-maintainer-mode
+ enable make rules and dependencies not useful (and
+ sometimes confusing) to the casual installer
+@@ -31387,17 +31389,33 @@ fi
+
+ # Test for <sys/sdt.h> on the target.
+
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking sys/sdt.h in the target C library" >&5
++
++# Check whether --enable-systemtap was given.
++if test "${enable_systemtap+set}" = set; then :
++ enableval=$enable_systemtap; enable_systemtap=$enableval
++else
++ enable_systemtap=auto
++fi
++
++
++if test x$enable_systemtap != xno; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking sys/sdt.h in the target C library" >&5
+ $as_echo_n "checking sys/sdt.h in the target C library... " >&6; }
+-have_sys_sdt_h=no
+-if test -f $target_header_dir/sys/sdt.h; then
+- have_sys_sdt_h=yes
++ have_sys_sdt_h=no
++ if test -f $target_header_dir/sys/sdt.h ; then
++ have_sys_sdt_h=yes
+
+ $as_echo "#define HAVE_SYS_SDT_H 1" >>confdefs.h
+
+-fi
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_sys_sdt_h" >&5
++ fi
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_sys_sdt_h" >&5
+ $as_echo "$have_sys_sdt_h" >&6; }
++ if test x$enable_systemtap = xyes ; then
++ if test x$have_sys_sdt_h = xno ; then
++ as_fn_error $? "sys/sdt.h was not found" "$LINENO" 5
++ fi
++ fi
++fi
+
+ # Check if TFmode long double should be used by default or not.
+ # Some glibc targets used DFmode long double, but with glibc 2.4
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -6904,14 +6904,28 @@ AC_SUBST([enable_default_ssp])
+
+ # Test for <sys/sdt.h> on the target.
+ GCC_TARGET_TEMPLATE([HAVE_SYS_SDT_H])
+-AC_MSG_CHECKING(sys/sdt.h in the target C library)
+-have_sys_sdt_h=no
+-if test -f $target_header_dir/sys/sdt.h; then
+- have_sys_sdt_h=yes
+- AC_DEFINE(HAVE_SYS_SDT_H, 1,
+- [Define if your target C library provides sys/sdt.h])
+-fi
+-AC_MSG_RESULT($have_sys_sdt_h)
++
++AC_ARG_ENABLE(systemtap,
++[AS_HELP_STRING([--disable-systemtap],
++ [enable systemtap static probe points [default=auto]])],
++ enable_systemtap=$enableval,
++ enable_systemtap=auto)
++
++if test x$enable_systemtap != xno; then
++ AC_MSG_CHECKING(sys/sdt.h in the target C library)
++ have_sys_sdt_h=no
++ if test -f $target_header_dir/sys/sdt.h ; then
++ have_sys_sdt_h=yes
++ AC_DEFINE(HAVE_SYS_SDT_H, 1,
++ [Define if your target C library provides sys/sdt.h])
++ fi
++ AC_MSG_RESULT($have_sys_sdt_h)
++ if test x$enable_systemtap = xyes ; then
++ if test x$have_sys_sdt_h = xno ; then
++ AC_MSG_ERROR([sys/sdt.h was not found])
++ fi
++ fi
++fi
+
+ # Check if TFmode long double should be used by default or not.
+ # Some glibc targets used DFmode long double, but with glibc 2.4
+--
+2.17.0
+
diff --git a/12.3.0/gentoo/14_all_respect-build-cxxflags.patch b/12.3.0/gentoo/14_all_respect-build-cxxflags.patch
new file mode 100644
index 0000000..1f9a774
--- /dev/null
+++ b/12.3.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/12.3.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch b/12.3.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch
new file mode 100644
index 0000000..2daf73b
--- /dev/null
+++ b/12.3.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
+@@ -957,6 +957,10 @@ c_cpp_builtins (cpp_reader *pfile)
+ cpp_define (pfile, "__cpp_rtti=199711L");
+ }
+
++ #ifdef DEF_GENTOO_GLIBCXX_ASSERTIONS
++ cpp_define (pfile, "_GLIBCXX_ASSERTIONS");
++ #endif
++
+ if (cxx_dialect >= cxx11)
+ cpp_define (pfile, "__GXX_EXPERIMENTAL_CXX0X__");
+
diff --git a/12.3.0/gentoo/20_all_libstdcxx-no-vtv.patch b/12.3.0/gentoo/20_all_libstdcxx-no-vtv.patch
new file mode 100644
index 0000000..2719e2d
--- /dev/null
+++ b/12.3.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/12.3.0/gentoo/22_all_default_ssp-buffer-size.patch b/12.3.0/gentoo/22_all_default_ssp-buffer-size.patch
new file mode 100644
index 0000000..0e0dd42
--- /dev/null
+++ b/12.3.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/12.3.0/gentoo/23_all_DEF_GENTOO_ZNOW-z-now.patch b/12.3.0/gentoo/23_all_DEF_GENTOO_ZNOW-z-now.patch
new file mode 100644
index 0000000..2ed7968
--- /dev/null
+++ b/12.3.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/12.3.0/gentoo/24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch b/12.3.0/gentoo/24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch
new file mode 100644
index 0000000..b13215d
--- /dev/null
+++ b/12.3.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. */
++#ifdef DEF_GENTOO_SCP
++#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/12.3.0/gentoo/25_all_lto-intl-workaround-PR95194.patch b/12.3.0/gentoo/25_all_lto-intl-workaround-PR95194.patch
new file mode 100644
index 0000000..9613216
--- /dev/null
+++ b/12.3.0/gentoo/25_all_lto-intl-workaround-PR95194.patch
@@ -0,0 +1,20 @@
+Trick libintl not to use '_INTL_REDIRECT_ASM' mode as it's
+incompatible with LTO builds.
+
+glibc does not normally use libintl implementations and uses
+it's own primitives. But musl ond others do fall back to libintl.
+
+Reported-by: Andrew Savchenko
+Bug: https://bugs.gentoo.org/723370
+Bug: https://gcc.gnu.org/PR95194
+--- a/intl/libgnuintl.h
++++ b/intl/libgnuintl.h
+@@ -93,7 +93,7 @@ extern "C" {
+ If he doesn't, we choose the method. A third possible method is
+ _INTL_REDIRECT_ASM, supported only by GCC. */
+ #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
+-# if __GNUC__ >= 2 && !defined __APPLE_CC__ && (defined __STDC__ || defined __cplusplus)
++# if __GNUC__ >= 2 && !defined __APPLE_CC__ && (defined __STDC__ || defined __cplusplus) && USE_ASM_ALIASES_THAT_BREAK_LTO
+ # define _INTL_REDIRECT_ASM
+ # else
+ # ifdef __cplusplus
diff --git a/12.3.0/gentoo/26_all_enable-cet.patch b/12.3.0/gentoo/26_all_enable-cet.patch
new file mode 100644
index 0000000..1d0c04f
--- /dev/null
+++ b/12.3.0/gentoo/26_all_enable-cet.patch
@@ -0,0 +1,206 @@
+https://bugs.gentoo.org/822036
+https://salsa.debian.org/toolchain-team/gcc/-/blob/master/debian/patches/gcc-distro-specs.diff
+
+From: Sam James <sam@gentoo.org>
+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
+@@ -51,7 +51,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-ts:-fmodule-header %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(default_flag_cf_spec) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s%V}"
+ " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:"
+@@ -72,7 +72,7 @@ along with GCC; see the file COPYING3. If not see
+ " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}"
+ " %{fmodules-ts:-fmodule-header=system"
+ " %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(default_flag_cf_spec) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s%V}"
+ " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:"
+@@ -92,7 +92,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-ts:-fmodule-header=user %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(default_flag_cf_spec) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s%V}"
+ " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:"
+@@ -107,7 +107,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)}}"
+@@ -116,7 +116,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
+@@ -1007,6 +1007,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. */
++#ifdef EXTRA_OPTIONS_CF
++#define DEFAULT_FLAG_CF_SPEC " %{!m16:%{!m32:%{!fcf-protection*:%{!fno-cf-protection:-fcf-protection}}}}"
++#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"
+@@ -1209,6 +1221,7 @@ static const char *cpp_spec = CPP_SPEC;
+ static const char *cc1_spec = 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;
+@@ -1267,7 +1280,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.
+
+@@ -1456,9 +1469,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}\
+@@ -1472,18 +1485,18 @@ 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)\
+ %{!fsyntax-only:%{!S:-o %g.s} \
+ %{!fdump-ada-spec*:%{!o*:--output-pch=%i.gch}\
+ %W{o*:--output-pch=%*}}%V}}\
+ %{!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:%{!S:-o %g.s} \
+ %{!fdump-ada-spec*:%{!o*:--output-pch=%i.gch}\
+ %W{o*:--output-pch=%*}}%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},
+@@ -1715,6 +1728,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/12.3.0/gentoo/27_all_plugin-objdump.patch b/12.3.0/gentoo/27_all_plugin-objdump.patch
new file mode 100644
index 0000000..059bca5
--- /dev/null
+++ b/12.3.0/gentoo/27_all_plugin-objdump.patch
@@ -0,0 +1,34 @@
+https://gcc.gnu.org/PR95648
+--- a/config/gcc-plugin.m4
++++ b/config/gcc-plugin.m4
+@@ -45,7 +45,7 @@ AC_DEFUN([GCC_ENABLE_PLUGINS],
+ ;;
+ *)
+ if test x$build = x$host; then
+- export_sym_check="objdump${exeext} -T"
++ export_sym_check="$ac_cv_prog_OBJDUMP -T"
+ elif test x$host = x$target; then
+ export_sym_check="$gcc_cv_objdump -T"
+ else
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -32075,7 +32075,7 @@ fi
+ ;;
+ *)
+ if test x$build = x$host; then
+- export_sym_check="objdump${exeext} -T"
++ export_sym_check="$ac_cv_prog_OBJDUMP -T"
+ elif test x$host = x$target; then
+ export_sym_check="$gcc_cv_objdump -T"
+ else
+--- a/libcc1/configure
++++ b/libcc1/configure
+@@ -15034,7 +15034,7 @@ fi
+ ;;
+ *)
+ if test x$build = x$host; then
+- export_sym_check="objdump${exeext} -T"
++ export_sym_check="$ac_cv_prog_OBJDUMP -T"
+ elif test x$host = x$target; then
+ export_sym_check="$gcc_cv_objdump -T"
+ else
diff --git a/12.3.0/gentoo/28_all_drop_CFLAGS_sed.patch b/12.3.0/gentoo/28_all_drop_CFLAGS_sed.patch
new file mode 100644
index 0000000..764f34c
--- /dev/null
+++ b/12.3.0/gentoo/28_all_drop_CFLAGS_sed.patch
@@ -0,0 +1,35 @@
+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
+@@ -5388,13 +5388,6 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
+ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+-# Remove the -O2: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[ ]//" -e "s/-O[gs][ ]//" -e "s/-O[0-9]*[ ]//" `
+- CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[ ]//" -e "s/-O[gs][ ]//" -e "s/-O[0-9]*[ ]//" ` ;;
+-esac
+
+
+
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -440,13 +440,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 the -O2: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" `
+- CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" ` ;;
+-esac
+ AC_SUBST(CFLAGS)
+ AC_SUBST(CXXFLAGS)
+ AC_SUBST(GDCFLAGS)
diff --git a/12.3.0/gentoo/29_all_msgfmt-libstdc++-link.patch b/12.3.0/gentoo/29_all_msgfmt-libstdc++-link.patch
new file mode 100644
index 0000000..0d2f113
--- /dev/null
+++ b/12.3.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/12.3.0/gentoo/30_all_tar_libstdc++-link.patch b/12.3.0/gentoo/30_all_tar_libstdc++-link.patch
new file mode 100644
index 0000000..149d614
--- /dev/null
+++ b/12.3.0/gentoo/30_all_tar_libstdc++-link.patch
@@ -0,0 +1,57 @@
+From eae11e896edef4199a128bf6720b5bd4e5edc2f9 Mon Sep 17 00:00:00 2001
+From: Sam James <sam@gentoo.org>
+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 <sam@gentoo.org>
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -3934,10 +3934,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.
+@@ -3958,7 +3958,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/12.3.0/gentoo/75_all_go_posix_shell_arithmetic_nonbash.patch b/12.3.0/gentoo/75_all_go_posix_shell_arithmetic_nonbash.patch
new file mode 100644
index 0000000..57e9060
--- /dev/null
+++ b/12.3.0/gentoo/75_all_go_posix_shell_arithmetic_nonbash.patch
@@ -0,0 +1,40 @@
+https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=cf1725610526fe347d2530455b32affc033fd7fc
+
+From cf1725610526fe347d2530455b32affc033fd7fc Mon Sep 17 00:00:00 2001
+From: Ian Lance Taylor <iant@golang.org>
+Date: Fri, 22 Jul 2022 11:38:20 -0700
+Subject: [PATCH] libgo: use POSIX shell arithmetic expansion
+MIME-Version: 1.0
+Content-Type: text/plain; charset=utf8
+Content-Transfer-Encoding: 8bit
+
+Avoid bash-specific ((expression)) syntax. As the bash syntax
+converts a non-zero value to a zero status (and a zero value to a 1
+status), and POSIX arithmetic expansion does not, we have to negate
+the result.
+
+Based on patch by Sören Tempel.
+
+Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/419154
+--- a/libgo/match.sh
++++ b/libgo/match.sh
+@@ -111,7 +111,7 @@ gobuild() {
+ if test "$goarch" != "386"; then
+ line=$(echo "$line" | sed -e "s/\\(${wrap}\\)386\\(${wrap}\\)/\10\2/g")
+ fi
+- (($line))
++ return $((!($line)))
+ }
+
+ matched=
+--- a/libgo/testsuite/gotest
++++ b/libgo/testsuite/gotest
+@@ -302,7 +302,7 @@ gobuild() {
+ if test "$goarch" != "386"; then
+ line=$(echo "$line" | sed -e "s/\\(${wrap}\\)386\\(${wrap}\\)/\10\2/g")
+ fi
+- (($line))
++ return $((!($line)))
+ }
+
+ case "x$gofiles" in
diff --git a/12.3.0/gentoo/76_all_all_PR107087_12_Wstringop-overread-libstdc++-cow-empty.patch b/12.3.0/gentoo/76_all_all_PR107087_12_Wstringop-overread-libstdc++-cow-empty.patch
new file mode 100644
index 0000000..15241fe
--- /dev/null
+++ b/12.3.0/gentoo/76_all_all_PR107087_12_Wstringop-overread-libstdc++-cow-empty.patch
@@ -0,0 +1,63 @@
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107087
+https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=4969dcd2b7a94ce6c0d07225b21b5f3c040a4902
+
+From 4969dcd2b7a94ce6c0d07225b21b5f3c040a4902 Mon Sep 17 00:00:00 2001
+From: Jonathan Wakely <jwakely@redhat.com>
+Date: Fri, 31 Mar 2023 13:44:04 +0100
+Subject: [PATCH] libstdc++: Teach optimizer that empty COW strings are empty
+ [PR107087]
+
+The compiler doesn't know about the invariant that the _S_empty_rep()
+object is immutable and so _M_length and _M_refcount are always zero.
+This means that we get warnings about writing possibly-non-zero length
+strings into buffers that can't hold them. If we teach the compiler that
+the empty rep is always zero length, it knows it can be copied into any
+buffer.
+
+For Stage 1 we might want to also consider adding this to capacity():
+
+ if (_S_empty_rep()._M_capacity != 0)
+ __builtin_unreachable();
+
+And this to _Rep::_M_is_leaked() and _Rep::_M_is_shared():
+
+ if (_S_empty_rep()._M_refcount != 0)
+ __builtin_unreachable();
+
+libstdc++-v3/ChangeLog:
+
+ PR tree-optimization/107087
+ * include/bits/cow_string.h (basic_string::size()): Add
+ optimizer hint that _S_empty_rep()._M_length is always zero.
+ (basic_string::length()): Call size().
+--- a/libstdc++-v3/include/bits/cow_string.h
++++ b/libstdc++-v3/include/bits/cow_string.h
+@@ -907,17 +907,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ public:
+ // Capacity:
++
+ /// Returns the number of characters in the string, not including any
+ /// null-termination.
+ size_type
+ size() const _GLIBCXX_NOEXCEPT
+- { return _M_rep()->_M_length; }
++ {
++#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 && __OPTIMIZE__
++ if (_S_empty_rep()._M_length != 0)
++ __builtin_unreachable();
++#endif
++ return _M_rep()->_M_length;
++ }
+
+ /// Returns the number of characters in the string, not including any
+ /// null-termination.
+ size_type
+ length() const _GLIBCXX_NOEXCEPT
+- { return _M_rep()->_M_length; }
++ { return size(); }
+
+ /// Returns the size() of the largest possible %string.
+ size_type
+--
+2.31.1
diff --git a/12.3.0/gentoo/77_all_riscv_PR106271-multilib-bootstrap.patch b/12.3.0/gentoo/77_all_riscv_PR106271-multilib-bootstrap.patch
new file mode 100644
index 0000000..a333dc8
--- /dev/null
+++ b/12.3.0/gentoo/77_all_riscv_PR106271-multilib-bootstrap.patch
@@ -0,0 +1,36 @@
+https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=47f95bc4be4eb14730ab3eaaaf8f6e71fda47690
+https://gcc.gnu.org/PR106271
+https://bugs.gentoo.org/890636
+
+From 7cb2eddfcd84d6e4a1bc1b19fa7ace0927db6bbc Mon Sep 17 00:00:00 2001
+From: Raphael Moreira Zinsly <rzinsly@ventanamicro.com>
+Date: Tue, 22 Aug 2023 11:37:04 -0600
+Subject: [PATCH] RISC-V: Add multiarch support on riscv-linux-gnu
+
+This adds multiarch support to the RISC-V port so that bootstraps work with
+Debian out-of-the-box. Without this patch the stage1 compiler is unable to
+find headers/libraries when building the stage1 runtime.
+
+This is functionally (and possibly textually) equivalent to Debian's fix for
+the same problem.
+
+gcc/
+ * config/riscv/t-linux: Add MULTIARCH_DIRNAME.
+
+(cherry picked from commit 47f95bc4be4eb14730ab3eaaaf8f6e71fda47690)
+---
+ gcc/config/riscv/t-linux | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/gcc/config/riscv/t-linux b/gcc/config/riscv/t-linux
+index 216d2776a183..a6f64f88d25c 100644
+--- a/gcc/config/riscv/t-linux
++++ b/gcc/config/riscv/t-linux
+@@ -1,3 +1,5 @@
+ # Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/
+ MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES)))
+ MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES))
++
++MULTIARCH_DIRNAME := $(call if_multiarch,$(firstword $(subst -, ,$(target)))-linux-gnu)
+--
+2.44.0
diff --git a/12.0.0/gentoo/README.history b/12.3.0/gentoo/README.history
index d329e6f..6699fd4 100644
--- a/12.0.0/gentoo/README.history
+++ b/12.3.0/gentoo/README.history
@@ -1,7 +1,13 @@
-2 28 July 2021
- - 21_all_disable-riscv32-ABIs.patch
+3 28 Feb 2024
+
+ + 77_all_riscv_PR106271-multilib-bootstrap.patch
+
+2 29 Apr 2023
+
+ + 76_all_all_PR107087_12_Wstringop-overread-libstdc++-cow-empty.patch
+
+1 28 Apr 2023
-1 20 Apr 2021
+ 01_all_default-fortify-source.patch
+ 02_all_default-warn-format-security.patch
+ 03_all_default-warn-trampolines.patch
@@ -14,17 +20,16 @@
+ 10_all_sh-drop-sysroot-suffix.patch
+ 11_all_ia64-TEXTREL.patch
+ 12_all_disable-systemtap-switch.patch
- + 13_all_m68k-textrel-on-libgcc.patch
+ 14_all_respect-build-cxxflags.patch
- + 15_all_libgomp-Werror.patch
- + 16_all_libitm-Werror.patch
- + 17_all_libatomic-Werror.patch
- + 18_all_libbacktrace-Werror.patch
- + 19_all_libsanitizer-Werror.patch
+ + 15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch
+ 20_all_libstdcxx-no-vtv.patch
- + 21_all_disable-riscv32-ABIs.patch
+ 22_all_default_ssp-buffer-size.patch
- + 23_all_EXTRA_OPTIONS-z-now.patch
- + 24_all_EXTRA_OPTIONS-fstack-clash-protection.patch
+ + 23_all_DEF_GENTOO_ZNOW-z-now.patch
+ + 24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch
+ 25_all_lto-intl-workaround-PR95194.patch
- + 26_all_plugin-objdump.patch
+ + 26_all_enable-cet.patch
+ + 27_all_plugin-objdump.patch
+ + 28_all_drop_CFLAGS_sed.patch
+ + 29_all_msgfmt-libstdc++-link.patch
+ + 30_all_tar_libstdc++-link.patch
+ + 75_all_go_posix_shell_arithmetic_nonbash.patch
diff --git a/12.3.0/musl/25_all_multilib_pure64.patch b/12.3.0/musl/25_all_multilib_pure64.patch
new file mode 100644
index 0000000..d55c04c
--- /dev/null
+++ b/12.3.0/musl/25_all_multilib_pure64.patch
@@ -0,0 +1,83 @@
+https://bugs.gentoo.org/675954
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90077
+
+--- a/gcc/config/aarch64/t-aarch64-linux
++++ b/gcc/config/aarch64/t-aarch64-linux
+@@ -22,7 +22,7 @@
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+--- a/gcc/config/i386/t-linux64
++++ b/gcc/config/i386/t-linux64
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
+-MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
++MULTILIB_OSDIRNAMES+= mx32=../libx32
+--- a/gcc/config/rs6000/t-linux
++++ b/gcc/config/rs6000/t-linux
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+
+--- a/gcc/config/rs6000/t-linux64
++++ b/gcc/config/rs6000/t-linux64
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS := m64/m32
+ MULTILIB_DIRNAMES := 64 32
+ MULTILIB_EXTRA_OPTS :=
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ $(COMPILE) $<
+--- a/gcc/config/rs6000/t-linux64bele
++++ b/gcc/config/rs6000/t-linux64bele
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mlittle
+ MULTILIB_DIRNAMES += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/rs6000/t-linux64lebe
++++ b/gcc/config/rs6000/t-linux64lebe
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mbig
+ MULTILIB_DIRNAMES += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
diff --git a/12.3.0/musl/50_all_cpu_indicator.patch b/12.3.0/musl/50_all_cpu_indicator.patch
new file mode 100644
index 0000000..a7d199f
--- /dev/null
+++ b/12.3.0/musl/50_all_cpu_indicator.patch
@@ -0,0 +1,35 @@
+From d16a8ceb1c3c8a7ec381090b4c316ff4c55661c0 Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 7 May 2020 21:14:11 -0500
+Subject: [PATCH] convert "__cpu_indicator_init" to
+ "__cpu_indicator_init_local"
+
+--- a/gcc/config/i386/i386-expand.cc
++++ b/gcc/config/i386/i386-expand.cc
+@@ -12338,10 +12338,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
+ {
+ case IX86_BUILTIN_CPU_INIT:
+ {
+- /* Make it call __cpu_indicator_init in libgcc. */
++ /* Make it call __cpu_indicator_init_local in libgcc. */
+ tree call_expr, fndecl, type;
+ type = build_function_type_list (integer_type_node, NULL_TREE);
+- fndecl = build_fn_decl ("__cpu_indicator_init", type);
++ fndecl = build_fn_decl ("__cpu_indicator_init_local", type);
+ call_expr = build_call_expr (fndecl, 0);
+ return expand_expr (call_expr, target, mode, EXPAND_NORMAL);
+ }
+
+--- a/libgcc/config/i386/cpuinfo.c
++++ b/libgcc/config/i386/cpuinfo.c
+@@ -508,7 +508,7 @@ __cpu_indicator_init (void)
+ return 0;
+ }
+
+-#if defined SHARED && defined USE_ELF_SYMVER
+-__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0");
+-__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0");
++#ifndef SHARED
++int __cpu_indicator_init_local (void)
++ __attribute__ ((weak, alias ("__cpu_indicator_init")));
+ #endif
diff --git a/12.3.0/musl/50_all_libssp_unconditionally.patch b/12.3.0/musl/50_all_libssp_unconditionally.patch
new file mode 100644
index 0000000..a3b5984
--- /dev/null
+++ b/12.3.0/musl/50_all_libssp_unconditionally.patch
@@ -0,0 +1,24 @@
+https://bugs.gentoo.org/706210
+https://bugs.gentoo.org/747346
+
+Author: Timo Teräs <timo.teras@iki.fi>
+
+"Alpine musl package provides libssp_nonshared.a. We link to it unconditionally,
+as otherwise we get link failures if some objects are -fstack-protector built
+and final link happens with -fno-stack-protector. This seems to be the common
+case when bootstrapping gcc, the piepatches do not seem to fully fix the
+crosstoolchain and bootstrap sequence wrt. stack-protector flag usage."
+
+(We do the same in Gentoo.)
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -870,8 +870,7 @@
+
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+- "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ "|fstack-protector-strong|fstack-protector-explicit" \
diff --git a/12.3.0/musl/50_all_posix_memalign.patch b/12.3.0/musl/50_all_posix_memalign.patch
new file mode 100644
index 0000000..dd75a93
--- /dev/null
+++ b/12.3.0/musl/50_all_posix_memalign.patch
@@ -0,0 +1,28 @@
+--- a/gcc/config/i386/pmm_malloc.h
++++ b/gcc/config/i386/pmm_malloc.h
+@@ -27,12 +27,13 @@
+ #include <stdlib.h>
+
+ /* We can't depend on <stdlib.h> since the prototype of posix_memalign
+- may not be visible. */
++ may not be visible and we can't pollute the namespace either. */
+ #ifndef __cplusplus
+-extern int posix_memalign (void **, size_t, size_t);
++extern int __gcc_posix_memalign (void **, size_t, size_t)
+ #else
+-extern "C" int posix_memalign (void **, size_t, size_t) throw ();
++extern "C" int __gcc_posix_memalign (void **, size_t, size_t) throw ()
+ #endif
++__asm__("posix_memalign");
+
+ static __inline void *
+ _mm_malloc (size_t __size, size_t __alignment)
+@@ -42,7 +43,7 @@
+ return malloc (__size);
+ if (__alignment == 2 || (sizeof (void *) == 8 && __alignment == 4))
+ __alignment = sizeof (void *);
+- if (posix_memalign (&__ptr, __alignment, __size) == 0)
++ if (__gcc_posix_memalign (&__ptr, __alignment, __size) == 0)
+ return __ptr;
+ else
+ return NULL;
diff --git a/12.3.0/musl/README.history b/12.3.0/musl/README.history
new file mode 100644
index 0000000..f149181
--- /dev/null
+++ b/12.3.0/musl/README.history
@@ -0,0 +1,6 @@
+1 28 Apr 2023
+
+ + 25_all_multilib_pure64.patch
+ + 50_all_cpu_indicator.patch
+ + 50_all_libssp_unconditionally.patch
+ + 50_all_posix_memalign.patch
diff --git a/13.1.0/gentoo/01_all_default-fortify-source.patch b/13.1.0/gentoo/01_all_default-fortify-source.patch
new file mode 100644
index 0000000..4cdf5f6
--- /dev/null
+++ b/13.1.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/13.1.0/gentoo/02_all_default-warn-format-security.patch b/13.1.0/gentoo/02_all_default-warn-format-security.patch
new file mode 100644
index 0000000..9723a1c
--- /dev/null
+++ b/13.1.0/gentoo/02_all_default-warn-format-security.patch
@@ -0,0 +1,22 @@
+Enable -Wformat and -Wformat-security by default.
+
+--- a/gcc/c-family/c.opt
++++ b/gcc/c-family/c.opt
+@@ -696,7 +696,7 @@ Warn about function calls with format strings that write past the end
+ of the destination region. Same as -Wformat-overflow=1.
+
+ 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
+@@ -717,7 +717,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.
+
+ Wformat-overflow=
diff --git a/13.1.0/gentoo/03_all_default-warn-trampolines.patch b/13.1.0/gentoo/03_all_default-warn-trampolines.patch
new file mode 100644
index 0000000..fb6d8bc
--- /dev/null
+++ b/13.1.0/gentoo/03_all_default-warn-trampolines.patch
@@ -0,0 +1,13 @@
+Enable -Wtrampolines by default.
+
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -798,7 +798,7 @@ Common Var(warn_system_headers) Warning
+ Do not suppress warnings from system headers.
+
+ 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/13.1.0/gentoo/04_all_nossp-on-nostdlib.patch b/13.1.0/gentoo/04_all_nossp-on-nostdlib.patch
new file mode 100644
index 0000000..b633d7f
--- /dev/null
+++ b/13.1.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
+@@ -984,6 +984,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} "
++#else
++#define NO_SSP_SPEC ""
++#endif
++
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+@@ -1280,7 +1286,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|fprofile-generate*|coverage:\
+ %{!fprofile-update=single:\
diff --git a/13.1.0/gentoo/05_all_alpha-mieee-default.patch b/13.1.0/gentoo/05_all_alpha-mieee-default.patch
new file mode 100644
index 0000000..fd1de71
--- /dev/null
+++ b/13.1.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 <vapier@gentoo.org>
+
+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/13.1.0/gentoo/06_all_ia64_note.GNU-stack.patch b/13.1.0/gentoo/06_all_ia64_note.GNU-stack.patch
new file mode 100644
index 0000000..7a1d4c6
--- /dev/null
+++ b/13.1.0/gentoo/06_all_ia64_note.GNU-stack.patch
@@ -0,0 +1,92 @@
+http://gcc.gnu.org/PR21098
+
+
+2004-09-20 Jakub Jelinek <jakub@redhat.com>
+
+ * 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 <jakub@redhat.com>
+
+ * 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/13.1.0/gentoo/07_all_libiberty-asprintf.patch b/13.1.0/gentoo/07_all_libiberty-asprintf.patch
new file mode 100644
index 0000000..1ed2ba3
--- /dev/null
+++ b/13.1.0/gentoo/07_all_libiberty-asprintf.patch
@@ -0,0 +1,18 @@
+2008-07-25 Magnus Granberg <zorry@ume.nu>
+
+ * include/libiberty.h (asprintf): Don't declare if defined as a macro
+
+--- a/include/libiberty.h
++++ b/include/libiberty.h
+@@ -652,8 +652,11 @@ extern void *bsearch_r (const void *, const void *,
+ /* Like sprintf but provides a pointer to malloc'd storage, which must
+ be freed by the caller. */
+
++/* asprintf may be declared as a macro by glibc with __USE_FORTIFY_LEVEL. */
++#ifndef asprintf
+ extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
+ #endif
++#endif
+
+ /* Like asprintf but allocates memory without fail. This works like
+ xmalloc. */
diff --git a/13.1.0/gentoo/08_all_libiberty-pic.patch b/13.1.0/gentoo/08_all_libiberty-pic.patch
new file mode 100644
index 0000000..3f0bae1
--- /dev/null
+++ b/13.1.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/13.1.0/gentoo/09_all_nopie-all-flags.patch b/13.1.0/gentoo/09_all_nopie-all-flags.patch
new file mode 100644
index 0000000..fe1cd80
--- /dev/null
+++ b/13.1.0/gentoo/09_all_nopie-all-flags.patch
@@ -0,0 +1,18 @@
+We need to pass NO_PIE_CFLAGS to ALL_* so gcc don't fail when
+we compile it with older gcc and pie.
+
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -1054,10 +1054,10 @@ ALL_CXXFLAGS = $(T_CFLAGS) $(CFLAGS-$@)
+ ALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS)
+
+ # This is the variable to use when using $(COMPILER).
+-ALL_COMPILERFLAGS = $(ALL_CXXFLAGS)
++ALL_COMPILERFLAGS = $(NO_PIE_CFLAGS) $(ALL_CXXFLAGS)
+
+ # This is the variable to use when using $(LINKER).
+-ALL_LINKERFLAGS = $(ALL_CXXFLAGS)
++ALL_LINKERFLAGS = $(NO_PIE_CFLAGS) $(ALL_CXXFLAGS)
+
+ # Build and host support libraries.
+
diff --git a/13.1.0/gentoo/10_all_sh-drop-sysroot-suffix.patch b/13.1.0/gentoo/10_all_sh-drop-sysroot-suffix.patch
new file mode 100644
index 0000000..e778f81
--- /dev/null
+++ b/13.1.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 <slyfox@gentoo.org>
+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 <slyfox@gentoo.org>
+--- 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/13.1.0/gentoo/11_all_ia64-TEXTREL.patch b/13.1.0/gentoo/11_all_ia64-TEXTREL.patch
new file mode 100644
index 0000000..f5d0a99
--- /dev/null
+++ b/13.1.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/13.1.0/gentoo/14_all_respect-build-cxxflags.patch b/13.1.0/gentoo/14_all_respect-build-cxxflags.patch
new file mode 100644
index 0000000..1f9a774
--- /dev/null
+++ b/13.1.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/13.1.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch b/13.1.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch
new file mode 100644
index 0000000..2daf73b
--- /dev/null
+++ b/13.1.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
+@@ -957,6 +957,10 @@ c_cpp_builtins (cpp_reader *pfile)
+ cpp_define (pfile, "__cpp_rtti=199711L");
+ }
+
++ #ifdef DEF_GENTOO_GLIBCXX_ASSERTIONS
++ cpp_define (pfile, "_GLIBCXX_ASSERTIONS");
++ #endif
++
+ if (cxx_dialect >= cxx11)
+ cpp_define (pfile, "__GXX_EXPERIMENTAL_CXX0X__");
+
diff --git a/13.1.0/gentoo/20_all_libstdcxx-no-vtv.patch b/13.1.0/gentoo/20_all_libstdcxx-no-vtv.patch
new file mode 100644
index 0000000..2719e2d
--- /dev/null
+++ b/13.1.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/13.1.0/gentoo/22_all_default_ssp-buffer-size.patch b/13.1.0/gentoo/22_all_default_ssp-buffer-size.patch
new file mode 100644
index 0000000..0e0dd42
--- /dev/null
+++ b/13.1.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/13.1.0/gentoo/23_all_DEF_GENTOO_ZNOW-z-now.patch b/13.1.0/gentoo/23_all_DEF_GENTOO_ZNOW-z-now.patch
new file mode 100644
index 0000000..2ed7968
--- /dev/null
+++ b/13.1.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/13.1.0/gentoo/24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch b/13.1.0/gentoo/24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch
new file mode 100644
index 0000000..b13215d
--- /dev/null
+++ b/13.1.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. */
++#ifdef DEF_GENTOO_SCP
++#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/13.1.0/gentoo/25_all_lto-intl-workaround-PR95194.patch b/13.1.0/gentoo/25_all_lto-intl-workaround-PR95194.patch
new file mode 100644
index 0000000..9613216
--- /dev/null
+++ b/13.1.0/gentoo/25_all_lto-intl-workaround-PR95194.patch
@@ -0,0 +1,20 @@
+Trick libintl not to use '_INTL_REDIRECT_ASM' mode as it's
+incompatible with LTO builds.
+
+glibc does not normally use libintl implementations and uses
+it's own primitives. But musl ond others do fall back to libintl.
+
+Reported-by: Andrew Savchenko
+Bug: https://bugs.gentoo.org/723370
+Bug: https://gcc.gnu.org/PR95194
+--- a/intl/libgnuintl.h
++++ b/intl/libgnuintl.h
+@@ -93,7 +93,7 @@ extern "C" {
+ If he doesn't, we choose the method. A third possible method is
+ _INTL_REDIRECT_ASM, supported only by GCC. */
+ #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
+-# if __GNUC__ >= 2 && !defined __APPLE_CC__ && (defined __STDC__ || defined __cplusplus)
++# if __GNUC__ >= 2 && !defined __APPLE_CC__ && (defined __STDC__ || defined __cplusplus) && USE_ASM_ALIASES_THAT_BREAK_LTO
+ # define _INTL_REDIRECT_ASM
+ # else
+ # ifdef __cplusplus
diff --git a/13.1.0/gentoo/26_all_enable-cet.patch b/13.1.0/gentoo/26_all_enable-cet.patch
new file mode 100644
index 0000000..b13abab
--- /dev/null
+++ b/13.1.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 <sam@gentoo.org>
+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
+@@ -51,7 +51,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-ts:-fmodule-header %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(default_flag_cf_spec) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s%V}"
+ " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:"
+@@ -72,7 +72,7 @@ along with GCC; see the file COPYING3. If not see
+ " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}"
+ " %{fmodules-ts:-fmodule-header=system"
+ " %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(default_flag_cf_spec) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s%V}"
+ " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:"
+@@ -92,7 +92,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-ts:-fmodule-header=user %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(default_flag_cf_spec) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s%V}"
+ " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:"
+@@ -107,7 +107,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)}}"
+@@ -116,7 +116,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
+@@ -994,6 +994,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. */
++#ifdef EXTRA_OPTIONS_CF
++#define DEFAULT_FLAG_CF_SPEC " %{!m16:%{!m32:%{!fcf-protection*:%{!fno-cf-protection:-fcf-protection}}}}"
++#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"
+@@ -1196,6 +1208,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;
+@@ -1254,7 +1267,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.
+
+@@ -1448,9 +1461,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}\
+@@ -1475,7 +1488,7 @@ static const struct compiler default_compilers[] =
+ %W{o*:--output-pch %*}}%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},
+@@ -1707,6 +1720,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/13.1.0/gentoo/28_all_drop_CFLAGS_sed.patch b/13.1.0/gentoo/28_all_drop_CFLAGS_sed.patch
new file mode 100644
index 0000000..764f34c
--- /dev/null
+++ b/13.1.0/gentoo/28_all_drop_CFLAGS_sed.patch
@@ -0,0 +1,35 @@
+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
+@@ -5388,13 +5388,6 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
+ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+-# Remove the -O2: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[ ]//" -e "s/-O[gs][ ]//" -e "s/-O[0-9]*[ ]//" `
+- CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[ ]//" -e "s/-O[gs][ ]//" -e "s/-O[0-9]*[ ]//" ` ;;
+-esac
+
+
+
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -440,13 +440,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 the -O2: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" `
+- CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" ` ;;
+-esac
+ AC_SUBST(CFLAGS)
+ AC_SUBST(CXXFLAGS)
+ AC_SUBST(GDCFLAGS)
diff --git a/13.1.0/gentoo/29_all_msgfmt-libstdc++-link.patch b/13.1.0/gentoo/29_all_msgfmt-libstdc++-link.patch
new file mode 100644
index 0000000..0d2f113
--- /dev/null
+++ b/13.1.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/13.1.0/gentoo/30_all_tar_libstdc++-link.patch b/13.1.0/gentoo/30_all_tar_libstdc++-link.patch
new file mode 100644
index 0000000..adb414a
--- /dev/null
+++ b/13.1.0/gentoo/30_all_tar_libstdc++-link.patch
@@ -0,0 +1,57 @@
+From eae11e896edef4199a128bf6720b5bd4e5edc2f9 Mon Sep 17 00:00:00 2001
+From: Sam James <sam@gentoo.org>
+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 <sam@gentoo.org>
+--- 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/13.1.0/gentoo/31_all_gm2_make_P_var.patch b/13.1.0/gentoo/31_all_gm2_make_P_var.patch
new file mode 100644
index 0000000..c977874
--- /dev/null
+++ b/13.1.0/gentoo/31_all_gm2_make_P_var.patch
@@ -0,0 +1,49 @@
+https://bugs.gentoo.org/904714
+https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=79c73122fab213f218b85b2c579ffe3cf5e98ad0
+
+From 79c73122fab213f218b85b2c579ffe3cf5e98ad0 Mon Sep 17 00:00:00 2001
+From: =?utf8?q?Arsen=20Arsenovi=C4=87?= <arsen@aarsen.me>
+Date: Fri, 21 Apr 2023 18:07:29 +0200
+Subject: [PATCH] gcc/m2: Drop references to $(P)
+
+$(P) seems to have been a workaround for some old, proprietary make
+implementations that we no longer support. It was removed in
+r0-31149-gb8dad04b688e9c.
+
+gcc/m2/ChangeLog:
+
+ * Make-lang.in: Remove references to $(P).
+ * Make-maintainer.in: Ditto.
+--- a/gcc/m2/Make-lang.in
++++ b/gcc/m2/Make-lang.in
+@@ -514,7 +514,7 @@ GM2_LIBS_BOOT = m2/gm2-compiler-boot/gm2.a \
+ cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) $(m2.prev)
+ cp -p $< $@
+
+-m2/stage2/cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o $(P) \
++m2/stage2/cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o \
+ $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) $(GM2_LIBS) \
+ m2/gm2-gcc/rtegraph.o plugin/m2rte$(soext)
+ -test -d $(@D) || $(mkinstalldirs) $(@D)
+@@ -527,7 +527,7 @@ m2/stage2/cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o $(
+ @$(call LINK_PROGRESS,$(INDEX.m2),end)
+
+ m2/stage1/cc1gm2$(exeext): gm2$(exeext) m2/gm2-compiler-boot/m2flex.o \
+- $(P) $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) \
++ $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) \
+ $(GM2_LIBS_BOOT) $(MC_LIBS) \
+ m2/gm2-gcc/rtegraph.o plugin/m2rte$(soext) \
+ $(m2.prev)
+--- a/gcc/m2/Make-maintainer.in
++++ b/gcc/m2/Make-maintainer.in
+@@ -753,7 +753,7 @@ GM2_LIBS_PARANOID = m2/gm2-compiler-paranoid/gm2.a \
+ gm2.paranoid: m2/m2obj3/cc1gm2$(exeext) gm2.verifyparanoid
+
+ m2/m2obj3/cc1gm2$(exeext): m2/m2obj2/cc1gm2$(exeext) m2/gm2-compiler-paranoid/m2flex.o \
+- $(P) $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) $(GM2_LIBS_PARANOID) \
++ $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) $(GM2_LIBS_PARANOID) \
+ m2/gm2-gcc/rtegraph.o plugin/m2rte$(exeext).so m2/gm2-libs-boot/M2LINK.o
+ -test -d m2/m2obj3 || $(mkinstalldirs) m2/m2obj3
+ @$(call LINK_PROGRESS,$(INDEX.m2),start)
+--
+2.31.1
diff --git a/13.1.0/gentoo/README.history b/13.1.0/gentoo/README.history
new file mode 100644
index 0000000..047322a
--- /dev/null
+++ b/13.1.0/gentoo/README.history
@@ -0,0 +1,56 @@
+10 23 Apr 2023
+ U 26_all_enable-cet.patch
+ + 31_all_gm2_make_P_var.patch
+
+9 13 Mar 2023
+ U 01_all_default-fortify-source.patch
+
+8 12 Feb 2023
+ - 76_all_all_PR107461_cxx_equivalence_non_dependent_calls.patch
+
+7 6 Feb 2023
+ + 75_all_all_PR107461_cxx_equivalence_non_dependent_calls.patch
+
+6 30 Jan 2023
+ U 01_all_default-fortify-source.patch
+ + 15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch
+
+5 17 Dec 2022
+ U 30_all_tar_libstdc++-link.patch
+
+4 17 Dec 2022
+ + 30_all_tar_libstdc++-link.patch
+
+3 29 November 2022
+
+ - 23_all_EXTRA_OPTIONS-z-now.patch
+ + 23_all_DEF_GENTOO_ZNOW-z-now.patch
+ - 24_all_EXTRA_OPTIONS-fstack-clash-protection.patch
+ + 24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch
+ + 28_all_drop_CFLAGS_sed.patch
+ + 29_all_msgfmt-libstdc++-link.patch
+
+2 8 November 2022
+ - 12_all_disable-systemtap-switch.patch
+
+1 7 August 2022
+
+ + 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
+ + 07_all_libiberty-asprintf.patch
+ + 08_all_libiberty-pic.patch
+ + 09_all_nopie-all-flags.patch
+ + 10_all_sh-drop-sysroot-suffix.patch
+ + 11_all_ia64-TEXTREL.patch
+ + 12_all_disable-systemtap-switch.patch
+ + 14_all_respect-build-cxxflags.patch
+ + 20_all_libstdcxx-no-vtv.patch
+ + 22_all_default_ssp-buffer-size.patch
+ + 23_all_EXTRA_OPTIONS-z-now.patch
+ + 24_all_EXTRA_OPTIONS-fstack-clash-protection.patch
+ + 25_all_lto-intl-workaround-PR95194.patch
+ + 26_all_enable-cet.patch
diff --git a/13.1.0/musl/25_all_multilib_pure64.patch b/13.1.0/musl/25_all_multilib_pure64.patch
new file mode 100644
index 0000000..d55c04c
--- /dev/null
+++ b/13.1.0/musl/25_all_multilib_pure64.patch
@@ -0,0 +1,83 @@
+https://bugs.gentoo.org/675954
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90077
+
+--- a/gcc/config/aarch64/t-aarch64-linux
++++ b/gcc/config/aarch64/t-aarch64-linux
+@@ -22,7 +22,7 @@
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+--- a/gcc/config/i386/t-linux64
++++ b/gcc/config/i386/t-linux64
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
+-MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
++MULTILIB_OSDIRNAMES+= mx32=../libx32
+--- a/gcc/config/rs6000/t-linux
++++ b/gcc/config/rs6000/t-linux
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+
+--- a/gcc/config/rs6000/t-linux64
++++ b/gcc/config/rs6000/t-linux64
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS := m64/m32
+ MULTILIB_DIRNAMES := 64 32
+ MULTILIB_EXTRA_OPTS :=
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ $(COMPILE) $<
+--- a/gcc/config/rs6000/t-linux64bele
++++ b/gcc/config/rs6000/t-linux64bele
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mlittle
+ MULTILIB_DIRNAMES += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/rs6000/t-linux64lebe
++++ b/gcc/config/rs6000/t-linux64lebe
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mbig
+ MULTILIB_DIRNAMES += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
diff --git a/13.1.0/musl/50_all_cpu_indicator.patch b/13.1.0/musl/50_all_cpu_indicator.patch
new file mode 100644
index 0000000..52e8b92
--- /dev/null
+++ b/13.1.0/musl/50_all_cpu_indicator.patch
@@ -0,0 +1,37 @@
+https://gcc.gnu.org/pipermail/gcc-patches/2023-February/612648.html
+
+From d16a8ceb1c3c8a7ec381090b4c316ff4c55661c0 Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 7 May 2020 21:14:11 -0500
+Subject: [PATCH] convert "__cpu_indicator_init" to
+ "__cpu_indicator_init_local"
+
+--- a/gcc/config/i386/i386-expand.cc
++++ b/gcc/config/i386/i386-expand.cc
+@@ -12338,10 +12338,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
+ {
+ case IX86_BUILTIN_CPU_INIT:
+ {
+- /* Make it call __cpu_indicator_init in libgcc. */
++ /* Make it call __cpu_indicator_init_local in libgcc. */
+ tree call_expr, fndecl, type;
+ type = build_function_type_list (integer_type_node, NULL_TREE);
+- fndecl = build_fn_decl ("__cpu_indicator_init", type);
++ fndecl = build_fn_decl ("__cpu_indicator_init_local", type);
+ call_expr = build_call_expr (fndecl, 0);
+ return expand_expr (call_expr, target, mode, EXPAND_NORMAL);
+ }
+
+--- a/libgcc/config/i386/cpuinfo.c
++++ b/libgcc/config/i386/cpuinfo.c
+@@ -508,7 +508,7 @@ __cpu_indicator_init (void)
+ return 0;
+ }
+
+-#if defined SHARED && defined USE_ELF_SYMVER
+-__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0");
+-__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0");
++#ifndef SHARED
++int __cpu_indicator_init_local (void)
++ __attribute__ ((weak, alias ("__cpu_indicator_init")));
+ #endif
diff --git a/13.1.0/musl/50_all_libssp_unconditionally.patch b/13.1.0/musl/50_all_libssp_unconditionally.patch
new file mode 100644
index 0000000..a3b5984
--- /dev/null
+++ b/13.1.0/musl/50_all_libssp_unconditionally.patch
@@ -0,0 +1,24 @@
+https://bugs.gentoo.org/706210
+https://bugs.gentoo.org/747346
+
+Author: Timo Teräs <timo.teras@iki.fi>
+
+"Alpine musl package provides libssp_nonshared.a. We link to it unconditionally,
+as otherwise we get link failures if some objects are -fstack-protector built
+and final link happens with -fno-stack-protector. This seems to be the common
+case when bootstrapping gcc, the piepatches do not seem to fully fix the
+crosstoolchain and bootstrap sequence wrt. stack-protector flag usage."
+
+(We do the same in Gentoo.)
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -870,8 +870,7 @@
+
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+- "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ "|fstack-protector-strong|fstack-protector-explicit" \
diff --git a/13.1.0/musl/50_all_posix_memalign.patch b/13.1.0/musl/50_all_posix_memalign.patch
new file mode 100644
index 0000000..dd75a93
--- /dev/null
+++ b/13.1.0/musl/50_all_posix_memalign.patch
@@ -0,0 +1,28 @@
+--- a/gcc/config/i386/pmm_malloc.h
++++ b/gcc/config/i386/pmm_malloc.h
+@@ -27,12 +27,13 @@
+ #include <stdlib.h>
+
+ /* We can't depend on <stdlib.h> since the prototype of posix_memalign
+- may not be visible. */
++ may not be visible and we can't pollute the namespace either. */
+ #ifndef __cplusplus
+-extern int posix_memalign (void **, size_t, size_t);
++extern int __gcc_posix_memalign (void **, size_t, size_t)
+ #else
+-extern "C" int posix_memalign (void **, size_t, size_t) throw ();
++extern "C" int __gcc_posix_memalign (void **, size_t, size_t) throw ()
+ #endif
++__asm__("posix_memalign");
+
+ static __inline void *
+ _mm_malloc (size_t __size, size_t __alignment)
+@@ -42,7 +43,7 @@
+ return malloc (__size);
+ if (__alignment == 2 || (sizeof (void *) == 8 && __alignment == 4))
+ __alignment = sizeof (void *);
+- if (posix_memalign (&__ptr, __alignment, __size) == 0)
++ if (__gcc_posix_memalign (&__ptr, __alignment, __size) == 0)
+ return __ptr;
+ else
+ return NULL;
diff --git a/13.1.0/musl/README.history b/13.1.0/musl/README.history
new file mode 100644
index 0000000..d3b73e5
--- /dev/null
+++ b/13.1.0/musl/README.history
@@ -0,0 +1,6 @@
+1 1 Feb 2022
+
+ + 25_all_multilib_pure64.patch
+ + 50_all_posix_memalign.patch
+ + 50_all_cpu_indicator.patch
+ + 50_all_libssp_unconditionally.patch
diff --git a/13.2.0/gentoo/01_all_default-fortify-source.patch b/13.2.0/gentoo/01_all_default-fortify-source.patch
new file mode 100644
index 0000000..4cdf5f6
--- /dev/null
+++ b/13.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/13.2.0/gentoo/02_all_default-warn-format-security.patch b/13.2.0/gentoo/02_all_default-warn-format-security.patch
new file mode 100644
index 0000000..9723a1c
--- /dev/null
+++ b/13.2.0/gentoo/02_all_default-warn-format-security.patch
@@ -0,0 +1,22 @@
+Enable -Wformat and -Wformat-security by default.
+
+--- a/gcc/c-family/c.opt
++++ b/gcc/c-family/c.opt
+@@ -696,7 +696,7 @@ Warn about function calls with format strings that write past the end
+ of the destination region. Same as -Wformat-overflow=1.
+
+ 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
+@@ -717,7 +717,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.
+
+ Wformat-overflow=
diff --git a/13.2.0/gentoo/03_all_default-warn-trampolines.patch b/13.2.0/gentoo/03_all_default-warn-trampolines.patch
new file mode 100644
index 0000000..fb6d8bc
--- /dev/null
+++ b/13.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
+@@ -798,7 +798,7 @@ Common Var(warn_system_headers) Warning
+ Do not suppress warnings from system headers.
+
+ 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/13.2.0/gentoo/04_all_nossp-on-nostdlib.patch b/13.2.0/gentoo/04_all_nossp-on-nostdlib.patch
new file mode 100644
index 0000000..b633d7f
--- /dev/null
+++ b/13.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
+@@ -984,6 +984,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} "
++#else
++#define NO_SSP_SPEC ""
++#endif
++
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+@@ -1280,7 +1286,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|fprofile-generate*|coverage:\
+ %{!fprofile-update=single:\
diff --git a/13.2.0/gentoo/05_all_alpha-mieee-default.patch b/13.2.0/gentoo/05_all_alpha-mieee-default.patch
new file mode 100644
index 0000000..fd1de71
--- /dev/null
+++ b/13.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 <vapier@gentoo.org>
+
+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/13.2.0/gentoo/06_all_ia64_note.GNU-stack.patch b/13.2.0/gentoo/06_all_ia64_note.GNU-stack.patch
new file mode 100644
index 0000000..7a1d4c6
--- /dev/null
+++ b/13.2.0/gentoo/06_all_ia64_note.GNU-stack.patch
@@ -0,0 +1,92 @@
+http://gcc.gnu.org/PR21098
+
+
+2004-09-20 Jakub Jelinek <jakub@redhat.com>
+
+ * 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 <jakub@redhat.com>
+
+ * 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/13.2.0/gentoo/07_all_libiberty-asprintf.patch b/13.2.0/gentoo/07_all_libiberty-asprintf.patch
new file mode 100644
index 0000000..1ed2ba3
--- /dev/null
+++ b/13.2.0/gentoo/07_all_libiberty-asprintf.patch
@@ -0,0 +1,18 @@
+2008-07-25 Magnus Granberg <zorry@ume.nu>
+
+ * include/libiberty.h (asprintf): Don't declare if defined as a macro
+
+--- a/include/libiberty.h
++++ b/include/libiberty.h
+@@ -652,8 +652,11 @@ extern void *bsearch_r (const void *, const void *,
+ /* Like sprintf but provides a pointer to malloc'd storage, which must
+ be freed by the caller. */
+
++/* asprintf may be declared as a macro by glibc with __USE_FORTIFY_LEVEL. */
++#ifndef asprintf
+ extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
+ #endif
++#endif
+
+ /* Like asprintf but allocates memory without fail. This works like
+ xmalloc. */
diff --git a/13.2.0/gentoo/08_all_libiberty-pic.patch b/13.2.0/gentoo/08_all_libiberty-pic.patch
new file mode 100644
index 0000000..3f0bae1
--- /dev/null
+++ b/13.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/13.2.0/gentoo/09_all_nopie-all-flags.patch b/13.2.0/gentoo/09_all_nopie-all-flags.patch
new file mode 100644
index 0000000..fe1cd80
--- /dev/null
+++ b/13.2.0/gentoo/09_all_nopie-all-flags.patch
@@ -0,0 +1,18 @@
+We need to pass NO_PIE_CFLAGS to ALL_* so gcc don't fail when
+we compile it with older gcc and pie.
+
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -1054,10 +1054,10 @@ ALL_CXXFLAGS = $(T_CFLAGS) $(CFLAGS-$@)
+ ALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS)
+
+ # This is the variable to use when using $(COMPILER).
+-ALL_COMPILERFLAGS = $(ALL_CXXFLAGS)
++ALL_COMPILERFLAGS = $(NO_PIE_CFLAGS) $(ALL_CXXFLAGS)
+
+ # This is the variable to use when using $(LINKER).
+-ALL_LINKERFLAGS = $(ALL_CXXFLAGS)
++ALL_LINKERFLAGS = $(NO_PIE_CFLAGS) $(ALL_CXXFLAGS)
+
+ # Build and host support libraries.
+
diff --git a/13.2.0/gentoo/10_all_sh-drop-sysroot-suffix.patch b/13.2.0/gentoo/10_all_sh-drop-sysroot-suffix.patch
new file mode 100644
index 0000000..e778f81
--- /dev/null
+++ b/13.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 <slyfox@gentoo.org>
+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 <slyfox@gentoo.org>
+--- 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/13.2.0/gentoo/11_all_ia64-TEXTREL.patch b/13.2.0/gentoo/11_all_ia64-TEXTREL.patch
new file mode 100644
index 0000000..f5d0a99
--- /dev/null
+++ b/13.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/13.2.0/gentoo/14_all_respect-build-cxxflags.patch b/13.2.0/gentoo/14_all_respect-build-cxxflags.patch
new file mode 100644
index 0000000..1f9a774
--- /dev/null
+++ b/13.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/13.2.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch b/13.2.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch
new file mode 100644
index 0000000..2daf73b
--- /dev/null
+++ b/13.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
+@@ -957,6 +957,10 @@ c_cpp_builtins (cpp_reader *pfile)
+ cpp_define (pfile, "__cpp_rtti=199711L");
+ }
+
++ #ifdef DEF_GENTOO_GLIBCXX_ASSERTIONS
++ cpp_define (pfile, "_GLIBCXX_ASSERTIONS");
++ #endif
++
+ if (cxx_dialect >= cxx11)
+ cpp_define (pfile, "__GXX_EXPERIMENTAL_CXX0X__");
+
diff --git a/13.2.0/gentoo/20_all_libstdcxx-no-vtv.patch b/13.2.0/gentoo/20_all_libstdcxx-no-vtv.patch
new file mode 100644
index 0000000..2719e2d
--- /dev/null
+++ b/13.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/13.2.0/gentoo/22_all_default_ssp-buffer-size.patch b/13.2.0/gentoo/22_all_default_ssp-buffer-size.patch
new file mode 100644
index 0000000..0e0dd42
--- /dev/null
+++ b/13.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/13.2.0/gentoo/23_all_DEF_GENTOO_ZNOW-z-now.patch b/13.2.0/gentoo/23_all_DEF_GENTOO_ZNOW-z-now.patch
new file mode 100644
index 0000000..2ed7968
--- /dev/null
+++ b/13.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/13.2.0/gentoo/24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch b/13.2.0/gentoo/24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch
new file mode 100644
index 0000000..b13215d
--- /dev/null
+++ b/13.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. */
++#ifdef DEF_GENTOO_SCP
++#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/13.2.0/gentoo/25_all_lto-intl-workaround-PR95194.patch b/13.2.0/gentoo/25_all_lto-intl-workaround-PR95194.patch
new file mode 100644
index 0000000..9613216
--- /dev/null
+++ b/13.2.0/gentoo/25_all_lto-intl-workaround-PR95194.patch
@@ -0,0 +1,20 @@
+Trick libintl not to use '_INTL_REDIRECT_ASM' mode as it's
+incompatible with LTO builds.
+
+glibc does not normally use libintl implementations and uses
+it's own primitives. But musl ond others do fall back to libintl.
+
+Reported-by: Andrew Savchenko
+Bug: https://bugs.gentoo.org/723370
+Bug: https://gcc.gnu.org/PR95194
+--- a/intl/libgnuintl.h
++++ b/intl/libgnuintl.h
+@@ -93,7 +93,7 @@ extern "C" {
+ If he doesn't, we choose the method. A third possible method is
+ _INTL_REDIRECT_ASM, supported only by GCC. */
+ #if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
+-# if __GNUC__ >= 2 && !defined __APPLE_CC__ && (defined __STDC__ || defined __cplusplus)
++# if __GNUC__ >= 2 && !defined __APPLE_CC__ && (defined __STDC__ || defined __cplusplus) && USE_ASM_ALIASES_THAT_BREAK_LTO
+ # define _INTL_REDIRECT_ASM
+ # else
+ # ifdef __cplusplus
diff --git a/13.2.0/gentoo/26_all_enable-cet.patch b/13.2.0/gentoo/26_all_enable-cet.patch
new file mode 100644
index 0000000..b13abab
--- /dev/null
+++ b/13.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 <sam@gentoo.org>
+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
+@@ -51,7 +51,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-ts:-fmodule-header %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(default_flag_cf_spec) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s%V}"
+ " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:"
+@@ -72,7 +72,7 @@ along with GCC; see the file COPYING3. If not see
+ " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}"
+ " %{fmodules-ts:-fmodule-header=system"
+ " %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(default_flag_cf_spec) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s%V}"
+ " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:"
+@@ -92,7 +92,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-ts:-fmodule-header=user %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(default_flag_cf_spec) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s%V}"
+ " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:"
+@@ -107,7 +107,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)}}"
+@@ -116,7 +116,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
+@@ -994,6 +994,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. */
++#ifdef EXTRA_OPTIONS_CF
++#define DEFAULT_FLAG_CF_SPEC " %{!m16:%{!m32:%{!fcf-protection*:%{!fno-cf-protection:-fcf-protection}}}}"
++#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"
+@@ -1196,6 +1208,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;
+@@ -1254,7 +1267,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.
+
+@@ -1448,9 +1461,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}\
+@@ -1475,7 +1488,7 @@ static const struct compiler default_compilers[] =
+ %W{o*:--output-pch %*}}%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},
+@@ -1707,6 +1720,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/13.2.0/gentoo/28_all_drop_CFLAGS_sed.patch b/13.2.0/gentoo/28_all_drop_CFLAGS_sed.patch
new file mode 100644
index 0000000..764f34c
--- /dev/null
+++ b/13.2.0/gentoo/28_all_drop_CFLAGS_sed.patch
@@ -0,0 +1,35 @@
+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
+@@ -5388,13 +5388,6 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
+ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+-# Remove the -O2: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[ ]//" -e "s/-O[gs][ ]//" -e "s/-O[0-9]*[ ]//" `
+- CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[ ]//" -e "s/-O[gs][ ]//" -e "s/-O[0-9]*[ ]//" ` ;;
+-esac
+
+
+
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -440,13 +440,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 the -O2: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" `
+- CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" ` ;;
+-esac
+ AC_SUBST(CFLAGS)
+ AC_SUBST(CXXFLAGS)
+ AC_SUBST(GDCFLAGS)
diff --git a/13.2.0/gentoo/29_all_msgfmt-libstdc++-link.patch b/13.2.0/gentoo/29_all_msgfmt-libstdc++-link.patch
new file mode 100644
index 0000000..0d2f113
--- /dev/null
+++ b/13.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/13.2.0/gentoo/30_all_tar_libstdc++-link.patch b/13.2.0/gentoo/30_all_tar_libstdc++-link.patch
new file mode 100644
index 0000000..adb414a
--- /dev/null
+++ b/13.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 <sam@gentoo.org>
+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 <sam@gentoo.org>
+--- 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/13.2.0/gentoo/31_all_gm2_make_P_var.patch b/13.2.0/gentoo/31_all_gm2_make_P_var.patch
new file mode 100644
index 0000000..74b3925
--- /dev/null
+++ b/13.2.0/gentoo/31_all_gm2_make_P_var.patch
@@ -0,0 +1,49 @@
+https://bugs.gentoo.org/904714
+https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=79c73122fab213f218b85b2c579ffe3cf5e98ad0
+
+From 275c516a40b7044895c4920f52ec19c7bceedd54 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Arsen=20Arsenovi=C4=87?= <arsen@aarsen.me>
+Date: Fri, 21 Apr 2023 18:07:29 +0200
+Subject: [PATCH] gcc/m2: Drop references to $(P)
+
+$(P) seems to have been a workaround for some old, proprietary make
+implementations that we no longer support. It was removed in
+r0-31149-gb8dad04b688e9c.
+
+gcc/m2/ChangeLog:
+
+ * Make-lang.in: Remove references to $(P).
+ * Make-maintainer.in: Ditto.
+
+(cherry picked from commit 79c73122fab213f218b85b2c579ffe3cf5e98ad0)
+--- a/gcc/m2/Make-lang.in
++++ b/gcc/m2/Make-lang.in
+@@ -532,7 +532,7 @@ m2_OBJS = $(GM2_C_OBJS) m2/gm2-gcc/rtegraph.o \
+ cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) $(m2.prev)
+ cp -p $< $@
+
+-m2/stage2/cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o $(P) \
++m2/stage2/cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o \
+ $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) $(GM2_LIBS) \
+ m2/gm2-gcc/rtegraph.o $(M2RTE_PLUGIN_SO)
+ -test -d $(@D) || $(mkinstalldirs) $(@D)
+@@ -545,7 +545,7 @@ m2/stage2/cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o $(
+ @$(call LINK_PROGRESS,$(INDEX.m2),end)
+
+ m2/stage1/cc1gm2$(exeext): gm2$(exeext) m2/gm2-compiler-boot/m2flex.o \
+- $(P) $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) \
++ $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) \
+ $(GM2_LIBS_BOOT) $(MC_LIBS) \
+ m2/gm2-gcc/rtegraph.o $(M2RTE_PLUGIN_SO) \
+ $(m2.prev)
+--- a/gcc/m2/Make-maintainer.in
++++ b/gcc/m2/Make-maintainer.in
+@@ -852,7 +852,7 @@ GM2_LIBS_PARANOID = m2/gm2-compiler-paranoid/gm2.a \
+ gm2.paranoid: m2/m2obj3/cc1gm2$(exeext) gm2.verifyparanoid
+
+ m2/m2obj3/cc1gm2$(exeext): m2/m2obj2/cc1gm2$(exeext) m2/gm2-compiler-paranoid/m2flex.o \
+- $(P) $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) $(GM2_LIBS_PARANOID) \
++ $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) $(GM2_LIBS_PARANOID) \
+ m2/gm2-gcc/rtegraph.o plugin/m2rte$(exeext).so
+ -test -d m2/m2obj3 || $(mkinstalldirs) m2/m2obj3
+ @$(call LINK_PROGRESS,$(INDEX.m2),start)
diff --git a/13.2.0/gentoo/76_all_match.pd-don-t-emit-label-if-not-needed.patch b/13.2.0/gentoo/76_all_match.pd-don-t-emit-label-if-not-needed.patch
new file mode 100644
index 0000000..95da940
--- /dev/null
+++ b/13.2.0/gentoo/76_all_match.pd-don-t-emit-label-if-not-needed.patch
@@ -0,0 +1,114 @@
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109927#c21
+
+From 6178fddd3e0957fbb8bcfc443fef172691b7640b Mon Sep 17 00:00:00 2001
+From: Tamar Christina <tamar.christina@arm.com>
+Date: Fri, 5 May 2023 13:35:17 +0100
+Subject: [PATCH 01/15] match.pd: don't emit label if not needed
+
+This is a small QoL codegen improvement for match.pd to not emit labels when
+they are not needed. The codegen is nice and there is a small (but consistent)
+improvement in compile time.
+
+gcc/ChangeLog:
+
+ PR bootstrap/84402
+ * genmatch.cc (dt_simplify::gen_1): Only emit labels if used.
+
+(cherry picked from commit 580cda3c2799b1f8323af770e52f1eb0fa204718)
+---
+ gcc/genmatch.cc | 30 ++++++++++++++++++++++--------
+ 1 file changed, 22 insertions(+), 8 deletions(-)
+
+diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc
+index c1023d921fca..9ecd0a462b4f 100644
+--- a/gcc/genmatch.cc
++++ b/gcc/genmatch.cc
+@@ -3354,6 +3354,7 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimple, operand *result)
+ char local_fail_label[256];
+ snprintf (local_fail_label, 256, "next_after_fail%u", ++fail_label_cnt);
+ fail_label = local_fail_label;
++ bool needs_label = false;
+
+ /* Analyze captures and perform early-outs on the incoming arguments
+ that cover cases we cannot handle. */
+@@ -3368,6 +3369,7 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimple, operand *result)
+ fprintf_indent (f, indent,
+ "if (TREE_SIDE_EFFECTS (_p%d)) goto %s;\n",
+ i, fail_label);
++ needs_label = true;
+ if (verbose >= 1)
+ warning_at (as_a <expr *> (s->match)->ops[i]->location,
+ "forcing toplevel operand to have no "
+@@ -3383,6 +3385,7 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimple, operand *result)
+ fprintf_indent (f, indent,
+ "if (TREE_SIDE_EFFECTS (captures[%d])) "
+ "goto %s;\n", i, fail_label);
++ needs_label = true;
+ if (verbose >= 1)
+ warning_at (cinfo.info[i].c->location,
+ "forcing captured operand to have no "
+@@ -3425,7 +3428,10 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimple, operand *result)
+ }
+
+ if (s->kind == simplify::SIMPLIFY)
+- fprintf_indent (f, indent, "if (UNLIKELY (!dbg_cnt (match))) goto %s;\n", fail_label);
++ {
++ fprintf_indent (f, indent, "if (UNLIKELY (!dbg_cnt (match))) goto %s;\n", fail_label);
++ needs_label = true;
++ }
+
+ fprintf_indent (f, indent, "if (UNLIKELY (dump_file && (dump_flags & TDF_FOLDING))) "
+ "fprintf (dump_file, \"%s ",
+@@ -3498,9 +3504,12 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimple, operand *result)
+ "res_op->resimplify (%s, valueize);\n",
+ !e->force_leaf ? "lseq" : "NULL");
+ if (e->force_leaf)
+- fprintf_indent (f, indent,
+- "if (!maybe_push_res_to_seq (res_op, NULL)) "
+- "goto %s;\n", fail_label);
++ {
++ fprintf_indent (f, indent,
++ "if (!maybe_push_res_to_seq (res_op, NULL)) "
++ "goto %s;\n", fail_label);
++ needs_label = true;
++ }
+ }
+ }
+ else if (result->type == operand::OP_CAPTURE
+@@ -3556,9 +3565,12 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimple, operand *result)
+ continue;
+ if (cinfo.info[i].result_use_count
+ > cinfo.info[i].match_use_count)
+- fprintf_indent (f, indent,
+- "if (! tree_invariant_p (captures[%d])) "
+- "goto %s;\n", i, fail_label);
++ {
++ fprintf_indent (f, indent,
++ "if (! tree_invariant_p (captures[%d])) "
++ "goto %s;\n", i, fail_label);
++ needs_label = true;
++ }
+ }
+ for (unsigned j = 0; j < e->ops.length (); ++j)
+ {
+@@ -3609,6 +3621,7 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimple, operand *result)
+ {
+ fprintf_indent (f, indent, "if (!_r)\n");
+ fprintf_indent (f, indent, " goto %s;\n", fail_label);
++ needs_label = true;
+ }
+ }
+ }
+@@ -3649,7 +3662,8 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimple, operand *result)
+ }
+ indent -= 2;
+ fprintf_indent (f, indent, "}\n");
+- fprintf (f, "%s:;\n", fail_label);
++ if (needs_label)
++ fprintf (f, "%s:;\n", fail_label);
+ fail_label = NULL;
+ }
+
+--
+2.44.0
+
diff --git a/13.2.0/gentoo/77_all_match.pd-Remove-commented-out-line-pragmas-unless-vv.patch b/13.2.0/gentoo/77_all_match.pd-Remove-commented-out-line-pragmas-unless-vv.patch
new file mode 100644
index 0000000..ea61987
--- /dev/null
+++ b/13.2.0/gentoo/77_all_match.pd-Remove-commented-out-line-pragmas-unless-vv.patch
@@ -0,0 +1,41 @@
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109927#c21
+
+From 2be19327b38b4e3e183d47529871614a3ef0c3ad Mon Sep 17 00:00:00 2001
+From: Tamar Christina <tamar.christina@arm.com>
+Date: Fri, 5 May 2023 13:36:01 +0100
+Subject: [PATCH 02/15] match.pd: Remove commented out line pragmas unless -vv
+ is used.
+
+genmatch currently outputs commented out line directives that have no effect
+but the compiler still has to parse only to discard.
+
+They are however handy when debugging genmatch output. As such this moves them
+behind the -vv flag.
+
+gcc/ChangeLog:
+
+ PR bootstrap/84402
+ * genmatch.cc (output_line_directive): Only emit commented directive
+ when -vv.
+
+(cherry picked from commit e487fcc0f7466ea663a0fea52076337bebd42b8b)
+---
+ gcc/genmatch.cc | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc
+index 9ecd0a462b4f..45e49c790b6d 100644
+--- a/gcc/genmatch.cc
++++ b/gcc/genmatch.cc
+@@ -209,7 +209,7 @@ output_line_directive (FILE *f, location_t location,
+ else
+ fprintf (f, "%s:%d", file, loc.line);
+ }
+- else
++ else if (verbose >= 2)
+ /* Other gen programs really output line directives here, at least for
+ development it's right now more convenient to have line information
+ from the generated file. Still keep the directives as comment for now
+--
+2.44.0
+
diff --git a/13.2.0/gentoo/78_all_match.pd-CSE-the-dump-output-check.patch b/13.2.0/gentoo/78_all_match.pd-CSE-the-dump-output-check.patch
new file mode 100644
index 0000000..e084c4c
--- /dev/null
+++ b/13.2.0/gentoo/78_all_match.pd-CSE-the-dump-output-check.patch
@@ -0,0 +1,70 @@
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109927#c21
+
+From 2d83fafb3f263544be09bf7dbde036e4a84f6d7c Mon Sep 17 00:00:00 2001
+From: Tamar Christina <tamar.christina@arm.com>
+Date: Fri, 5 May 2023 13:36:43 +0100
+Subject: [PATCH 03/15] match.pd: CSE the dump output check.
+
+This is a small improvement in QoL codegen for match.pd to save time not
+re-evaluating the condition for printing debug information in every function.
+
+There is a small but consistent runtime and compile time win here. The runtime
+win comes from not having to do the condition over again, and on Arm plaforms
+we now use the new test-and-branch support for booleans to only have a single
+instruction here.
+
+gcc/ChangeLog:
+
+ PR bootstrap/84402
+ * genmatch.cc (decision_tree::gen, write_predicate): Generate new
+ debug_dump var.
+ (dt_simplify::gen_1): Use it.
+
+(cherry picked from commit c0ce29bc1ce329001b6c02bb3d34bcbb086e1b72)
+---
+ gcc/genmatch.cc | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc
+index 45e49c790b6d..a17ef8a23ed5 100644
+--- a/gcc/genmatch.cc
++++ b/gcc/genmatch.cc
+@@ -3433,7 +3433,7 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimple, operand *result)
+ needs_label = true;
+ }
+
+- fprintf_indent (f, indent, "if (UNLIKELY (dump_file && (dump_flags & TDF_FOLDING))) "
++ fprintf_indent (f, indent, "if (UNLIKELY (debug_dump)) "
+ "fprintf (dump_file, \"%s ",
+ s->kind == simplify::SIMPLIFY
+ ? "Applying pattern" : "Matching expression");
+@@ -3894,6 +3894,8 @@ decision_tree::gen (FILE *f, bool gimple)
+ }
+
+ fprintf (f, ")\n{\n");
++ fprintf_indent (f, 2, "const bool debug_dump = "
++ "dump_file && (dump_flags & TDF_FOLDING);\n");
+ s->s->gen_1 (f, 2, gimple, s->s->s->result);
+ if (gimple)
+ fprintf (f, " return false;\n");
+@@ -3939,6 +3941,8 @@ decision_tree::gen (FILE *f, bool gimple)
+ fprintf (f, ", tree _p%d", i);
+ fprintf (f, ")\n");
+ fprintf (f, "{\n");
++ fprintf_indent (f, 2, "const bool debug_dump = "
++ "dump_file && (dump_flags & TDF_FOLDING);\n");
+ dop->gen_kids (f, 2, gimple, 0);
+ if (gimple)
+ fprintf (f, " return false;\n");
+@@ -4048,6 +4052,8 @@ write_predicate (FILE *f, predicate_id *p, decision_tree &dt, bool gimple)
+ gimple ? ", tree (*valueize)(tree) ATTRIBUTE_UNUSED" : "");
+ /* Conveniently make 'type' available. */
+ fprintf_indent (f, 2, "const tree type = TREE_TYPE (t);\n");
++ fprintf_indent (f, 2, "const bool debug_dump = "
++ "dump_file && (dump_flags & TDF_FOLDING);\n");
+
+ if (!gimple)
+ fprintf_indent (f, 2, "if (TREE_SIDE_EFFECTS (t)) return false;\n");
+--
+2.44.0
+
diff --git a/13.2.0/gentoo/79_all_genmatch-split-shared-code-to-gimple-match-exports.c.patch b/13.2.0/gentoo/79_all_genmatch-split-shared-code-to-gimple-match-exports.c.patch
new file mode 100644
index 0000000..1f7769f
--- /dev/null
+++ b/13.2.0/gentoo/79_all_genmatch-split-shared-code-to-gimple-match-exports.c.patch
@@ -0,0 +1,2560 @@
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109927#c21
+
+From 49ed8cead428b48bf46afbbb37a4d043d00702d6 Mon Sep 17 00:00:00 2001
+From: Tamar Christina <tamar.christina@arm.com>
+Date: Fri, 5 May 2023 13:37:49 +0100
+Subject: [PATCH 04/15] genmatch: split shared code to gimple-match-exports.cc
+
+In preparation for automatically splitting match.pd files I split off the
+non-static helper functions that are shared between the match.pd functions off
+to another file.
+
+This file can be compiled in parallel and also allows us to later avoid
+duplicate symbols errors.
+
+gcc/ChangeLog:
+
+ PR bootstrap/84402
+ * Makefile.in (OBJS): Add gimple-match-exports.o.
+ * genmatch.cc (decision_tree::gen): Export gimple_gimplify helpers.
+ * gimple-match-head.cc (gimple_simplify, gimple_resimplify1,
+ gimple_resimplify2, gimple_resimplify3, gimple_resimplify4,
+ gimple_resimplify5, constant_for_folding, convert_conditional_op,
+ maybe_resimplify_conditional_op, gimple_match_op::resimplify,
+ maybe_build_generic_op, build_call_internal, maybe_push_res_to_seq,
+ do_valueize, try_conditional_simplification, gimple_extract,
+ gimple_extract_op, canonicalize_code, commutative_binary_op_p,
+ commutative_ternary_op_p, first_commutative_argument,
+ associative_binary_op_p, directly_supported_p,
+ get_conditional_internal_fn): Moved to gimple-match-exports.cc
+ * gimple-match-exports.cc: New file.
+
+(cherry picked from commit 27fcf994c5515e1bbf2ff03d28fd2fa927c7e7b5)
+---
+ gcc/Makefile.in | 4 +-
+ gcc/genmatch.cc | 4 +-
+ gcc/gimple-match-exports.cc | 1253 +++++++++++++++++++++++++++++++++++
+ gcc/gimple-match-head.cc | 1192 +--------------------------------
+ 4 files changed, 1260 insertions(+), 1193 deletions(-)
+ create mode 100644 gcc/gimple-match-exports.cc
+
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index 06d192fa9ed8..406856acde1c 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -223,6 +223,7 @@ libgcov-util.o-warn = -Wno-error
+ libgcov-driver-tool.o-warn = -Wno-error
+ libgcov-merge-tool.o-warn = -Wno-error
+ gimple-match.o-warn = -Wno-unused
++gimple-match-exports.o-warn = -Wno-unused
+ generic-match.o-warn = -Wno-unused
+ dfp.o-warn = -Wno-strict-aliasing
+
+@@ -1308,6 +1309,7 @@ ANALYZER_OBJS = \
+ # the last objects to finish building.
+ OBJS = \
+ gimple-match.o \
++ gimple-match-exports.o \
+ generic-match.o \
+ insn-attrtab.o \
+ insn-automata.o \
+@@ -2659,7 +2661,7 @@ s-tm-texi: build/genhooks$(build_exeext) $(srcdir)/doc/tm.texi.in
+ false; \
+ fi
+
+-gimple-match.cc: s-match gimple-match-head.cc ; @true
++gimple-match.cc: s-match gimple-match-head.cc gimple-match-exports.cc ; @true
+ generic-match.cc: s-match generic-match-head.cc ; @true
+
+ s-match: build/genmatch$(build_exeext) $(srcdir)/match.pd cfn-operators.pd
+diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc
+index a17ef8a23ed5..665d7e2106ff 100644
+--- a/gcc/genmatch.cc
++++ b/gcc/genmatch.cc
+@@ -3957,7 +3957,7 @@ decision_tree::gen (FILE *f, bool gimple)
+ if (! has_kids_p)
+ {
+ if (gimple)
+- fprintf (f, "\nstatic bool\n"
++ fprintf (f, "\nbool\n"
+ "gimple_simplify (gimple_match_op*, gimple_seq*,\n"
+ " tree (*)(tree), code_helper,\n"
+ " const tree");
+@@ -3980,7 +3980,7 @@ decision_tree::gen (FILE *f, bool gimple)
+ /* Then generate the main entry with the outermost switch and
+ tail-calls to the split-out functions. */
+ if (gimple)
+- fprintf (f, "\nstatic bool\n"
++ fprintf (f, "\nbool\n"
+ "gimple_simplify (gimple_match_op *res_op, gimple_seq *seq,\n"
+ " tree (*valueize)(tree) ATTRIBUTE_UNUSED,\n"
+ " code_helper code, const tree type");
+diff --git a/gcc/gimple-match-exports.cc b/gcc/gimple-match-exports.cc
+new file mode 100644
+index 000000000000..7aeb4ddb1524
+--- /dev/null
++++ b/gcc/gimple-match-exports.cc
+@@ -0,0 +1,1253 @@
++/* Helpers for the autogenerated gimple-match.cc file.
++ 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 "backend.h"
++#include "target.h"
++#include "rtl.h"
++#include "tree.h"
++#include "gimple.h"
++#include "ssa.h"
++#include "cgraph.h"
++#include "vec-perm-indices.h"
++#include "fold-const.h"
++#include "fold-const-call.h"
++#include "stor-layout.h"
++#include "gimple-iterator.h"
++#include "gimple-fold.h"
++#include "calls.h"
++#include "tree-dfa.h"
++#include "builtins.h"
++#include "gimple-match.h"
++#include "tree-pass.h"
++#include "internal-fn.h"
++#include "case-cfn-macros.h"
++#include "gimplify.h"
++#include "optabs-tree.h"
++#include "tree-eh.h"
++#include "dbgcnt.h"
++#include "tm.h"
++#include "gimple-range.h"
++#include "langhooks.h"
++
++tree (*mprts_hook) (gimple_match_op *);
++
++extern bool gimple_simplify (gimple_match_op *, gimple_seq *, tree (*)(tree),
++ code_helper, tree, tree);
++extern bool gimple_simplify (gimple_match_op *, gimple_seq *, tree (*)(tree),
++ code_helper, tree, tree, tree);
++extern bool gimple_simplify (gimple_match_op *, gimple_seq *, tree (*)(tree),
++ code_helper, tree, tree, tree, tree);
++extern bool gimple_simplify (gimple_match_op *, gimple_seq *, tree (*)(tree),
++ code_helper, tree, tree, tree, tree, tree);
++extern bool gimple_simplify (gimple_match_op *, gimple_seq *, tree (*)(tree),
++ code_helper, tree, tree, tree, tree, tree, tree);
++
++/* Functions that are needed by gimple-match but that are exported and used in
++ other places in the compiler. */
++
++tree gimple_simplify (enum tree_code, tree, tree, gimple_seq *,
++ tree (*)(tree));
++tree gimple_simplify (enum tree_code, tree, tree, tree, gimple_seq *,
++ tree (*)(tree));
++tree gimple_simplify (enum tree_code, tree, tree, tree, tree, gimple_seq *,
++ tree (*)(tree));
++tree gimple_simplify (combined_fn, tree, tree, gimple_seq *,
++ tree (*)(tree));
++tree gimple_simplify (combined_fn, tree, tree, tree, gimple_seq *,
++ tree (*)(tree));
++tree gimple_simplify (combined_fn, tree, tree, tree, tree, gimple_seq *,
++ tree (*)(tree));
++
++tree do_valueize (tree, tree (*)(tree), bool &);
++tree do_valueize (tree (*)(tree), tree);
++
++/* Forward declarations of the private auto-generated matchers.
++ They expect valueized operands in canonical order and do not
++ perform simplification of all-constant operands. */
++
++static bool gimple_resimplify1 (gimple_seq *, gimple_match_op *, tree (*)(tree));
++static bool gimple_resimplify2 (gimple_seq *, gimple_match_op *, tree (*)(tree));
++static bool gimple_resimplify3 (gimple_seq *, gimple_match_op *, tree (*)(tree));
++static bool gimple_resimplify4 (gimple_seq *, gimple_match_op *, tree (*)(tree));
++static bool gimple_resimplify5 (gimple_seq *, gimple_match_op *, tree (*)(tree));
++
++/* Match and simplify the toplevel valueized operation THIS.
++ Replaces THIS with a simplified and/or canonicalized result and
++ returns whether any change was made. */
++
++bool
++gimple_match_op::resimplify (gimple_seq *seq, tree (*valueize)(tree))
++{
++ switch (num_ops)
++ {
++ case 1:
++ return gimple_resimplify1 (seq, this, valueize);
++ case 2:
++ return gimple_resimplify2 (seq, this, valueize);
++ case 3:
++ return gimple_resimplify3 (seq, this, valueize);
++ case 4:
++ return gimple_resimplify4 (seq, this, valueize);
++ case 5:
++ return gimple_resimplify5 (seq, this, valueize);
++ default:
++ gcc_unreachable ();
++ }
++}
++
++/* Return whether T is a constant that we'll dispatch to fold to
++ evaluate fully constant expressions. */
++
++static inline bool
++constant_for_folding (tree t)
++{
++ return (CONSTANT_CLASS_P (t)
++ /* The following is only interesting to string builtins. */
++ || (TREE_CODE (t) == ADDR_EXPR
++ && TREE_CODE (TREE_OPERAND (t, 0)) == STRING_CST));
++}
++
++/* Try to convert conditional operation ORIG_OP into an IFN_COND_*
++ operation. Return true on success, storing the new operation in NEW_OP. */
++
++static bool
++convert_conditional_op (gimple_match_op *orig_op,
++ gimple_match_op *new_op)
++{
++ internal_fn ifn;
++ if (orig_op->code.is_tree_code ())
++ ifn = get_conditional_internal_fn ((tree_code) orig_op->code);
++ else
++ {
++ auto cfn = combined_fn (orig_op->code);
++ if (!internal_fn_p (cfn))
++ return false;
++ ifn = get_conditional_internal_fn (as_internal_fn (cfn));
++ }
++ if (ifn == IFN_LAST)
++ return false;
++ unsigned int num_ops = orig_op->num_ops;
++ new_op->set_op (as_combined_fn (ifn), orig_op->type, num_ops + 2);
++ new_op->ops[0] = orig_op->cond.cond;
++ for (unsigned int i = 0; i < num_ops; ++i)
++ new_op->ops[i + 1] = orig_op->ops[i];
++ tree else_value = orig_op->cond.else_value;
++ if (!else_value)
++ else_value = targetm.preferred_else_value (ifn, orig_op->type,
++ num_ops, orig_op->ops);
++ new_op->ops[num_ops + 1] = else_value;
++ return true;
++}
++/* Helper for gimple_simplify valueizing OP using VALUEIZE and setting
++ VALUEIZED to true if valueization changed OP. */
++
++inline tree
++do_valueize (tree op, tree (*valueize)(tree), bool &valueized)
++{
++ if (valueize && TREE_CODE (op) == SSA_NAME)
++ {
++ tree tem = valueize (op);
++ if (tem && tem != op)
++ {
++ op = tem;
++ valueized = true;
++ }
++ }
++ return op;
++}
++
++/* If in GIMPLE the operation described by RES_OP should be single-rhs,
++ build a GENERIC tree for that expression and update RES_OP accordingly. */
++
++void
++maybe_build_generic_op (gimple_match_op *res_op)
++{
++ tree_code code = (tree_code) res_op->code;
++ tree val;
++ switch (code)
++ {
++ case REALPART_EXPR:
++ case IMAGPART_EXPR:
++ case VIEW_CONVERT_EXPR:
++ val = build1 (code, res_op->type, res_op->ops[0]);
++ res_op->set_value (val);
++ break;
++ case BIT_FIELD_REF:
++ val = build3 (code, res_op->type, res_op->ops[0], res_op->ops[1],
++ res_op->ops[2]);
++ REF_REVERSE_STORAGE_ORDER (val) = res_op->reverse;
++ res_op->set_value (val);
++ break;
++ default:;
++ }
++}
++
++/* Try to build RES_OP, which is known to be a call to FN. Return null
++ if the target doesn't support the function. */
++
++static gcall *
++build_call_internal (internal_fn fn, gimple_match_op *res_op)
++{
++ if (direct_internal_fn_p (fn))
++ {
++ tree_pair types = direct_internal_fn_types (fn, res_op->type,
++ res_op->ops);
++ if (!direct_internal_fn_supported_p (fn, types, OPTIMIZE_FOR_BOTH))
++ return NULL;
++ }
++ return gimple_build_call_internal (fn, res_op->num_ops,
++ res_op->op_or_null (0),
++ res_op->op_or_null (1),
++ res_op->op_or_null (2),
++ res_op->op_or_null (3),
++ res_op->op_or_null (4));
++}
++
++/* RES_OP is the result of a simplification. If it is conditional,
++ try to replace it with the equivalent UNCOND form, such as an
++ IFN_COND_* call or a VEC_COND_EXPR. Also try to resimplify the
++ result of the replacement if appropriate, adding any new statements to
++ SEQ and using VALUEIZE as the valueization function. Return true if
++ this resimplification occurred and resulted in at least one change. */
++
++static bool
++maybe_resimplify_conditional_op (gimple_seq *seq, gimple_match_op *res_op,
++ tree (*valueize) (tree))
++{
++ if (!res_op->cond.cond)
++ return false;
++
++ if (!res_op->cond.else_value
++ && res_op->code.is_tree_code ())
++ {
++ /* The "else" value doesn't matter. If the "then" value is a
++ gimple value, just use it unconditionally. This isn't a
++ simplification in itself, since there was no operation to
++ build in the first place. */
++ if (gimple_simplified_result_is_gimple_val (res_op))
++ {
++ res_op->cond.cond = NULL_TREE;
++ return false;
++ }
++
++ /* Likewise if the operation would not trap. */
++ bool honor_trapv = (INTEGRAL_TYPE_P (res_op->type)
++ && TYPE_OVERFLOW_TRAPS (res_op->type));
++ tree_code op_code = (tree_code) res_op->code;
++ bool op_could_trap;
++
++ /* COND_EXPR will trap if, and only if, the condition
++ traps and hence we have to check this. For all other operations, we
++ don't need to consider the operands. */
++ if (op_code == COND_EXPR)
++ op_could_trap = generic_expr_could_trap_p (res_op->ops[0]);
++ else
++ op_could_trap = operation_could_trap_p ((tree_code) res_op->code,
++ FLOAT_TYPE_P (res_op->type),
++ honor_trapv,
++ res_op->op_or_null (1));
++
++ if (!op_could_trap)
++ {
++ res_op->cond.cond = NULL_TREE;
++ return false;
++ }
++ }
++
++ /* If the "then" value is a gimple value and the "else" value matters,
++ create a VEC_COND_EXPR between them, then see if it can be further
++ simplified. */
++ gimple_match_op new_op;
++ if (res_op->cond.else_value
++ && VECTOR_TYPE_P (res_op->type)
++ && gimple_simplified_result_is_gimple_val (res_op))
++ {
++ new_op.set_op (VEC_COND_EXPR, res_op->type,
++ res_op->cond.cond, res_op->ops[0],
++ res_op->cond.else_value);
++ *res_op = new_op;
++ return gimple_resimplify3 (seq, res_op, valueize);
++ }
++
++ /* Otherwise try rewriting the operation as an IFN_COND_* call.
++ Again, this isn't a simplification in itself, since it's what
++ RES_OP already described. */
++ if (convert_conditional_op (res_op, &new_op))
++ *res_op = new_op;
++
++ return false;
++}
++
++/* If RES_OP is a call to a conditional internal function, try simplifying
++ the associated unconditional operation and using the result to build
++ a new conditional operation. For example, if RES_OP is:
++
++ IFN_COND_ADD (COND, A, B, ELSE)
++
++ try simplifying (plus A B) and using the result to build a replacement
++ for the whole IFN_COND_ADD.
++
++ Return true if this approach led to a simplification, otherwise leave
++ RES_OP unchanged (and so suitable for other simplifications). When
++ returning true, add any new statements to SEQ and use VALUEIZE as the
++ valueization function.
++
++ RES_OP is known to be a call to IFN. */
++
++static bool
++try_conditional_simplification (internal_fn ifn, gimple_match_op *res_op,
++ gimple_seq *seq, tree (*valueize) (tree))
++{
++ code_helper op;
++ tree_code code = conditional_internal_fn_code (ifn);
++ if (code != ERROR_MARK)
++ op = code;
++ else
++ {
++ ifn = get_unconditional_internal_fn (ifn);
++ if (ifn == IFN_LAST)
++ return false;
++ op = as_combined_fn (ifn);
++ }
++
++ unsigned int num_ops = res_op->num_ops;
++ gimple_match_op cond_op (gimple_match_cond (res_op->ops[0],
++ res_op->ops[num_ops - 1]),
++ op, res_op->type, num_ops - 2);
++
++ memcpy (cond_op.ops, res_op->ops + 1, (num_ops - 1) * sizeof *cond_op.ops);
++ switch (num_ops - 2)
++ {
++ case 1:
++ if (!gimple_resimplify1 (seq, &cond_op, valueize))
++ return false;
++ break;
++ case 2:
++ if (!gimple_resimplify2 (seq, &cond_op, valueize))
++ return false;
++ break;
++ case 3:
++ if (!gimple_resimplify3 (seq, &cond_op, valueize))
++ return false;
++ break;
++ default:
++ gcc_unreachable ();
++ }
++ *res_op = cond_op;
++ maybe_resimplify_conditional_op (seq, res_op, valueize);
++ return true;
++}
++
++/* Helper for the autogenerated code, valueize OP. */
++
++tree
++do_valueize (tree (*valueize)(tree), tree op)
++{
++ if (valueize && TREE_CODE (op) == SSA_NAME)
++ {
++ tree tem = valueize (op);
++ if (tem)
++ return tem;
++ }
++ return op;
++}
++
++/* Push the exploded expression described by RES_OP as a statement to
++ SEQ if necessary and return a gimple value denoting the value of the
++ expression. If RES is not NULL then the result will be always RES
++ and even gimple values are pushed to SEQ. */
++
++tree
++maybe_push_res_to_seq (gimple_match_op *res_op, gimple_seq *seq, tree res)
++{
++ tree *ops = res_op->ops;
++ unsigned num_ops = res_op->num_ops;
++
++ /* The caller should have converted conditional operations into an UNCOND
++ form and resimplified as appropriate. The conditional form only
++ survives this far if that conversion failed. */
++ if (res_op->cond.cond)
++ return NULL_TREE;
++
++ if (res_op->code.is_tree_code ())
++ {
++ if (!res
++ && gimple_simplified_result_is_gimple_val (res_op))
++ return ops[0];
++ if (mprts_hook)
++ {
++ tree tem = mprts_hook (res_op);
++ if (tem)
++ return tem;
++ }
++ }
++
++ if (!seq)
++ return NULL_TREE;
++
++ /* Play safe and do not allow abnormals to be mentioned in
++ newly created statements. */
++ for (unsigned int i = 0; i < num_ops; ++i)
++ if (TREE_CODE (ops[i]) == SSA_NAME
++ && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[i]))
++ return NULL_TREE;
++
++ if (num_ops > 0 && COMPARISON_CLASS_P (ops[0]))
++ for (unsigned int i = 0; i < 2; ++i)
++ if (TREE_CODE (TREE_OPERAND (ops[0], i)) == SSA_NAME
++ && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (TREE_OPERAND (ops[0], i)))
++ return NULL_TREE;
++
++ if (res_op->code.is_tree_code ())
++ {
++ auto code = tree_code (res_op->code);
++ if (!res)
++ {
++ if (gimple_in_ssa_p (cfun))
++ res = make_ssa_name (res_op->type);
++ else
++ res = create_tmp_reg (res_op->type);
++ }
++ maybe_build_generic_op (res_op);
++ gimple *new_stmt = gimple_build_assign (res, code,
++ res_op->op_or_null (0),
++ res_op->op_or_null (1),
++ res_op->op_or_null (2));
++ gimple_seq_add_stmt_without_update (seq, new_stmt);
++ return res;
++ }
++ else
++ {
++ gcc_assert (num_ops != 0);
++ auto fn = combined_fn (res_op->code);
++ gcall *new_stmt = NULL;
++ if (internal_fn_p (fn))
++ {
++ /* Generate the given function if we can. */
++ internal_fn ifn = as_internal_fn (fn);
++ new_stmt = build_call_internal (ifn, res_op);
++ if (!new_stmt)
++ return NULL_TREE;
++ }
++ else
++ {
++ /* Find the function we want to call. */
++ tree decl = builtin_decl_implicit (as_builtin_fn (fn));
++ if (!decl)
++ return NULL;
++
++ /* We can't and should not emit calls to non-const functions. */
++ if (!(flags_from_decl_or_type (decl) & ECF_CONST))
++ return NULL;
++
++ new_stmt = gimple_build_call (decl, num_ops,
++ res_op->op_or_null (0),
++ res_op->op_or_null (1),
++ res_op->op_or_null (2),
++ res_op->op_or_null (3),
++ res_op->op_or_null (4));
++ }
++ if (!res)
++ {
++ if (gimple_in_ssa_p (cfun))
++ res = make_ssa_name (res_op->type);
++ else
++ res = create_tmp_reg (res_op->type);
++ }
++ gimple_call_set_lhs (new_stmt, res);
++ gimple_seq_add_stmt_without_update (seq, new_stmt);
++ return res;
++ }
++}
++
++
++/* Public API overloads follow for operation being tree_code or
++ built_in_function and for one to three operands or arguments.
++ They return NULL_TREE if nothing could be simplified or
++ the resulting simplified value with parts pushed to SEQ.
++ If SEQ is NULL then if the simplification needs to create
++ new stmts it will fail. If VALUEIZE is non-NULL then all
++ SSA names will be valueized using that hook prior to
++ applying simplifications. */
++
++/* Unary ops. */
++
++tree
++gimple_simplify (enum tree_code code, tree type,
++ tree op0,
++ gimple_seq *seq, tree (*valueize)(tree))
++{
++ if (constant_for_folding (op0))
++ {
++ tree res = const_unop (code, type, op0);
++ if (res != NULL_TREE
++ && CONSTANT_CLASS_P (res))
++ return res;
++ }
++
++ gimple_match_op res_op;
++ if (!gimple_simplify (&res_op, seq, valueize, code, type, op0))
++ return NULL_TREE;
++ return maybe_push_res_to_seq (&res_op, seq);
++}
++
++/* Binary ops. */
++
++tree
++gimple_simplify (enum tree_code code, tree type,
++ tree op0, tree op1,
++ gimple_seq *seq, tree (*valueize)(tree))
++{
++ if (constant_for_folding (op0) && constant_for_folding (op1))
++ {
++ tree res = const_binop (code, type, op0, op1);
++ if (res != NULL_TREE
++ && CONSTANT_CLASS_P (res))
++ return res;
++ }
++
++ /* Canonicalize operand order both for matching and fallback stmt
++ generation. */
++ if ((commutative_tree_code (code)
++ || TREE_CODE_CLASS (code) == tcc_comparison)
++ && tree_swap_operands_p (op0, op1))
++ {
++ std::swap (op0, op1);
++ if (TREE_CODE_CLASS (code) == tcc_comparison)
++ code = swap_tree_comparison (code);
++ }
++
++ gimple_match_op res_op;
++ if (!gimple_simplify (&res_op, seq, valueize, code, type, op0, op1))
++ return NULL_TREE;
++ return maybe_push_res_to_seq (&res_op, seq);
++}
++
++/* Ternary ops. */
++
++tree
++gimple_simplify (enum tree_code code, tree type,
++ tree op0, tree op1, tree op2,
++ gimple_seq *seq, tree (*valueize)(tree))
++{
++ if (constant_for_folding (op0) && constant_for_folding (op1)
++ && constant_for_folding (op2))
++ {
++ tree res = fold_ternary/*_to_constant */ (code, type, op0, op1, op2);
++ if (res != NULL_TREE
++ && CONSTANT_CLASS_P (res))
++ return res;
++ }
++
++ /* Canonicalize operand order both for matching and fallback stmt
++ generation. */
++ if (commutative_ternary_tree_code (code)
++ && tree_swap_operands_p (op0, op1))
++ std::swap (op0, op1);
++
++ gimple_match_op res_op;
++ if (!gimple_simplify (&res_op, seq, valueize, code, type, op0, op1, op2))
++ return NULL_TREE;
++ return maybe_push_res_to_seq (&res_op, seq);
++}
++
++/* Builtin or internal function with one argument. */
++
++tree
++gimple_simplify (combined_fn fn, tree type,
++ tree arg0,
++ gimple_seq *seq, tree (*valueize)(tree))
++{
++ if (constant_for_folding (arg0))
++ {
++ tree res = fold_const_call (fn, type, arg0);
++ if (res && CONSTANT_CLASS_P (res))
++ return res;
++ }
++
++ gimple_match_op res_op;
++ if (!gimple_simplify (&res_op, seq, valueize, fn, type, arg0))
++ return NULL_TREE;
++ return maybe_push_res_to_seq (&res_op, seq);
++}
++
++/* Builtin or internal function with two arguments. */
++
++tree
++gimple_simplify (combined_fn fn, tree type,
++ tree arg0, tree arg1,
++ gimple_seq *seq, tree (*valueize)(tree))
++{
++ if (constant_for_folding (arg0)
++ && constant_for_folding (arg1))
++ {
++ tree res = fold_const_call (fn, type, arg0, arg1);
++ if (res && CONSTANT_CLASS_P (res))
++ return res;
++ }
++
++ gimple_match_op res_op;
++ if (!gimple_simplify (&res_op, seq, valueize, fn, type, arg0, arg1))
++ return NULL_TREE;
++ return maybe_push_res_to_seq (&res_op, seq);
++}
++
++/* Builtin or internal function with three arguments. */
++
++tree
++gimple_simplify (combined_fn fn, tree type,
++ tree arg0, tree arg1, tree arg2,
++ gimple_seq *seq, tree (*valueize)(tree))
++{
++ if (constant_for_folding (arg0)
++ && constant_for_folding (arg1)
++ && constant_for_folding (arg2))
++ {
++ tree res = fold_const_call (fn, type, arg0, arg1, arg2);
++ if (res && CONSTANT_CLASS_P (res))
++ return res;
++ }
++
++ gimple_match_op res_op;
++ if (!gimple_simplify (&res_op, seq, valueize, fn, type, arg0, arg1, arg2))
++ return NULL_TREE;
++ return maybe_push_res_to_seq (&res_op, seq);
++}
++
++/* Common subroutine of gimple_extract_op and gimple_simplify. Try to
++ describe STMT in RES_OP, returning true on success. Before recording
++ an operand, call:
++
++ - VALUEIZE_CONDITION for a COND_EXPR condition
++ - VALUEIZE_OP for every other top-level operand
++
++ Both routines take a tree argument and returns a tree. */
++
++template<typename ValueizeOp, typename ValueizeCondition>
++inline bool
++gimple_extract (gimple *stmt, gimple_match_op *res_op,
++ ValueizeOp valueize_op,
++ ValueizeCondition valueize_condition)
++{
++ switch (gimple_code (stmt))
++ {
++ case GIMPLE_ASSIGN:
++ {
++ enum tree_code code = gimple_assign_rhs_code (stmt);
++ tree type = TREE_TYPE (gimple_assign_lhs (stmt));
++ switch (gimple_assign_rhs_class (stmt))
++ {
++ case GIMPLE_SINGLE_RHS:
++ if (code == REALPART_EXPR
++ || code == IMAGPART_EXPR
++ || code == VIEW_CONVERT_EXPR)
++ {
++ tree op0 = TREE_OPERAND (gimple_assign_rhs1 (stmt), 0);
++ res_op->set_op (code, type, valueize_op (op0));
++ return true;
++ }
++ else if (code == BIT_FIELD_REF)
++ {
++ tree rhs1 = gimple_assign_rhs1 (stmt);
++ tree op0 = valueize_op (TREE_OPERAND (rhs1, 0));
++ res_op->set_op (code, type, op0,
++ TREE_OPERAND (rhs1, 1),
++ TREE_OPERAND (rhs1, 2),
++ REF_REVERSE_STORAGE_ORDER (rhs1));
++ return true;
++ }
++ else if (code == SSA_NAME)
++ {
++ tree op0 = gimple_assign_rhs1 (stmt);
++ res_op->set_op (TREE_CODE (op0), type, valueize_op (op0));
++ return true;
++ }
++ break;
++ case GIMPLE_UNARY_RHS:
++ {
++ tree rhs1 = gimple_assign_rhs1 (stmt);
++ res_op->set_op (code, type, valueize_op (rhs1));
++ return true;
++ }
++ case GIMPLE_BINARY_RHS:
++ {
++ tree rhs1 = valueize_op (gimple_assign_rhs1 (stmt));
++ tree rhs2 = valueize_op (gimple_assign_rhs2 (stmt));
++ res_op->set_op (code, type, rhs1, rhs2);
++ return true;
++ }
++ case GIMPLE_TERNARY_RHS:
++ {
++ tree rhs1 = gimple_assign_rhs1 (stmt);
++ if (code == COND_EXPR && COMPARISON_CLASS_P (rhs1))
++ rhs1 = valueize_condition (rhs1);
++ else
++ rhs1 = valueize_op (rhs1);
++ tree rhs2 = valueize_op (gimple_assign_rhs2 (stmt));
++ tree rhs3 = valueize_op (gimple_assign_rhs3 (stmt));
++ res_op->set_op (code, type, rhs1, rhs2, rhs3);
++ return true;
++ }
++ default:
++ gcc_unreachable ();
++ }
++ break;
++ }
++
++ case GIMPLE_CALL:
++ /* ??? This way we can't simplify calls with side-effects. */
++ if (gimple_call_lhs (stmt) != NULL_TREE
++ && gimple_call_num_args (stmt) >= 1
++ && gimple_call_num_args (stmt) <= 5)
++ {
++ combined_fn cfn;
++ if (gimple_call_internal_p (stmt))
++ cfn = as_combined_fn (gimple_call_internal_fn (stmt));
++ else
++ {
++ tree fn = gimple_call_fn (stmt);
++ if (!fn)
++ return false;
++
++ fn = valueize_op (fn);
++ if (TREE_CODE (fn) != ADDR_EXPR
++ || TREE_CODE (TREE_OPERAND (fn, 0)) != FUNCTION_DECL)
++ return false;
++
++ tree decl = TREE_OPERAND (fn, 0);
++ if (DECL_BUILT_IN_CLASS (decl) != BUILT_IN_NORMAL
++ || !gimple_builtin_call_types_compatible_p (stmt, decl))
++ return false;
++
++ cfn = as_combined_fn (DECL_FUNCTION_CODE (decl));
++ }
++
++ unsigned int num_args = gimple_call_num_args (stmt);
++ res_op->set_op (cfn, TREE_TYPE (gimple_call_lhs (stmt)), num_args);
++ for (unsigned i = 0; i < num_args; ++i)
++ res_op->ops[i] = valueize_op (gimple_call_arg (stmt, i));
++ return true;
++ }
++ break;
++
++ case GIMPLE_COND:
++ {
++ tree lhs = valueize_op (gimple_cond_lhs (stmt));
++ tree rhs = valueize_op (gimple_cond_rhs (stmt));
++ res_op->set_op (gimple_cond_code (stmt), boolean_type_node, lhs, rhs);
++ return true;
++ }
++
++ default:
++ break;
++ }
++
++ return false;
++}
++
++/* Try to describe STMT in RES_OP, returning true on success.
++ For GIMPLE_CONDs, describe the condition that is being tested.
++ For GIMPLE_ASSIGNs, describe the rhs of the assignment.
++ For GIMPLE_CALLs, describe the call. */
++
++bool
++gimple_extract_op (gimple *stmt, gimple_match_op *res_op)
++{
++ auto nop = [](tree op) { return op; };
++ return gimple_extract (stmt, res_op, nop, nop);
++}
++
++/* The main STMT based simplification entry. It is used by the fold_stmt
++ and the fold_stmt_to_constant APIs. */
++
++bool
++gimple_simplify (gimple *stmt, gimple_match_op *res_op, gimple_seq *seq,
++ tree (*valueize)(tree), tree (*top_valueize)(tree))
++{
++ bool valueized = false;
++ auto valueize_op = [&](tree op)
++ {
++ return do_valueize (op, top_valueize, valueized);
++ };
++ auto valueize_condition = [&](tree op) -> tree
++ {
++ bool cond_valueized = false;
++ tree lhs = do_valueize (TREE_OPERAND (op, 0), top_valueize,
++ cond_valueized);
++ tree rhs = do_valueize (TREE_OPERAND (op, 1), top_valueize,
++ cond_valueized);
++ gimple_match_op res_op2 (res_op->cond, TREE_CODE (op),
++ TREE_TYPE (op), lhs, rhs);
++ if ((gimple_resimplify2 (seq, &res_op2, valueize)
++ || cond_valueized)
++ && res_op2.code.is_tree_code ())
++ {
++ auto code = tree_code (res_op2.code);
++ if (TREE_CODE_CLASS (code) == tcc_comparison)
++ {
++ valueized = true;
++ return build2 (code, TREE_TYPE (op),
++ res_op2.ops[0], res_op2.ops[1]);
++ }
++ else if (code == SSA_NAME
++ || code == INTEGER_CST
++ || code == VECTOR_CST)
++ {
++ valueized = true;
++ return res_op2.ops[0];
++ }
++ }
++ return valueize_op (op);
++ };
++
++ if (!gimple_extract (stmt, res_op, valueize_op, valueize_condition))
++ return false;
++
++ if (res_op->code.is_internal_fn ())
++ {
++ internal_fn ifn = internal_fn (res_op->code);
++ if (try_conditional_simplification (ifn, res_op, seq, valueize))
++ return true;
++ }
++
++ if (!res_op->reverse
++ && res_op->num_ops
++ && res_op->resimplify (seq, valueize))
++ return true;
++
++ return valueized;
++}
++
++/* Helper that matches and simplifies the toplevel result from
++ a gimple_simplify run (where we don't want to build
++ a stmt in case it's used in in-place folding). Replaces
++ RES_OP with a simplified and/or canonicalized result and
++ returns whether any change was made. */
++
++static bool
++gimple_resimplify1 (gimple_seq *seq, gimple_match_op *res_op,
++ tree (*valueize)(tree))
++{
++ if (constant_for_folding (res_op->ops[0]))
++ {
++ tree tem = NULL_TREE;
++ if (res_op->code.is_tree_code ())
++ {
++ auto code = tree_code (res_op->code);
++ if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code))
++ && TREE_CODE_LENGTH (code) == 1)
++ tem = const_unop (code, res_op->type, res_op->ops[0]);
++ }
++ else
++ tem = fold_const_call (combined_fn (res_op->code), res_op->type,
++ res_op->ops[0]);
++ if (tem != NULL_TREE
++ && CONSTANT_CLASS_P (tem))
++ {
++ if (TREE_OVERFLOW_P (tem))
++ tem = drop_tree_overflow (tem);
++ res_op->set_value (tem);
++ maybe_resimplify_conditional_op (seq, res_op, valueize);
++ return true;
++ }
++ }
++
++ /* Limit recursion, there are cases like PR80887 and others, for
++ example when value-numbering presents us with unfolded expressions
++ that we are really not prepared to handle without eventual
++ oscillation like ((_50 + 0) + 8) where _50 gets mapped to _50
++ itself as available expression. */
++ static unsigned depth;
++ if (depth > 10)
++ {
++ if (dump_file && (dump_flags & TDF_FOLDING))
++ fprintf (dump_file, "Aborting expression simplification due to "
++ "deep recursion\n");
++ return false;
++ }
++
++ ++depth;
++ gimple_match_op res_op2 (*res_op);
++ if (gimple_simplify (&res_op2, seq, valueize,
++ res_op->code, res_op->type, res_op->ops[0]))
++ {
++ --depth;
++ *res_op = res_op2;
++ return true;
++ }
++ --depth;
++
++ if (maybe_resimplify_conditional_op (seq, res_op, valueize))
++ return true;
++
++ return false;
++}
++
++/* Helper that matches and simplifies the toplevel result from
++ a gimple_simplify run (where we don't want to build
++ a stmt in case it's used in in-place folding). Replaces
++ RES_OP with a simplified and/or canonicalized result and
++ returns whether any change was made. */
++
++static bool
++gimple_resimplify2 (gimple_seq *seq, gimple_match_op *res_op,
++ tree (*valueize)(tree))
++{
++ if (constant_for_folding (res_op->ops[0])
++ && constant_for_folding (res_op->ops[1]))
++ {
++ tree tem = NULL_TREE;
++ if (res_op->code.is_tree_code ())
++ {
++ auto code = tree_code (res_op->code);
++ if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code))
++ && TREE_CODE_LENGTH (code) == 2)
++ tem = const_binop (code, res_op->type,
++ res_op->ops[0], res_op->ops[1]);
++ }
++ else
++ tem = fold_const_call (combined_fn (res_op->code), res_op->type,
++ res_op->ops[0], res_op->ops[1]);
++ if (tem != NULL_TREE
++ && CONSTANT_CLASS_P (tem))
++ {
++ if (TREE_OVERFLOW_P (tem))
++ tem = drop_tree_overflow (tem);
++ res_op->set_value (tem);
++ maybe_resimplify_conditional_op (seq, res_op, valueize);
++ return true;
++ }
++ }
++
++ /* Canonicalize operand order. */
++ bool canonicalized = false;
++ bool is_comparison
++ = (res_op->code.is_tree_code ()
++ && TREE_CODE_CLASS (tree_code (res_op->code)) == tcc_comparison);
++ if ((is_comparison || commutative_binary_op_p (res_op->code, res_op->type))
++ && tree_swap_operands_p (res_op->ops[0], res_op->ops[1]))
++ {
++ std::swap (res_op->ops[0], res_op->ops[1]);
++ if (is_comparison)
++ res_op->code = swap_tree_comparison (tree_code (res_op->code));
++ canonicalized = true;
++ }
++
++ /* Limit recursion, see gimple_resimplify1. */
++ static unsigned depth;
++ if (depth > 10)
++ {
++ if (dump_file && (dump_flags & TDF_FOLDING))
++ fprintf (dump_file, "Aborting expression simplification due to "
++ "deep recursion\n");
++ return false;
++ }
++
++ ++depth;
++ gimple_match_op res_op2 (*res_op);
++ if (gimple_simplify (&res_op2, seq, valueize,
++ res_op->code, res_op->type,
++ res_op->ops[0], res_op->ops[1]))
++ {
++ --depth;
++ *res_op = res_op2;
++ return true;
++ }
++ --depth;
++
++ if (maybe_resimplify_conditional_op (seq, res_op, valueize))
++ return true;
++
++ return canonicalized;
++}
++
++/* Helper that matches and simplifies the toplevel result from
++ a gimple_simplify run (where we don't want to build
++ a stmt in case it's used in in-place folding). Replaces
++ RES_OP with a simplified and/or canonicalized result and
++ returns whether any change was made. */
++
++static bool
++gimple_resimplify3 (gimple_seq *seq, gimple_match_op *res_op,
++ tree (*valueize)(tree))
++{
++ if (constant_for_folding (res_op->ops[0])
++ && constant_for_folding (res_op->ops[1])
++ && constant_for_folding (res_op->ops[2]))
++ {
++ tree tem = NULL_TREE;
++ if (res_op->code.is_tree_code ())
++ {
++ auto code = tree_code (res_op->code);
++ if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code))
++ && TREE_CODE_LENGTH (code) == 3)
++ tem = fold_ternary/*_to_constant*/ (code, res_op->type,
++ res_op->ops[0], res_op->ops[1],
++ res_op->ops[2]);
++ }
++ else
++ tem = fold_const_call (combined_fn (res_op->code), res_op->type,
++ res_op->ops[0], res_op->ops[1], res_op->ops[2]);
++ if (tem != NULL_TREE
++ && CONSTANT_CLASS_P (tem))
++ {
++ if (TREE_OVERFLOW_P (tem))
++ tem = drop_tree_overflow (tem);
++ res_op->set_value (tem);
++ maybe_resimplify_conditional_op (seq, res_op, valueize);
++ return true;
++ }
++ }
++
++ /* Canonicalize operand order. */
++ bool canonicalized = false;
++ int argno = first_commutative_argument (res_op->code, res_op->type);
++ if (argno >= 0
++ && tree_swap_operands_p (res_op->ops[argno], res_op->ops[argno + 1]))
++ {
++ std::swap (res_op->ops[argno], res_op->ops[argno + 1]);
++ canonicalized = true;
++ }
++
++ /* Limit recursion, see gimple_resimplify1. */
++ static unsigned depth;
++ if (depth > 10)
++ {
++ if (dump_file && (dump_flags & TDF_FOLDING))
++ fprintf (dump_file, "Aborting expression simplification due to "
++ "deep recursion\n");
++ return false;
++ }
++
++ ++depth;
++ gimple_match_op res_op2 (*res_op);
++ if (gimple_simplify (&res_op2, seq, valueize,
++ res_op->code, res_op->type,
++ res_op->ops[0], res_op->ops[1], res_op->ops[2]))
++ {
++ --depth;
++ *res_op = res_op2;
++ return true;
++ }
++ --depth;
++
++ if (maybe_resimplify_conditional_op (seq, res_op, valueize))
++ return true;
++
++ return canonicalized;
++}
++
++/* Helper that matches and simplifies the toplevel result from
++ a gimple_simplify run (where we don't want to build
++ a stmt in case it's used in in-place folding). Replaces
++ RES_OP with a simplified and/or canonicalized result and
++ returns whether any change was made. */
++
++static bool
++gimple_resimplify4 (gimple_seq *seq, gimple_match_op *res_op,
++ tree (*valueize)(tree))
++{
++ /* No constant folding is defined for four-operand functions. */
++
++ /* Canonicalize operand order. */
++ bool canonicalized = false;
++ int argno = first_commutative_argument (res_op->code, res_op->type);
++ if (argno >= 0
++ && tree_swap_operands_p (res_op->ops[argno], res_op->ops[argno + 1]))
++ {
++ std::swap (res_op->ops[argno], res_op->ops[argno + 1]);
++ canonicalized = true;
++ }
++
++ /* Limit recursion, see gimple_resimplify1. */
++ static unsigned depth;
++ if (depth > 10)
++ {
++ if (dump_file && (dump_flags & TDF_FOLDING))
++ fprintf (dump_file, "Aborting expression simplification due to "
++ "deep recursion\n");
++ return false;
++ }
++
++ ++depth;
++ gimple_match_op res_op2 (*res_op);
++ if (gimple_simplify (&res_op2, seq, valueize,
++ res_op->code, res_op->type,
++ res_op->ops[0], res_op->ops[1], res_op->ops[2],
++ res_op->ops[3]))
++ {
++ --depth;
++ *res_op = res_op2;
++ return true;
++ }
++ --depth;
++
++ if (maybe_resimplify_conditional_op (seq, res_op, valueize))
++ return true;
++
++ return canonicalized;
++}
++
++/* Helper that matches and simplifies the toplevel result from
++ a gimple_simplify run (where we don't want to build
++ a stmt in case it's used in in-place folding). Replaces
++ RES_OP with a simplified and/or canonicalized result and
++ returns whether any change was made. */
++
++static bool
++gimple_resimplify5 (gimple_seq *seq, gimple_match_op *res_op,
++ tree (*valueize)(tree))
++{
++ /* No constant folding is defined for five-operand functions. */
++
++ /* Canonicalize operand order. */
++ bool canonicalized = false;
++ int argno = first_commutative_argument (res_op->code, res_op->type);
++ if (argno >= 0
++ && tree_swap_operands_p (res_op->ops[argno], res_op->ops[argno + 1]))
++ {
++ std::swap (res_op->ops[argno], res_op->ops[argno + 1]);
++ canonicalized = true;
++ }
++
++ gimple_match_op res_op2 (*res_op);
++ if (gimple_simplify (&res_op2, seq, valueize,
++ res_op->code, res_op->type,
++ res_op->ops[0], res_op->ops[1], res_op->ops[2],
++ res_op->ops[3], res_op->ops[4]))
++ {
++ *res_op = res_op2;
++ return true;
++ }
++
++ if (maybe_resimplify_conditional_op (seq, res_op, valueize))
++ return true;
++
++ return canonicalized;
++}
++
++/* Return a canonical form for CODE when operating on TYPE. The idea
++ is to remove redundant ways of representing the same operation so
++ that code_helpers can be hashed and compared for equality.
++
++ The only current canonicalization is to replace built-in functions
++ with internal functions, in cases where internal-fn.def defines
++ such an internal function.
++
++ Note that the new code_helper cannot necessarily be used in place of
++ the original code_helper. For example, the new code_helper might be
++ an internal function that the target does not support. */
++
++code_helper
++canonicalize_code (code_helper code, tree type)
++{
++ if (code.is_fn_code ())
++ return associated_internal_fn (combined_fn (code), type);
++ return code;
++}
++
++/* Return true if CODE is a binary operation and if CODE is commutative when
++ operating on type TYPE. */
++
++bool
++commutative_binary_op_p (code_helper code, tree type)
++{
++ if (code.is_tree_code ())
++ return commutative_tree_code (tree_code (code));
++ auto cfn = combined_fn (code);
++ return commutative_binary_fn_p (associated_internal_fn (cfn, type));
++}
++
++/* Return true if CODE represents a ternary operation and if the first two
++ operands are commutative when CODE is operating on TYPE. */
++
++bool
++commutative_ternary_op_p (code_helper code, tree type)
++{
++ if (code.is_tree_code ())
++ return commutative_ternary_tree_code (tree_code (code));
++ auto cfn = combined_fn (code);
++ return commutative_ternary_fn_p (associated_internal_fn (cfn, type));
++}
++
++/* If CODE is commutative in two consecutive operands, return the
++ index of the first, otherwise return -1. */
++
++int
++first_commutative_argument (code_helper code, tree type)
++{
++ if (code.is_tree_code ())
++ {
++ auto tcode = tree_code (code);
++ if (commutative_tree_code (tcode)
++ || commutative_ternary_tree_code (tcode))
++ return 0;
++ return -1;
++ }
++ auto cfn = combined_fn (code);
++ return first_commutative_argument (associated_internal_fn (cfn, type));
++}
++
++/* Return true if CODE is a binary operation that is associative when
++ operating on type TYPE. */
++
++bool
++associative_binary_op_p (code_helper code, tree type)
++{
++ if (code.is_tree_code ())
++ return associative_tree_code (tree_code (code));
++ auto cfn = combined_fn (code);
++ return associative_binary_fn_p (associated_internal_fn (cfn, type));
++}
++
++/* Return true if the target directly supports operation CODE on type TYPE.
++ QUERY_TYPE acts as for optab_for_tree_code. */
++
++bool
++directly_supported_p (code_helper code, tree type, optab_subtype query_type)
++{
++ if (code.is_tree_code ())
++ {
++ direct_optab optab = optab_for_tree_code (tree_code (code), type,
++ query_type);
++ return (optab != unknown_optab
++ && optab_handler (optab, TYPE_MODE (type)) != CODE_FOR_nothing);
++ }
++ gcc_assert (query_type == optab_default
++ || (query_type == optab_vector && VECTOR_TYPE_P (type))
++ || (query_type == optab_scalar && !VECTOR_TYPE_P (type)));
++ internal_fn ifn = associated_internal_fn (combined_fn (code), type);
++ return (direct_internal_fn_p (ifn)
++ && direct_internal_fn_supported_p (ifn, type, OPTIMIZE_FOR_SPEED));
++}
++
++/* A wrapper around the internal-fn.cc versions of get_conditional_internal_fn
++ for a code_helper CODE operating on type TYPE. */
++
++internal_fn
++get_conditional_internal_fn (code_helper code, tree type)
++{
++ if (code.is_tree_code ())
++ return get_conditional_internal_fn (tree_code (code));
++ auto cfn = combined_fn (code);
++ return get_conditional_internal_fn (associated_internal_fn (cfn, type));
++}
+diff --git a/gcc/gimple-match-head.cc b/gcc/gimple-match-head.cc
+index 21843d7870b3..3069ff5cb6e1 100644
+--- a/gcc/gimple-match-head.cc
++++ b/gcc/gimple-match-head.cc
+@@ -50,1089 +50,8 @@ along with GCC; see the file COPYING3. If not see
+ #include "attribs.h"
+ #include "asan.h"
+
+-/* Forward declarations of the private auto-generated matchers.
+- They expect valueized operands in canonical order and do not
+- perform simplification of all-constant operands. */
+-static bool gimple_simplify (gimple_match_op *, gimple_seq *, tree (*)(tree),
+- code_helper, tree, tree);
+-static bool gimple_simplify (gimple_match_op *, gimple_seq *, tree (*)(tree),
+- code_helper, tree, tree, tree);
+-static bool gimple_simplify (gimple_match_op *, gimple_seq *, tree (*)(tree),
+- code_helper, tree, tree, tree, tree);
+-static bool gimple_simplify (gimple_match_op *, gimple_seq *, tree (*)(tree),
+- code_helper, tree, tree, tree, tree, tree);
+-static bool gimple_simplify (gimple_match_op *, gimple_seq *, tree (*)(tree),
+- code_helper, tree, tree, tree, tree, tree, tree);
+-static bool gimple_resimplify1 (gimple_seq *, gimple_match_op *,
+- tree (*)(tree));
+-static bool gimple_resimplify2 (gimple_seq *, gimple_match_op *,
+- tree (*)(tree));
+-static bool gimple_resimplify3 (gimple_seq *, gimple_match_op *,
+- tree (*)(tree));
+-static bool gimple_resimplify4 (gimple_seq *, gimple_match_op *,
+- tree (*)(tree));
+-static bool gimple_resimplify5 (gimple_seq *, gimple_match_op *,
+- tree (*)(tree));
+-
+-const unsigned int gimple_match_op::MAX_NUM_OPS;
+-
+-/* Return whether T is a constant that we'll dispatch to fold to
+- evaluate fully constant expressions. */
+-
+-static inline bool
+-constant_for_folding (tree t)
+-{
+- return (CONSTANT_CLASS_P (t)
+- /* The following is only interesting to string builtins. */
+- || (TREE_CODE (t) == ADDR_EXPR
+- && TREE_CODE (TREE_OPERAND (t, 0)) == STRING_CST));
+-}
+-
+-/* Try to convert conditional operation ORIG_OP into an IFN_COND_*
+- operation. Return true on success, storing the new operation in NEW_OP. */
+-
+-static bool
+-convert_conditional_op (gimple_match_op *orig_op,
+- gimple_match_op *new_op)
+-{
+- internal_fn ifn;
+- if (orig_op->code.is_tree_code ())
+- ifn = get_conditional_internal_fn ((tree_code) orig_op->code);
+- else
+- {
+- auto cfn = combined_fn (orig_op->code);
+- if (!internal_fn_p (cfn))
+- return false;
+- ifn = get_conditional_internal_fn (as_internal_fn (cfn));
+- }
+- if (ifn == IFN_LAST)
+- return false;
+- unsigned int num_ops = orig_op->num_ops;
+- new_op->set_op (as_combined_fn (ifn), orig_op->type, num_ops + 2);
+- new_op->ops[0] = orig_op->cond.cond;
+- for (unsigned int i = 0; i < num_ops; ++i)
+- new_op->ops[i + 1] = orig_op->ops[i];
+- tree else_value = orig_op->cond.else_value;
+- if (!else_value)
+- else_value = targetm.preferred_else_value (ifn, orig_op->type,
+- num_ops, orig_op->ops);
+- new_op->ops[num_ops + 1] = else_value;
+- return true;
+-}
+-
+-/* RES_OP is the result of a simplification. If it is conditional,
+- try to replace it with the equivalent UNCOND form, such as an
+- IFN_COND_* call or a VEC_COND_EXPR. Also try to resimplify the
+- result of the replacement if appropriate, adding any new statements to
+- SEQ and using VALUEIZE as the valueization function. Return true if
+- this resimplification occurred and resulted in at least one change. */
+-
+-static bool
+-maybe_resimplify_conditional_op (gimple_seq *seq, gimple_match_op *res_op,
+- tree (*valueize) (tree))
+-{
+- if (!res_op->cond.cond)
+- return false;
+-
+- if (!res_op->cond.else_value
+- && res_op->code.is_tree_code ())
+- {
+- /* The "else" value doesn't matter. If the "then" value is a
+- gimple value, just use it unconditionally. This isn't a
+- simplification in itself, since there was no operation to
+- build in the first place. */
+- if (gimple_simplified_result_is_gimple_val (res_op))
+- {
+- res_op->cond.cond = NULL_TREE;
+- return false;
+- }
+-
+- /* Likewise if the operation would not trap. */
+- bool honor_trapv = (INTEGRAL_TYPE_P (res_op->type)
+- && TYPE_OVERFLOW_TRAPS (res_op->type));
+- tree_code op_code = (tree_code) res_op->code;
+- bool op_could_trap;
+-
+- /* COND_EXPR will trap if, and only if, the condition
+- traps and hence we have to check this. For all other operations, we
+- don't need to consider the operands. */
+- if (op_code == COND_EXPR)
+- op_could_trap = generic_expr_could_trap_p (res_op->ops[0]);
+- else
+- op_could_trap = operation_could_trap_p ((tree_code) res_op->code,
+- FLOAT_TYPE_P (res_op->type),
+- honor_trapv,
+- res_op->op_or_null (1));
+-
+- if (!op_could_trap)
+- {
+- res_op->cond.cond = NULL_TREE;
+- return false;
+- }
+- }
+-
+- /* If the "then" value is a gimple value and the "else" value matters,
+- create a VEC_COND_EXPR between them, then see if it can be further
+- simplified. */
+- gimple_match_op new_op;
+- if (res_op->cond.else_value
+- && VECTOR_TYPE_P (res_op->type)
+- && gimple_simplified_result_is_gimple_val (res_op))
+- {
+- new_op.set_op (VEC_COND_EXPR, res_op->type,
+- res_op->cond.cond, res_op->ops[0],
+- res_op->cond.else_value);
+- *res_op = new_op;
+- return gimple_resimplify3 (seq, res_op, valueize);
+- }
+-
+- /* Otherwise try rewriting the operation as an IFN_COND_* call.
+- Again, this isn't a simplification in itself, since it's what
+- RES_OP already described. */
+- if (convert_conditional_op (res_op, &new_op))
+- *res_op = new_op;
+-
+- return false;
+-}
+-
+-/* Helper that matches and simplifies the toplevel result from
+- a gimple_simplify run (where we don't want to build
+- a stmt in case it's used in in-place folding). Replaces
+- RES_OP with a simplified and/or canonicalized result and
+- returns whether any change was made. */
+-
+-static bool
+-gimple_resimplify1 (gimple_seq *seq, gimple_match_op *res_op,
+- tree (*valueize)(tree))
+-{
+- if (constant_for_folding (res_op->ops[0]))
+- {
+- tree tem = NULL_TREE;
+- if (res_op->code.is_tree_code ())
+- {
+- auto code = tree_code (res_op->code);
+- if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code))
+- && TREE_CODE_LENGTH (code) == 1)
+- tem = const_unop (code, res_op->type, res_op->ops[0]);
+- }
+- else
+- tem = fold_const_call (combined_fn (res_op->code), res_op->type,
+- res_op->ops[0]);
+- if (tem != NULL_TREE
+- && CONSTANT_CLASS_P (tem))
+- {
+- if (TREE_OVERFLOW_P (tem))
+- tem = drop_tree_overflow (tem);
+- res_op->set_value (tem);
+- maybe_resimplify_conditional_op (seq, res_op, valueize);
+- return true;
+- }
+- }
+-
+- /* Limit recursion, there are cases like PR80887 and others, for
+- example when value-numbering presents us with unfolded expressions
+- that we are really not prepared to handle without eventual
+- oscillation like ((_50 + 0) + 8) where _50 gets mapped to _50
+- itself as available expression. */
+- static unsigned depth;
+- if (depth > 10)
+- {
+- if (dump_file && (dump_flags & TDF_FOLDING))
+- fprintf (dump_file, "Aborting expression simplification due to "
+- "deep recursion\n");
+- return false;
+- }
+-
+- ++depth;
+- gimple_match_op res_op2 (*res_op);
+- if (gimple_simplify (&res_op2, seq, valueize,
+- res_op->code, res_op->type, res_op->ops[0]))
+- {
+- --depth;
+- *res_op = res_op2;
+- return true;
+- }
+- --depth;
+-
+- if (maybe_resimplify_conditional_op (seq, res_op, valueize))
+- return true;
+-
+- return false;
+-}
+-
+-/* Helper that matches and simplifies the toplevel result from
+- a gimple_simplify run (where we don't want to build
+- a stmt in case it's used in in-place folding). Replaces
+- RES_OP with a simplified and/or canonicalized result and
+- returns whether any change was made. */
+-
+-static bool
+-gimple_resimplify2 (gimple_seq *seq, gimple_match_op *res_op,
+- tree (*valueize)(tree))
+-{
+- if (constant_for_folding (res_op->ops[0])
+- && constant_for_folding (res_op->ops[1]))
+- {
+- tree tem = NULL_TREE;
+- if (res_op->code.is_tree_code ())
+- {
+- auto code = tree_code (res_op->code);
+- if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code))
+- && TREE_CODE_LENGTH (code) == 2)
+- tem = const_binop (code, res_op->type,
+- res_op->ops[0], res_op->ops[1]);
+- }
+- else
+- tem = fold_const_call (combined_fn (res_op->code), res_op->type,
+- res_op->ops[0], res_op->ops[1]);
+- if (tem != NULL_TREE
+- && CONSTANT_CLASS_P (tem))
+- {
+- if (TREE_OVERFLOW_P (tem))
+- tem = drop_tree_overflow (tem);
+- res_op->set_value (tem);
+- maybe_resimplify_conditional_op (seq, res_op, valueize);
+- return true;
+- }
+- }
+-
+- /* Canonicalize operand order. */
+- bool canonicalized = false;
+- bool is_comparison
+- = (res_op->code.is_tree_code ()
+- && TREE_CODE_CLASS (tree_code (res_op->code)) == tcc_comparison);
+- if ((is_comparison || commutative_binary_op_p (res_op->code, res_op->type))
+- && tree_swap_operands_p (res_op->ops[0], res_op->ops[1]))
+- {
+- std::swap (res_op->ops[0], res_op->ops[1]);
+- if (is_comparison)
+- res_op->code = swap_tree_comparison (tree_code (res_op->code));
+- canonicalized = true;
+- }
+-
+- /* Limit recursion, see gimple_resimplify1. */
+- static unsigned depth;
+- if (depth > 10)
+- {
+- if (dump_file && (dump_flags & TDF_FOLDING))
+- fprintf (dump_file, "Aborting expression simplification due to "
+- "deep recursion\n");
+- return false;
+- }
+-
+- ++depth;
+- gimple_match_op res_op2 (*res_op);
+- if (gimple_simplify (&res_op2, seq, valueize,
+- res_op->code, res_op->type,
+- res_op->ops[0], res_op->ops[1]))
+- {
+- --depth;
+- *res_op = res_op2;
+- return true;
+- }
+- --depth;
+-
+- if (maybe_resimplify_conditional_op (seq, res_op, valueize))
+- return true;
+-
+- return canonicalized;
+-}
+-
+-/* Helper that matches and simplifies the toplevel result from
+- a gimple_simplify run (where we don't want to build
+- a stmt in case it's used in in-place folding). Replaces
+- RES_OP with a simplified and/or canonicalized result and
+- returns whether any change was made. */
+-
+-static bool
+-gimple_resimplify3 (gimple_seq *seq, gimple_match_op *res_op,
+- tree (*valueize)(tree))
+-{
+- if (constant_for_folding (res_op->ops[0])
+- && constant_for_folding (res_op->ops[1])
+- && constant_for_folding (res_op->ops[2]))
+- {
+- tree tem = NULL_TREE;
+- if (res_op->code.is_tree_code ())
+- {
+- auto code = tree_code (res_op->code);
+- if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code))
+- && TREE_CODE_LENGTH (code) == 3)
+- tem = fold_ternary/*_to_constant*/ (code, res_op->type,
+- res_op->ops[0], res_op->ops[1],
+- res_op->ops[2]);
+- }
+- else
+- tem = fold_const_call (combined_fn (res_op->code), res_op->type,
+- res_op->ops[0], res_op->ops[1], res_op->ops[2]);
+- if (tem != NULL_TREE
+- && CONSTANT_CLASS_P (tem))
+- {
+- if (TREE_OVERFLOW_P (tem))
+- tem = drop_tree_overflow (tem);
+- res_op->set_value (tem);
+- maybe_resimplify_conditional_op (seq, res_op, valueize);
+- return true;
+- }
+- }
+-
+- /* Canonicalize operand order. */
+- bool canonicalized = false;
+- int argno = first_commutative_argument (res_op->code, res_op->type);
+- if (argno >= 0
+- && tree_swap_operands_p (res_op->ops[argno], res_op->ops[argno + 1]))
+- {
+- std::swap (res_op->ops[argno], res_op->ops[argno + 1]);
+- canonicalized = true;
+- }
+-
+- /* Limit recursion, see gimple_resimplify1. */
+- static unsigned depth;
+- if (depth > 10)
+- {
+- if (dump_file && (dump_flags & TDF_FOLDING))
+- fprintf (dump_file, "Aborting expression simplification due to "
+- "deep recursion\n");
+- return false;
+- }
+-
+- ++depth;
+- gimple_match_op res_op2 (*res_op);
+- if (gimple_simplify (&res_op2, seq, valueize,
+- res_op->code, res_op->type,
+- res_op->ops[0], res_op->ops[1], res_op->ops[2]))
+- {
+- --depth;
+- *res_op = res_op2;
+- return true;
+- }
+- --depth;
+-
+- if (maybe_resimplify_conditional_op (seq, res_op, valueize))
+- return true;
+-
+- return canonicalized;
+-}
+-
+-/* Helper that matches and simplifies the toplevel result from
+- a gimple_simplify run (where we don't want to build
+- a stmt in case it's used in in-place folding). Replaces
+- RES_OP with a simplified and/or canonicalized result and
+- returns whether any change was made. */
+-
+-static bool
+-gimple_resimplify4 (gimple_seq *seq, gimple_match_op *res_op,
+- tree (*valueize)(tree))
+-{
+- /* No constant folding is defined for four-operand functions. */
+-
+- /* Canonicalize operand order. */
+- bool canonicalized = false;
+- int argno = first_commutative_argument (res_op->code, res_op->type);
+- if (argno >= 0
+- && tree_swap_operands_p (res_op->ops[argno], res_op->ops[argno + 1]))
+- {
+- std::swap (res_op->ops[argno], res_op->ops[argno + 1]);
+- canonicalized = true;
+- }
+-
+- /* Limit recursion, see gimple_resimplify1. */
+- static unsigned depth;
+- if (depth > 10)
+- {
+- if (dump_file && (dump_flags & TDF_FOLDING))
+- fprintf (dump_file, "Aborting expression simplification due to "
+- "deep recursion\n");
+- return false;
+- }
+-
+- ++depth;
+- gimple_match_op res_op2 (*res_op);
+- if (gimple_simplify (&res_op2, seq, valueize,
+- res_op->code, res_op->type,
+- res_op->ops[0], res_op->ops[1], res_op->ops[2],
+- res_op->ops[3]))
+- {
+- --depth;
+- *res_op = res_op2;
+- return true;
+- }
+- --depth;
+-
+- if (maybe_resimplify_conditional_op (seq, res_op, valueize))
+- return true;
+-
+- return canonicalized;
+-}
+-
+-/* Helper that matches and simplifies the toplevel result from
+- a gimple_simplify run (where we don't want to build
+- a stmt in case it's used in in-place folding). Replaces
+- RES_OP with a simplified and/or canonicalized result and
+- returns whether any change was made. */
+-
+-static bool
+-gimple_resimplify5 (gimple_seq *seq, gimple_match_op *res_op,
+- tree (*valueize)(tree))
+-{
+- /* No constant folding is defined for five-operand functions. */
+-
+- /* Canonicalize operand order. */
+- bool canonicalized = false;
+- int argno = first_commutative_argument (res_op->code, res_op->type);
+- if (argno >= 0
+- && tree_swap_operands_p (res_op->ops[argno], res_op->ops[argno + 1]))
+- {
+- std::swap (res_op->ops[argno], res_op->ops[argno + 1]);
+- canonicalized = true;
+- }
+-
+- gimple_match_op res_op2 (*res_op);
+- if (gimple_simplify (&res_op2, seq, valueize,
+- res_op->code, res_op->type,
+- res_op->ops[0], res_op->ops[1], res_op->ops[2],
+- res_op->ops[3], res_op->ops[4]))
+- {
+- *res_op = res_op2;
+- return true;
+- }
+-
+- if (maybe_resimplify_conditional_op (seq, res_op, valueize))
+- return true;
+-
+- return canonicalized;
+-}
+-
+-/* Match and simplify the toplevel valueized operation THIS.
+- Replaces THIS with a simplified and/or canonicalized result and
+- returns whether any change was made. */
+-
+-bool
+-gimple_match_op::resimplify (gimple_seq *seq, tree (*valueize)(tree))
+-{
+- switch (num_ops)
+- {
+- case 1:
+- return gimple_resimplify1 (seq, this, valueize);
+- case 2:
+- return gimple_resimplify2 (seq, this, valueize);
+- case 3:
+- return gimple_resimplify3 (seq, this, valueize);
+- case 4:
+- return gimple_resimplify4 (seq, this, valueize);
+- case 5:
+- return gimple_resimplify5 (seq, this, valueize);
+- default:
+- gcc_unreachable ();
+- }
+-}
+-
+-/* If in GIMPLE the operation described by RES_OP should be single-rhs,
+- build a GENERIC tree for that expression and update RES_OP accordingly. */
+-
+-void
+-maybe_build_generic_op (gimple_match_op *res_op)
+-{
+- tree_code code = (tree_code) res_op->code;
+- tree val;
+- switch (code)
+- {
+- case REALPART_EXPR:
+- case IMAGPART_EXPR:
+- case VIEW_CONVERT_EXPR:
+- val = build1 (code, res_op->type, res_op->ops[0]);
+- res_op->set_value (val);
+- break;
+- case BIT_FIELD_REF:
+- val = build3 (code, res_op->type, res_op->ops[0], res_op->ops[1],
+- res_op->ops[2]);
+- REF_REVERSE_STORAGE_ORDER (val) = res_op->reverse;
+- res_op->set_value (val);
+- break;
+- default:;
+- }
+-}
+-
+-tree (*mprts_hook) (gimple_match_op *);
+-
+-/* Try to build RES_OP, which is known to be a call to FN. Return null
+- if the target doesn't support the function. */
+-
+-static gcall *
+-build_call_internal (internal_fn fn, gimple_match_op *res_op)
+-{
+- if (direct_internal_fn_p (fn))
+- {
+- tree_pair types = direct_internal_fn_types (fn, res_op->type,
+- res_op->ops);
+- if (!direct_internal_fn_supported_p (fn, types, OPTIMIZE_FOR_BOTH))
+- return NULL;
+- }
+- return gimple_build_call_internal (fn, res_op->num_ops,
+- res_op->op_or_null (0),
+- res_op->op_or_null (1),
+- res_op->op_or_null (2),
+- res_op->op_or_null (3),
+- res_op->op_or_null (4));
+-}
+-
+-/* Push the exploded expression described by RES_OP as a statement to
+- SEQ if necessary and return a gimple value denoting the value of the
+- expression. If RES is not NULL then the result will be always RES
+- and even gimple values are pushed to SEQ. */
+-
+-tree
+-maybe_push_res_to_seq (gimple_match_op *res_op, gimple_seq *seq, tree res)
+-{
+- tree *ops = res_op->ops;
+- unsigned num_ops = res_op->num_ops;
+-
+- /* The caller should have converted conditional operations into an UNCOND
+- form and resimplified as appropriate. The conditional form only
+- survives this far if that conversion failed. */
+- if (res_op->cond.cond)
+- return NULL_TREE;
+-
+- if (res_op->code.is_tree_code ())
+- {
+- if (!res
+- && gimple_simplified_result_is_gimple_val (res_op))
+- return ops[0];
+- if (mprts_hook)
+- {
+- tree tem = mprts_hook (res_op);
+- if (tem)
+- return tem;
+- }
+- }
+-
+- if (!seq)
+- return NULL_TREE;
+-
+- /* Play safe and do not allow abnormals to be mentioned in
+- newly created statements. */
+- for (unsigned int i = 0; i < num_ops; ++i)
+- if (TREE_CODE (ops[i]) == SSA_NAME
+- && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[i]))
+- return NULL_TREE;
+-
+- if (num_ops > 0 && COMPARISON_CLASS_P (ops[0]))
+- for (unsigned int i = 0; i < 2; ++i)
+- if (TREE_CODE (TREE_OPERAND (ops[0], i)) == SSA_NAME
+- && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (TREE_OPERAND (ops[0], i)))
+- return NULL_TREE;
+-
+- if (res_op->code.is_tree_code ())
+- {
+- auto code = tree_code (res_op->code);
+- if (!res)
+- {
+- if (gimple_in_ssa_p (cfun))
+- res = make_ssa_name (res_op->type);
+- else
+- res = create_tmp_reg (res_op->type);
+- }
+- maybe_build_generic_op (res_op);
+- gimple *new_stmt = gimple_build_assign (res, code,
+- res_op->op_or_null (0),
+- res_op->op_or_null (1),
+- res_op->op_or_null (2));
+- gimple_seq_add_stmt_without_update (seq, new_stmt);
+- return res;
+- }
+- else
+- {
+- gcc_assert (num_ops != 0);
+- auto fn = combined_fn (res_op->code);
+- gcall *new_stmt = NULL;
+- if (internal_fn_p (fn))
+- {
+- /* Generate the given function if we can. */
+- internal_fn ifn = as_internal_fn (fn);
+- new_stmt = build_call_internal (ifn, res_op);
+- if (!new_stmt)
+- return NULL_TREE;
+- }
+- else
+- {
+- /* Find the function we want to call. */
+- tree decl = builtin_decl_implicit (as_builtin_fn (fn));
+- if (!decl)
+- return NULL;
+-
+- /* We can't and should not emit calls to non-const functions. */
+- if (!(flags_from_decl_or_type (decl) & ECF_CONST))
+- return NULL;
+-
+- new_stmt = gimple_build_call (decl, num_ops,
+- res_op->op_or_null (0),
+- res_op->op_or_null (1),
+- res_op->op_or_null (2),
+- res_op->op_or_null (3),
+- res_op->op_or_null (4));
+- }
+- if (!res)
+- {
+- if (gimple_in_ssa_p (cfun))
+- res = make_ssa_name (res_op->type);
+- else
+- res = create_tmp_reg (res_op->type);
+- }
+- gimple_call_set_lhs (new_stmt, res);
+- gimple_seq_add_stmt_without_update (seq, new_stmt);
+- return res;
+- }
+-}
+-
+-
+-/* Public API overloads follow for operation being tree_code or
+- built_in_function and for one to three operands or arguments.
+- They return NULL_TREE if nothing could be simplified or
+- the resulting simplified value with parts pushed to SEQ.
+- If SEQ is NULL then if the simplification needs to create
+- new stmts it will fail. If VALUEIZE is non-NULL then all
+- SSA names will be valueized using that hook prior to
+- applying simplifications. */
+-
+-/* Unary ops. */
+-
+-tree
+-gimple_simplify (enum tree_code code, tree type,
+- tree op0,
+- gimple_seq *seq, tree (*valueize)(tree))
+-{
+- if (constant_for_folding (op0))
+- {
+- tree res = const_unop (code, type, op0);
+- if (res != NULL_TREE
+- && CONSTANT_CLASS_P (res))
+- return res;
+- }
+-
+- gimple_match_op res_op;
+- if (!gimple_simplify (&res_op, seq, valueize, code, type, op0))
+- return NULL_TREE;
+- return maybe_push_res_to_seq (&res_op, seq);
+-}
+-
+-/* Binary ops. */
+-
+-tree
+-gimple_simplify (enum tree_code code, tree type,
+- tree op0, tree op1,
+- gimple_seq *seq, tree (*valueize)(tree))
+-{
+- if (constant_for_folding (op0) && constant_for_folding (op1))
+- {
+- tree res = const_binop (code, type, op0, op1);
+- if (res != NULL_TREE
+- && CONSTANT_CLASS_P (res))
+- return res;
+- }
+-
+- /* Canonicalize operand order both for matching and fallback stmt
+- generation. */
+- if ((commutative_tree_code (code)
+- || TREE_CODE_CLASS (code) == tcc_comparison)
+- && tree_swap_operands_p (op0, op1))
+- {
+- std::swap (op0, op1);
+- if (TREE_CODE_CLASS (code) == tcc_comparison)
+- code = swap_tree_comparison (code);
+- }
+-
+- gimple_match_op res_op;
+- if (!gimple_simplify (&res_op, seq, valueize, code, type, op0, op1))
+- return NULL_TREE;
+- return maybe_push_res_to_seq (&res_op, seq);
+-}
+-
+-/* Ternary ops. */
+-
+-tree
+-gimple_simplify (enum tree_code code, tree type,
+- tree op0, tree op1, tree op2,
+- gimple_seq *seq, tree (*valueize)(tree))
+-{
+- if (constant_for_folding (op0) && constant_for_folding (op1)
+- && constant_for_folding (op2))
+- {
+- tree res = fold_ternary/*_to_constant */ (code, type, op0, op1, op2);
+- if (res != NULL_TREE
+- && CONSTANT_CLASS_P (res))
+- return res;
+- }
+-
+- /* Canonicalize operand order both for matching and fallback stmt
+- generation. */
+- if (commutative_ternary_tree_code (code)
+- && tree_swap_operands_p (op0, op1))
+- std::swap (op0, op1);
+-
+- gimple_match_op res_op;
+- if (!gimple_simplify (&res_op, seq, valueize, code, type, op0, op1, op2))
+- return NULL_TREE;
+- return maybe_push_res_to_seq (&res_op, seq);
+-}
+-
+-/* Builtin or internal function with one argument. */
+-
+-tree
+-gimple_simplify (combined_fn fn, tree type,
+- tree arg0,
+- gimple_seq *seq, tree (*valueize)(tree))
+-{
+- if (constant_for_folding (arg0))
+- {
+- tree res = fold_const_call (fn, type, arg0);
+- if (res && CONSTANT_CLASS_P (res))
+- return res;
+- }
+-
+- gimple_match_op res_op;
+- if (!gimple_simplify (&res_op, seq, valueize, fn, type, arg0))
+- return NULL_TREE;
+- return maybe_push_res_to_seq (&res_op, seq);
+-}
+-
+-/* Builtin or internal function with two arguments. */
+-
+-tree
+-gimple_simplify (combined_fn fn, tree type,
+- tree arg0, tree arg1,
+- gimple_seq *seq, tree (*valueize)(tree))
+-{
+- if (constant_for_folding (arg0)
+- && constant_for_folding (arg1))
+- {
+- tree res = fold_const_call (fn, type, arg0, arg1);
+- if (res && CONSTANT_CLASS_P (res))
+- return res;
+- }
+-
+- gimple_match_op res_op;
+- if (!gimple_simplify (&res_op, seq, valueize, fn, type, arg0, arg1))
+- return NULL_TREE;
+- return maybe_push_res_to_seq (&res_op, seq);
+-}
+-
+-/* Builtin or internal function with three arguments. */
+-
+-tree
+-gimple_simplify (combined_fn fn, tree type,
+- tree arg0, tree arg1, tree arg2,
+- gimple_seq *seq, tree (*valueize)(tree))
+-{
+- if (constant_for_folding (arg0)
+- && constant_for_folding (arg1)
+- && constant_for_folding (arg2))
+- {
+- tree res = fold_const_call (fn, type, arg0, arg1, arg2);
+- if (res && CONSTANT_CLASS_P (res))
+- return res;
+- }
+-
+- gimple_match_op res_op;
+- if (!gimple_simplify (&res_op, seq, valueize, fn, type, arg0, arg1, arg2))
+- return NULL_TREE;
+- return maybe_push_res_to_seq (&res_op, seq);
+-}
+-
+-/* Helper for gimple_simplify valueizing OP using VALUEIZE and setting
+- VALUEIZED to true if valueization changed OP. */
+-
+-static inline tree
+-do_valueize (tree op, tree (*valueize)(tree), bool &valueized)
+-{
+- if (valueize && TREE_CODE (op) == SSA_NAME)
+- {
+- tree tem = valueize (op);
+- if (tem && tem != op)
+- {
+- op = tem;
+- valueized = true;
+- }
+- }
+- return op;
+-}
+-
+-/* If RES_OP is a call to a conditional internal function, try simplifying
+- the associated unconditional operation and using the result to build
+- a new conditional operation. For example, if RES_OP is:
+-
+- IFN_COND_ADD (COND, A, B, ELSE)
+-
+- try simplifying (plus A B) and using the result to build a replacement
+- for the whole IFN_COND_ADD.
+-
+- Return true if this approach led to a simplification, otherwise leave
+- RES_OP unchanged (and so suitable for other simplifications). When
+- returning true, add any new statements to SEQ and use VALUEIZE as the
+- valueization function.
+-
+- RES_OP is known to be a call to IFN. */
+-
+-static bool
+-try_conditional_simplification (internal_fn ifn, gimple_match_op *res_op,
+- gimple_seq *seq, tree (*valueize) (tree))
+-{
+- code_helper op;
+- tree_code code = conditional_internal_fn_code (ifn);
+- if (code != ERROR_MARK)
+- op = code;
+- else
+- {
+- ifn = get_unconditional_internal_fn (ifn);
+- if (ifn == IFN_LAST)
+- return false;
+- op = as_combined_fn (ifn);
+- }
+-
+- unsigned int num_ops = res_op->num_ops;
+- gimple_match_op cond_op (gimple_match_cond (res_op->ops[0],
+- res_op->ops[num_ops - 1]),
+- op, res_op->type, num_ops - 2);
+-
+- memcpy (cond_op.ops, res_op->ops + 1, (num_ops - 1) * sizeof *cond_op.ops);
+- switch (num_ops - 2)
+- {
+- case 1:
+- if (!gimple_resimplify1 (seq, &cond_op, valueize))
+- return false;
+- break;
+- case 2:
+- if (!gimple_resimplify2 (seq, &cond_op, valueize))
+- return false;
+- break;
+- case 3:
+- if (!gimple_resimplify3 (seq, &cond_op, valueize))
+- return false;
+- break;
+- default:
+- gcc_unreachable ();
+- }
+- *res_op = cond_op;
+- maybe_resimplify_conditional_op (seq, res_op, valueize);
+- return true;
+-}
+-
+-/* Common subroutine of gimple_extract_op and gimple_simplify. Try to
+- describe STMT in RES_OP, returning true on success. Before recording
+- an operand, call:
+-
+- - VALUEIZE_CONDITION for a COND_EXPR condition
+- - VALUEIZE_OP for every other top-level operand
+-
+- Both routines take a tree argument and returns a tree. */
+-
+-template<typename ValueizeOp, typename ValueizeCondition>
+-inline bool
+-gimple_extract (gimple *stmt, gimple_match_op *res_op,
+- ValueizeOp valueize_op,
+- ValueizeCondition valueize_condition)
+-{
+- switch (gimple_code (stmt))
+- {
+- case GIMPLE_ASSIGN:
+- {
+- enum tree_code code = gimple_assign_rhs_code (stmt);
+- tree type = TREE_TYPE (gimple_assign_lhs (stmt));
+- switch (gimple_assign_rhs_class (stmt))
+- {
+- case GIMPLE_SINGLE_RHS:
+- if (code == REALPART_EXPR
+- || code == IMAGPART_EXPR
+- || code == VIEW_CONVERT_EXPR)
+- {
+- tree op0 = TREE_OPERAND (gimple_assign_rhs1 (stmt), 0);
+- res_op->set_op (code, type, valueize_op (op0));
+- return true;
+- }
+- else if (code == BIT_FIELD_REF)
+- {
+- tree rhs1 = gimple_assign_rhs1 (stmt);
+- tree op0 = valueize_op (TREE_OPERAND (rhs1, 0));
+- res_op->set_op (code, type, op0,
+- TREE_OPERAND (rhs1, 1),
+- TREE_OPERAND (rhs1, 2),
+- REF_REVERSE_STORAGE_ORDER (rhs1));
+- return true;
+- }
+- else if (code == SSA_NAME)
+- {
+- tree op0 = gimple_assign_rhs1 (stmt);
+- res_op->set_op (TREE_CODE (op0), type, valueize_op (op0));
+- return true;
+- }
+- break;
+- case GIMPLE_UNARY_RHS:
+- {
+- tree rhs1 = gimple_assign_rhs1 (stmt);
+- res_op->set_op (code, type, valueize_op (rhs1));
+- return true;
+- }
+- case GIMPLE_BINARY_RHS:
+- {
+- tree rhs1 = valueize_op (gimple_assign_rhs1 (stmt));
+- tree rhs2 = valueize_op (gimple_assign_rhs2 (stmt));
+- res_op->set_op (code, type, rhs1, rhs2);
+- return true;
+- }
+- case GIMPLE_TERNARY_RHS:
+- {
+- tree rhs1 = gimple_assign_rhs1 (stmt);
+- if (code == COND_EXPR && COMPARISON_CLASS_P (rhs1))
+- rhs1 = valueize_condition (rhs1);
+- else
+- rhs1 = valueize_op (rhs1);
+- tree rhs2 = valueize_op (gimple_assign_rhs2 (stmt));
+- tree rhs3 = valueize_op (gimple_assign_rhs3 (stmt));
+- res_op->set_op (code, type, rhs1, rhs2, rhs3);
+- return true;
+- }
+- default:
+- gcc_unreachable ();
+- }
+- break;
+- }
+-
+- case GIMPLE_CALL:
+- /* ??? This way we can't simplify calls with side-effects. */
+- if (gimple_call_lhs (stmt) != NULL_TREE
+- && gimple_call_num_args (stmt) >= 1
+- && gimple_call_num_args (stmt) <= 5)
+- {
+- combined_fn cfn;
+- if (gimple_call_internal_p (stmt))
+- cfn = as_combined_fn (gimple_call_internal_fn (stmt));
+- else
+- {
+- tree fn = gimple_call_fn (stmt);
+- if (!fn)
+- return false;
+-
+- fn = valueize_op (fn);
+- if (TREE_CODE (fn) != ADDR_EXPR
+- || TREE_CODE (TREE_OPERAND (fn, 0)) != FUNCTION_DECL)
+- return false;
+-
+- tree decl = TREE_OPERAND (fn, 0);
+- if (DECL_BUILT_IN_CLASS (decl) != BUILT_IN_NORMAL
+- || !gimple_builtin_call_types_compatible_p (stmt, decl))
+- return false;
+-
+- cfn = as_combined_fn (DECL_FUNCTION_CODE (decl));
+- }
+-
+- unsigned int num_args = gimple_call_num_args (stmt);
+- res_op->set_op (cfn, TREE_TYPE (gimple_call_lhs (stmt)), num_args);
+- for (unsigned i = 0; i < num_args; ++i)
+- res_op->ops[i] = valueize_op (gimple_call_arg (stmt, i));
+- return true;
+- }
+- break;
+-
+- case GIMPLE_COND:
+- {
+- tree lhs = valueize_op (gimple_cond_lhs (stmt));
+- tree rhs = valueize_op (gimple_cond_rhs (stmt));
+- res_op->set_op (gimple_cond_code (stmt), boolean_type_node, lhs, rhs);
+- return true;
+- }
+-
+- default:
+- break;
+- }
+-
+- return false;
+-}
+-
+-/* Try to describe STMT in RES_OP, returning true on success.
+- For GIMPLE_CONDs, describe the condition that is being tested.
+- For GIMPLE_ASSIGNs, describe the rhs of the assignment.
+- For GIMPLE_CALLs, describe the call. */
+-
+-bool
+-gimple_extract_op (gimple *stmt, gimple_match_op *res_op)
+-{
+- auto nop = [](tree op) { return op; };
+- return gimple_extract (stmt, res_op, nop, nop);
+-}
+-
+-/* The main STMT based simplification entry. It is used by the fold_stmt
+- and the fold_stmt_to_constant APIs. */
+-
+-bool
+-gimple_simplify (gimple *stmt, gimple_match_op *res_op, gimple_seq *seq,
+- tree (*valueize)(tree), tree (*top_valueize)(tree))
+-{
+- bool valueized = false;
+- auto valueize_op = [&](tree op)
+- {
+- return do_valueize (op, top_valueize, valueized);
+- };
+- auto valueize_condition = [&](tree op) -> tree
+- {
+- bool cond_valueized = false;
+- tree lhs = do_valueize (TREE_OPERAND (op, 0), top_valueize,
+- cond_valueized);
+- tree rhs = do_valueize (TREE_OPERAND (op, 1), top_valueize,
+- cond_valueized);
+- gimple_match_op res_op2 (res_op->cond, TREE_CODE (op),
+- TREE_TYPE (op), lhs, rhs);
+- if ((gimple_resimplify2 (seq, &res_op2, valueize)
+- || cond_valueized)
+- && res_op2.code.is_tree_code ())
+- {
+- auto code = tree_code (res_op2.code);
+- if (TREE_CODE_CLASS (code) == tcc_comparison)
+- {
+- valueized = true;
+- return build2 (code, TREE_TYPE (op),
+- res_op2.ops[0], res_op2.ops[1]);
+- }
+- else if (code == SSA_NAME
+- || code == INTEGER_CST
+- || code == VECTOR_CST)
+- {
+- valueized = true;
+- return res_op2.ops[0];
+- }
+- }
+- return valueize_op (op);
+- };
+-
+- if (!gimple_extract (stmt, res_op, valueize_op, valueize_condition))
+- return false;
+-
+- if (res_op->code.is_internal_fn ())
+- {
+- internal_fn ifn = internal_fn (res_op->code);
+- if (try_conditional_simplification (ifn, res_op, seq, valueize))
+- return true;
+- }
+-
+- if (!res_op->reverse
+- && res_op->num_ops
+- && res_op->resimplify (seq, valueize))
+- return true;
+-
+- return valueized;
+-}
+-
+-/* Helper for the autogenerated code, valueize OP. */
+-
+-inline tree
+-do_valueize (tree (*valueize)(tree), tree op)
+-{
+- if (valueize && TREE_CODE (op) == SSA_NAME)
+- {
+- tree tem = valueize (op);
+- if (tem)
+- return tem;
+- }
+- return op;
+-}
++tree do_valueize (tree, tree (*)(tree), bool &);
++tree do_valueize (tree (*)(tree), tree);
+
+ /* Helper for the autogenerated code, get at the definition of NAME when
+ VALUEIZE allows that. */
+@@ -1307,110 +226,3 @@ optimize_successive_divisions_p (tree divisor, tree inner_div)
+ }
+ return true;
+ }
+-
+-/* Return a canonical form for CODE when operating on TYPE. The idea
+- is to remove redundant ways of representing the same operation so
+- that code_helpers can be hashed and compared for equality.
+-
+- The only current canonicalization is to replace built-in functions
+- with internal functions, in cases where internal-fn.def defines
+- such an internal function.
+-
+- Note that the new code_helper cannot necessarily be used in place of
+- the original code_helper. For example, the new code_helper might be
+- an internal function that the target does not support. */
+-
+-code_helper
+-canonicalize_code (code_helper code, tree type)
+-{
+- if (code.is_fn_code ())
+- return associated_internal_fn (combined_fn (code), type);
+- return code;
+-}
+-
+-/* Return true if CODE is a binary operation and if CODE is commutative when
+- operating on type TYPE. */
+-
+-bool
+-commutative_binary_op_p (code_helper code, tree type)
+-{
+- if (code.is_tree_code ())
+- return commutative_tree_code (tree_code (code));
+- auto cfn = combined_fn (code);
+- return commutative_binary_fn_p (associated_internal_fn (cfn, type));
+-}
+-
+-/* Return true if CODE represents a ternary operation and if the first two
+- operands are commutative when CODE is operating on TYPE. */
+-
+-bool
+-commutative_ternary_op_p (code_helper code, tree type)
+-{
+- if (code.is_tree_code ())
+- return commutative_ternary_tree_code (tree_code (code));
+- auto cfn = combined_fn (code);
+- return commutative_ternary_fn_p (associated_internal_fn (cfn, type));
+-}
+-
+-/* If CODE is commutative in two consecutive operands, return the
+- index of the first, otherwise return -1. */
+-
+-int
+-first_commutative_argument (code_helper code, tree type)
+-{
+- if (code.is_tree_code ())
+- {
+- auto tcode = tree_code (code);
+- if (commutative_tree_code (tcode)
+- || commutative_ternary_tree_code (tcode))
+- return 0;
+- return -1;
+- }
+- auto cfn = combined_fn (code);
+- return first_commutative_argument (associated_internal_fn (cfn, type));
+-}
+-
+-/* Return true if CODE is a binary operation that is associative when
+- operating on type TYPE. */
+-
+-bool
+-associative_binary_op_p (code_helper code, tree type)
+-{
+- if (code.is_tree_code ())
+- return associative_tree_code (tree_code (code));
+- auto cfn = combined_fn (code);
+- return associative_binary_fn_p (associated_internal_fn (cfn, type));
+-}
+-
+-/* Return true if the target directly supports operation CODE on type TYPE.
+- QUERY_TYPE acts as for optab_for_tree_code. */
+-
+-bool
+-directly_supported_p (code_helper code, tree type, optab_subtype query_type)
+-{
+- if (code.is_tree_code ())
+- {
+- direct_optab optab = optab_for_tree_code (tree_code (code), type,
+- query_type);
+- return (optab != unknown_optab
+- && optab_handler (optab, TYPE_MODE (type)) != CODE_FOR_nothing);
+- }
+- gcc_assert (query_type == optab_default
+- || (query_type == optab_vector && VECTOR_TYPE_P (type))
+- || (query_type == optab_scalar && !VECTOR_TYPE_P (type)));
+- internal_fn ifn = associated_internal_fn (combined_fn (code), type);
+- return (direct_internal_fn_p (ifn)
+- && direct_internal_fn_supported_p (ifn, type, OPTIMIZE_FOR_SPEED));
+-}
+-
+-/* A wrapper around the internal-fn.cc versions of get_conditional_internal_fn
+- for a code_helper CODE operating on type TYPE. */
+-
+-internal_fn
+-get_conditional_internal_fn (code_helper code, tree type)
+-{
+- if (code.is_tree_code ())
+- return get_conditional_internal_fn (tree_code (code));
+- auto cfn = combined_fn (code);
+- return get_conditional_internal_fn (associated_internal_fn (cfn, type));
+-}
+--
+2.44.0
+
diff --git a/13.2.0/gentoo/80_all_match.pd-automatically-partition-match.cc-files.patch b/13.2.0/gentoo/80_all_match.pd-automatically-partition-match.cc-files.patch
new file mode 100644
index 0000000..6405bf8
--- /dev/null
+++ b/13.2.0/gentoo/80_all_match.pd-automatically-partition-match.cc-files.patch
@@ -0,0 +1,524 @@
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109927#c21
+
+From daac5d2f67656dcf8cc2bbff1c6eaa34f3fb55b9 Mon Sep 17 00:00:00 2001
+From: Tamar Christina <tamar.christina@arm.com>
+Date: Fri, 5 May 2023 13:38:50 +0100
+Subject: [PATCH 05/15] match.pd: automatically partition *-match.cc files.
+
+Following on from Richi's RFC[1] this is another attempt to split up match.pd
+into multiple gimple-match and generic-match files. This version is fully
+automated and requires no human intervention.
+
+First things first, some perf numbers. The following shows the effect of the
+patch on my desktop doing parallel compilation of gimple-match:
+
++--------+------------------+--------+------------------+
+| splits | rel. improvement | splits | rel. improvement |
++--------+------------------+--------+------------------+
+| 1 | 0.00% | 33 | 91.03% |
+| 2 | 71.77% | 34 | 84.02% |
+| 3 | 100.71% | 35 | 83.42% |
+| 4 | 143.08% | 36 | 78.80% |
+| 5 | 176.18% | 37 | 74.06% |
+| 6 | 174.40% | 38 | 55.76% |
+| 7 | 176.62% | 39 | 66.90% |
+| 8 | 168.35% | 40 | 18.25% |
+| 9 | 189.80% | 41 | 16.55% |
+| 10 | 171.77% | 42 | 47.02% |
+| 11 | 152.82% | 43 | 15.29% |
+| 12 | 112.20% | 44 | 21.63% |
+| 13 | 158.57% | 45 | 41.53% |
+| 14 | 158.57% | 46 | 21.98% |
+| 15 | 152.07% | 47 | -42.74% |
+| 16 | 151.70% | 48 | -32.62% |
+| 17 | 131.52% | 49 | 11.81% |
+| 18 | 133.11% | 50 | 34.07% |
+| 19 | 137.33% | 51 | 2.71% |
+| 20 | 103.83% | 52 | -22.23% |
+| 21 | 132.47% | 53 | 32.30% |
+| 22 | 116.52% | 54 | 21.45% |
+| 23 | 112.73% | 55 | 40.02% |
+| 24 | 111.94% | 56 | 42.83% |
+| 25 | 112.73% | 57 | -9.98% |
+| 26 | 104.07% | 58 | 18.01% |
+| 27 | 113.27% | 59 | -4.91% |
+| 28 | 96.77% | 60 | 22.94% |
+| 29 | 93.42% | 61 | -3.73% |
+| 30 | 87.67% | 62 | -27.43% |
+| 31 | 89.54% | 63 | -1.05% |
+| 32 | 84.42% | 64 | -5.44% |
++--------+------------------+--------+------------------+
+
+As can be seen there seems to be a point of diminishing returns in doing splits.
+This comes from the fact that these match files consume a sizeable amount of
+headers. At a certain point the parsing overhead of the headers dominate and
+you start losing in gains.
+
+As such from this I've made the default 10 splits per file to allow for some
+room for growth in the future without needing changes to the split amount.
+Since 5-10 show roughly the same gains it means we can afford to double the
+file sizes before we need to up the split amount. This can be controlled
+by the configure parameter --with-matchpd-partitions=.
+
+At 10 splits the sizes of the files are:
+
+ 1.2M gimple-match-1.cc
+ 490K gimple-match-2.cc
+ 459K gimple-match-3.cc
+ 462K gimple-match-4.cc
+ 466K gimple-match-5.cc
+ 690K gimple-match-6.cc
+ 517K gimple-match-7.cc
+ 693K gimple-match-8.cc
+1011K gimple-match-9.cc
+ 490K gimple-match-10.cc
+ 210K gimple-match-auto.h
+
+The reason gimple-match-1.cc is so large is because it got allocated a very
+large function: gimple_simplify_NE_EXPR.
+
+Because of these sporadically large functions the allocation to a split happens
+based on the amount of data already written to a split instead of just a simple
+round robin allocation (though the patch supports that too.). This means that
+once gimple_simplify_NE_EXPR is allocated to gimple-match-1.cc nothing uses it
+again until the rest of the files catch up.
+
+To support this split a new header file *-match-auto.h is generated to allow
+the individual files to compile separately.
+
+Lastly for the auto generated files I use pragmas to silence the unused
+predicate warnings instead of the previous Makefile way because I couldn't find
+a way to set them without knowing the number of split files beforehand.
+
+Finally with this change, bootstrap time has dropped 8 minutes on AArch64.
+
+[1] https://gcc.gnu.org/legacy-ml/gcc-patches/2018-04/msg01125.html
+
+gcc/ChangeLog:
+
+ PR bootstrap/84402
+ * genmatch.cc (emit_func, SIZED_BASED_CHUNKS, get_out_file): New.
+ (decision_tree::gen): Accept list of files instead of single and update
+ to write function definition to header and main file.
+ (write_predicate): Likewise.
+ (write_header): Emit pragmas and new includes.
+ (main): Create file buffers and cleanup.
+ (showUsage, write_header_includes): New.
+
+(cherry picked from commit 703417a030b3d80f55ba1402adc3f1692d3631e5)
+---
+ gcc/genmatch.cc | 226 ++++++++++++++++++++++++++++++++++++++++--------
+ 1 file changed, 190 insertions(+), 36 deletions(-)
+
+diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc
+index 665d7e2106ff..f80e4b972288 100644
+--- a/gcc/genmatch.cc
++++ b/gcc/genmatch.cc
+@@ -183,6 +183,33 @@ fprintf_indent (FILE *f, unsigned int indent, const char *format, ...)
+ va_end (ap);
+ }
+
++/* Like fprintf, but print to two files, one header one C implementation. */
++FILE *header_file = NULL;
++
++static void
++#if GCC_VERSION >= 4001
++__attribute__((format (printf, 4, 5)))
++#endif
++emit_func (FILE *f, bool open, bool close, const char *format, ...)
++{
++ va_list ap1, ap2;
++ if (header_file != NULL)
++ {
++ if (open)
++ fprintf (header_file, "extern ");
++ va_start (ap2, format);
++ vfprintf (header_file, format, ap2);
++ va_end (ap2);
++ if (close)
++ fprintf (header_file, ";\n");
++ }
++
++ va_start (ap1, format);
++ vfprintf (f, format, ap1);
++ va_end (ap1);
++ fputc ('\n', f);
++}
++
+ static void
+ output_line_directive (FILE *f, location_t location,
+ bool dumpfile = false, bool fnargs = false)
+@@ -217,6 +244,37 @@ output_line_directive (FILE *f, location_t location,
+ fprintf (f, "/* #line %d \"%s\" */\n", loc.line, loc.file);
+ }
+
++/* Find the file to write into next. We try to evenly distribute the contents
++ over the different files. */
++
++#define SIZED_BASED_CHUNKS 1
++
++int current_file = 0;
++FILE *get_out_file (vec <FILE *> &parts)
++{
++#ifdef SIZED_BASED_CHUNKS
++ if (parts.length () == 1)
++ return parts[0];
++
++ FILE *f = NULL;
++ long min = 0;
++ /* We've started writing all the files at pos 0, so ftell is equivalent
++ to the size and should be much faster. */
++ for (unsigned i = 0; i < parts.length (); i++)
++ {
++ long res = ftell (parts[i]);
++ if (!f || res < min)
++ {
++ min = res;
++ f = parts[i];
++ }
++ }
++ return f;
++#else
++ return parts[current_file++ % parts.length ()];
++#endif
++}
++
+
+ /* Pull in tree codes and builtin function codes from their
+ definition files. */
+@@ -1732,7 +1790,7 @@ public:
+ dt_node *root;
+
+ void insert (class simplify *, unsigned);
+- void gen (FILE *f, bool gimple);
++ void gen (vec <FILE *> &f, bool gimple);
+ void print (FILE *f = stderr);
+
+ decision_tree () { root = new dt_node (dt_node::DT_NODE, NULL); }
+@@ -3832,7 +3890,7 @@ sinfo_hashmap_traits::equal_keys (const key_type &v,
+ tree. */
+
+ void
+-decision_tree::gen (FILE *f, bool gimple)
++decision_tree::gen (vec <FILE *> &files, bool gimple)
+ {
+ sinfo_map_t si;
+
+@@ -3861,11 +3919,14 @@ decision_tree::gen (FILE *f, bool gimple)
+ output_line_directive (stderr, s->s->s->result->location);
+ }
+
++ /* Cycle the file buffers. */
++ FILE *f = get_out_file (files);
++
+ /* Generate a split out function with the leaf transform code. */
+ s->fname = xasprintf ("%s_simplify_%u", gimple ? "gimple" : "generic",
+ fcnt++);
+ if (gimple)
+- fprintf (f, "\nstatic bool\n"
++ emit_func (f, true, false, "\nbool\n"
+ "%s (gimple_match_op *res_op, gimple_seq *seq,\n"
+ " tree (*valueize)(tree) ATTRIBUTE_UNUSED,\n"
+ " const tree ARG_UNUSED (type), tree *ARG_UNUSED "
+@@ -3873,27 +3934,28 @@ decision_tree::gen (FILE *f, bool gimple)
+ s->fname);
+ else
+ {
+- fprintf (f, "\nstatic tree\n"
++ emit_func (f, true, false, "\ntree\n"
+ "%s (location_t ARG_UNUSED (loc), const tree ARG_UNUSED (type),\n",
+ (*iter).second->fname);
+ for (unsigned i = 0;
+ i < as_a <expr *>(s->s->s->match)->ops.length (); ++i)
+- fprintf (f, " tree ARG_UNUSED (_p%d),", i);
+- fprintf (f, " tree *captures\n");
++ emit_func (f, false, false, " tree ARG_UNUSED (_p%d),", i);
++ emit_func (f, false, false, " tree *captures\n");
+ }
+ for (unsigned i = 0; i < s->s->s->for_subst_vec.length (); ++i)
+ {
+ if (! s->s->s->for_subst_vec[i].first->used)
+ continue;
+ if (is_a <operator_id *> (s->s->s->for_subst_vec[i].second))
+- fprintf (f, ", const enum tree_code ARG_UNUSED (%s)",
++ emit_func (f, false, false, ", const enum tree_code ARG_UNUSED (%s)",
+ s->s->s->for_subst_vec[i].first->id);
+ else if (is_a <fn_id *> (s->s->s->for_subst_vec[i].second))
+- fprintf (f, ", const combined_fn ARG_UNUSED (%s)",
++ emit_func (f, false, false, ", const combined_fn ARG_UNUSED (%s)",
+ s->s->s->for_subst_vec[i].first->id);
+ }
+
+- fprintf (f, ")\n{\n");
++ emit_func (f, false, true, ")");
++ fprintf (f, "{\n");
+ fprintf_indent (f, 2, "const bool debug_dump = "
+ "dump_file && (dump_flags & TDF_FOLDING);\n");
+ s->s->gen_1 (f, 2, gimple, s->s->s->result);
+@@ -3923,8 +3985,12 @@ decision_tree::gen (FILE *f, bool gimple)
+ && e->operation->kind != id_base::CODE))
+ continue;
+
++
++ /* Cycle the file buffers. */
++ FILE *f = get_out_file (files);
++
+ if (gimple)
+- fprintf (f, "\nstatic bool\n"
++ emit_func (f, true, false,"\nbool\n"
+ "gimple_simplify_%s (gimple_match_op *res_op,"
+ " gimple_seq *seq,\n"
+ " tree (*valueize)(tree) "
+@@ -3933,13 +3999,13 @@ decision_tree::gen (FILE *f, bool gimple)
+ "ARG_UNUSED (type)\n",
+ e->operation->id);
+ else
+- fprintf (f, "\nstatic tree\n"
++ emit_func (f, true, false, "\ntree\n"
+ "generic_simplify_%s (location_t ARG_UNUSED (loc), enum "
+ "tree_code ARG_UNUSED (code), const tree ARG_UNUSED (type)",
+ e->operation->id);
+ for (unsigned i = 0; i < n; ++i)
+- fprintf (f, ", tree _p%d", i);
+- fprintf (f, ")\n");
++ emit_func (f, false, false,", tree _p%d", i);
++ emit_func (f, false, true, ")");
+ fprintf (f, "{\n");
+ fprintf_indent (f, 2, "const bool debug_dump = "
+ "dump_file && (dump_flags & TDF_FOLDING);\n");
+@@ -3956,18 +4022,22 @@ decision_tree::gen (FILE *f, bool gimple)
+ with compiler warnings, by generating a simple stub. */
+ if (! has_kids_p)
+ {
++
++ /* Cycle the file buffers. */
++ FILE *f = get_out_file (files);
++
+ if (gimple)
+- fprintf (f, "\nbool\n"
++ emit_func (f, true, false, "\nbool\n"
+ "gimple_simplify (gimple_match_op*, gimple_seq*,\n"
+ " tree (*)(tree), code_helper,\n"
+ " const tree");
+ else
+- fprintf (f, "\ntree\n"
++ emit_func (f, true, false,"\ntree\n"
+ "generic_simplify (location_t, enum tree_code,\n"
+ " const tree");
+ for (unsigned i = 0; i < n; ++i)
+- fprintf (f, ", tree");
+- fprintf (f, ")\n");
++ emit_func (f, false, false, ", tree");
++ emit_func (f, false, true, ")");
+ fprintf (f, "{\n");
+ if (gimple)
+ fprintf (f, " return false;\n");
+@@ -3977,20 +4047,24 @@ decision_tree::gen (FILE *f, bool gimple)
+ continue;
+ }
+
++
++ /* Cycle the file buffers. */
++ FILE *f = get_out_file (files);
++
+ /* Then generate the main entry with the outermost switch and
+ tail-calls to the split-out functions. */
+ if (gimple)
+- fprintf (f, "\nbool\n"
++ emit_func (f, true, false, "\nbool\n"
+ "gimple_simplify (gimple_match_op *res_op, gimple_seq *seq,\n"
+ " tree (*valueize)(tree) ATTRIBUTE_UNUSED,\n"
+ " code_helper code, const tree type");
+ else
+- fprintf (f, "\ntree\n"
++ emit_func (f, true, false, "\ntree\n"
+ "generic_simplify (location_t loc, enum tree_code code, "
+ "const tree type ATTRIBUTE_UNUSED");
+ for (unsigned i = 0; i < n; ++i)
+- fprintf (f, ", tree _p%d", i);
+- fprintf (f, ")\n");
++ emit_func (f, false, false, ", tree _p%d", i);
++ emit_func (f, false, true, ")");
+ fprintf (f, "{\n");
+
+ if (gimple)
+@@ -4045,11 +4119,11 @@ decision_tree::gen (FILE *f, bool gimple)
+ void
+ write_predicate (FILE *f, predicate_id *p, decision_tree &dt, bool gimple)
+ {
+- fprintf (f, "\nbool\n"
+- "%s%s (tree t%s%s)\n"
+- "{\n", gimple ? "gimple_" : "tree_", p->id,
+- p->nargs > 0 ? ", tree *res_ops" : "",
+- gimple ? ", tree (*valueize)(tree) ATTRIBUTE_UNUSED" : "");
++ emit_func (f, true, true, "\nbool\n%s%s (tree t%s%s)",
++ gimple ? "gimple_" : "tree_", p->id,
++ p->nargs > 0 ? ", tree *res_ops" : "",
++ gimple ? ", tree (*valueize)(tree) ATTRIBUTE_UNUSED" : "");
++ fprintf (f, "{\n");
+ /* Conveniently make 'type' available. */
+ fprintf_indent (f, 2, "const tree type = TREE_TYPE (t);\n");
+ fprintf_indent (f, 2, "const bool debug_dump = "
+@@ -4070,9 +4144,13 @@ write_header (FILE *f, const char *head)
+ {
+ fprintf (f, "/* Generated automatically by the program `genmatch' from\n");
+ fprintf (f, " a IL pattern matching and simplification description. */\n");
++ fprintf (f, "#pragma GCC diagnostic push\n");
++ fprintf (f, "#pragma GCC diagnostic ignored \"-Wunused-variable\"\n");
++ fprintf (f, "#pragma GCC diagnostic ignored \"-Wunused-function\"\n");
+
+ /* Include the header instead of writing it awkwardly quoted here. */
+- fprintf (f, "\n#include \"%s\"\n", head);
++ if (head)
++ fprintf (f, "\n#include \"%s\"\n", head);
+ }
+
+
+@@ -5213,6 +5291,30 @@ round_alloc_size (size_t s)
+ }
+
+
++/* Construct and display the help menu. */
++
++static void
++showUsage ()
++{
++ fprintf (stderr, "Usage: genmatch [--gimple] [--generic] "
++ "[--header=<filename>] [--include=<filename>] [-v[v]] input "
++ "[<outputfile>...]\n");
++ fprintf (stderr, "\nWhen more then one outputfile is specified --header "
++ "is required.\n");
++}
++
++/* Write out the correct include to the match-head fle containing the helper
++ files. */
++
++static void
++write_header_includes (bool gimple, FILE *header_file)
++{
++ if (gimple)
++ fprintf (header_file, "#include \"gimple-match-head.cc\"\n");
++ else
++ fprintf (header_file, "#include \"generic-match-head.cc\"\n");
++}
++
+ /* The genmatch generator program. It reads from a pattern description
+ and outputs GIMPLE or GENERIC IL matching and simplification routines. */
+
+@@ -5227,25 +5329,44 @@ main (int argc, char **argv)
+ return 1;
+
+ bool gimple = true;
+- char *input = argv[argc-1];
+- for (int i = 1; i < argc - 1; ++i)
++ char *s_header_file = NULL;
++ char *s_include_file = NULL;
++ auto_vec <char *> files;
++ char *input = NULL;
++ int last_file = argc - 1;
++ for (int i = argc - 1; i >= 1; --i)
+ {
+ if (strcmp (argv[i], "--gimple") == 0)
+ gimple = true;
+ else if (strcmp (argv[i], "--generic") == 0)
+ gimple = false;
++ else if (strncmp (argv[i], "--header=", 9) == 0)
++ s_header_file = &argv[i][9];
++ else if (strncmp (argv[i], "--include=", 10) == 0)
++ s_include_file = &argv[i][10];
+ else if (strcmp (argv[i], "-v") == 0)
+ verbose = 1;
+ else if (strcmp (argv[i], "-vv") == 0)
+ verbose = 2;
++ else if (strncmp (argv[i], "--", 2) != 0 && last_file-- == i)
++ files.safe_push (argv[i]);
+ else
+ {
+- fprintf (stderr, "Usage: genmatch "
+- "[--gimple] [--generic] [-v[v]] input\n");
++ showUsage ();
+ return 1;
+ }
+ }
+
++ /* Validate if the combinations are valid. */
++ if ((files.length () > 1 && !s_header_file) || files.is_empty ())
++ showUsage ();
++
++ if (!s_include_file)
++ s_include_file = s_header_file;
++
++ /* Input file is the last in the reverse list. */
++ input = files.pop ();
++
+ line_table = XCNEW (class line_maps);
+ linemap_init (line_table, 0);
+ line_table->reallocator = xrealloc;
+@@ -5292,10 +5413,28 @@ main (int argc, char **argv)
+ /* Parse ahead! */
+ parser p (r, gimple);
+
+- if (gimple)
+- write_header (stdout, "gimple-match-head.cc");
++ /* Create file buffers. */
++ int n_parts = files.is_empty () ? 1 : files.length ();
++ auto_vec <FILE *> parts (n_parts);
++ if (files.is_empty ())
++ {
++ parts.quick_push (stdout);
++ write_header (stdout, s_include_file);
++ write_header_includes (gimple, stdout);
++ }
+ else
+- write_header (stdout, "generic-match-head.cc");
++ {
++ for (char *s_file : files)
++ {
++ parts.quick_push (fopen (s_file, "w"));
++ write_header (parts.last (), s_include_file);
++ }
++
++ header_file = fopen (s_header_file, "w");
++ fprintf (header_file, "#ifndef GCC_GIMPLE_MATCH_AUTO_H\n"
++ "#define GCC_GIMPLE_MATCH_AUTO_H\n");
++ write_header_includes (gimple, header_file);
++ }
+
+ /* Go over all predicates defined with patterns and perform
+ lowering and code generation. */
+@@ -5315,7 +5454,10 @@ main (int argc, char **argv)
+ if (verbose == 2)
+ dt.print (stderr);
+
+- write_predicate (stdout, pred, dt, gimple);
++ /* Cycle the file buffers. */
++ FILE *f = get_out_file (parts);
++
++ write_predicate (f, pred, dt, gimple);
+ }
+
+ /* Lower the main simplifiers and generate code for them. */
+@@ -5332,7 +5474,19 @@ main (int argc, char **argv)
+ if (verbose == 2)
+ dt.print (stderr);
+
+- dt.gen (stdout, gimple);
++ dt.gen (parts, gimple);
++
++ for (FILE *f : parts)
++ {
++ fprintf (f, "#pragma GCC diagnostic pop\n");
++ fclose (f);
++ }
++
++ if (header_file)
++ {
++ fprintf (header_file, "#endif /* GCC_GIMPLE_MATCH_AUTO_H. */\n");
++ fclose (header_file);
++ }
+
+ /* Finalize. */
+ cpp_finish (r, NULL);
+--
+2.44.0
+
diff --git a/13.2.0/gentoo/81_all_match.pd-Use-splits-in-makefile-and-make-configurabl.patch b/13.2.0/gentoo/81_all_match.pd-Use-splits-in-makefile-and-make-configurabl.patch
new file mode 100644
index 0000000..f525f63
--- /dev/null
+++ b/13.2.0/gentoo/81_all_match.pd-Use-splits-in-makefile-and-make-configurabl.patch
@@ -0,0 +1,276 @@
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109927#c21
+
+From dcfebe060ee266f364bb60f1cdf0cec58818c4f7 Mon Sep 17 00:00:00 2001
+From: Tamar Christina <tamar.christina@arm.com>
+Date: Fri, 5 May 2023 13:42:17 +0100
+Subject: [PATCH 06/15] match.pd: Use splits in makefile and make configurable.
+
+This updates the build system to split up match.pd files into chunks of 10.
+This also introduces a new flag --with-matchpd-partitions which can be used to
+change the number of partitions.
+
+For the analysis of why 10 please look at the previous patch in the series.
+
+gcc/ChangeLog:
+
+ PR bootstrap/84402
+ * Makefile.in (NUM_MATCH_SPLITS, MATCH_SPLITS_SEQ,
+ GIMPLE_MATCH_PD_SEQ_SRC, GIMPLE_MATCH_PD_SEQ_O,
+ GENERIC_MATCH_PD_SEQ_SRC, GENERIC_MATCH_PD_SEQ_O): New.
+ (OBJS, MOSTLYCLEANFILES, .PRECIOUS): Use them.
+ (s-match): Split into s-generic-match and s-gimple-match.
+ * configure.ac (with-matchpd-partitions,
+ DEFAULT_MATCHPD_PARTITIONS): New.
+ * configure: Regenerate.
+
+(cherry picked from commit 0a85544e1aaeca41133ecfc438cda913dbc0f122)
+---
+ gcc/Makefile.in | 67 +++++++++++++++++++++++++++++++++---------------
+ gcc/config.in | 6 +++++
+ gcc/configure | 29 +++++++++++++++++++--
+ gcc/configure.ac | 15 +++++++++++
+ 4 files changed, 95 insertions(+), 22 deletions(-)
+
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index 406856acde1c..f0c34d00ecbc 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -214,6 +214,14 @@ rtl-ssa-warn = $(STRICT_WARN)
+ GCC_WARN_CFLAGS = $(LOOSE_WARN) $(C_LOOSE_WARN) $($(@D)-warn) $(if $(filter-out $(STRICT_WARN),$($(@D)-warn)),,$(C_STRICT_WARN)) $(NOCOMMON_FLAG) $($@-warn)
+ GCC_WARN_CXXFLAGS = $(LOOSE_WARN) $($(@D)-warn) $(NOCOMMON_FLAG) $($@-warn)
+
++# The number of splits to be made for the match.pd files.
++NUM_MATCH_SPLITS = @DEFAULT_MATCHPD_PARTITIONS@
++MATCH_SPLITS_SEQ = $(shell seq 1 $(NUM_MATCH_SPLITS))
++GIMPLE_MATCH_PD_SEQ_SRC = $(patsubst %, gimple-match-%.cc, $(MATCH_SPLITS_SEQ))
++GIMPLE_MATCH_PD_SEQ_O = $(patsubst %, gimple-match-%.o, $(MATCH_SPLITS_SEQ))
++GENERIC_MATCH_PD_SEQ_SRC = $(patsubst %, generic-match-%.cc, $(MATCH_SPLITS_SEQ))
++GENERIC_MATCH_PD_SEQ_O = $(patsubst %, generic-match-%.o, $(MATCH_SPLITS_SEQ))
++
+ # These files are to have specific diagnostics suppressed, or are not to
+ # be subject to -Werror:
+ # flex output may yield harmless "no previous prototype" warnings
+@@ -222,9 +230,8 @@ gengtype-lex.o-warn = -Wno-error
+ libgcov-util.o-warn = -Wno-error
+ libgcov-driver-tool.o-warn = -Wno-error
+ libgcov-merge-tool.o-warn = -Wno-error
+-gimple-match.o-warn = -Wno-unused
++gimple-match-head.o-warn = -Wno-unused
+ gimple-match-exports.o-warn = -Wno-unused
+-generic-match.o-warn = -Wno-unused
+ dfp.o-warn = -Wno-strict-aliasing
+
+ # All warnings have to be shut off in stage1 if the compiler used then
+@@ -1308,9 +1315,9 @@ ANALYZER_OBJS = \
+ # will build them sooner, because they are large and otherwise tend to be
+ # the last objects to finish building.
+ OBJS = \
+- gimple-match.o \
++ $(GIMPLE_MATCH_PD_SEQ_O) \
+ gimple-match-exports.o \
+- generic-match.o \
++ $(GENERIC_MATCH_PD_SEQ_O) \
+ insn-attrtab.o \
+ insn-automata.o \
+ insn-dfatab.o \
+@@ -1803,7 +1810,8 @@ MOSTLYCLEANFILES = insn-flags.h insn-config.h insn-codes.h \
+ insn-output.cc insn-recog.cc insn-emit.cc insn-extract.cc insn-peep.cc \
+ insn-attr.h insn-attr-common.h insn-attrtab.cc insn-dfatab.cc \
+ insn-latencytab.cc insn-opinit.cc insn-opinit.h insn-preds.cc insn-constants.h \
+- tm-preds.h tm-constrs.h checksum-options gimple-match.cc generic-match.cc \
++ tm-preds.h tm-constrs.h checksum-options $(GIMPLE_MATCH_PD_SEQ_SRC) \
++ $(GENERIC_MATCH_PD_SEQ_SRC) gimple-match-auto.h generic-match-auto.h \
+ tree-check.h min-insn-modes.cc insn-modes.cc insn-modes.h insn-modes-inline.h \
+ genrtl.h gt-*.h gtype-*.h gtype-desc.cc gtyp-input.list \
+ case-cfn-macros.h cfn-operators.pd \
+@@ -2418,7 +2426,8 @@ $(common_out_object_file): $(common_out_file)
+ .PRECIOUS: insn-config.h insn-flags.h insn-codes.h insn-constants.h \
+ insn-emit.cc insn-recog.cc insn-extract.cc insn-output.cc insn-peep.cc \
+ insn-attr.h insn-attr-common.h insn-attrtab.cc insn-dfatab.cc \
+- insn-latencytab.cc insn-preds.cc gimple-match.cc generic-match.cc \
++ insn-latencytab.cc insn-preds.cc $(GIMPLE_MATCH_PD_SEQ_SRC) \
++ $(GENERIC_MATCH_PD_SEQ_SRC) gimple-match-auto.h generic-match-auto.h \
+ insn-target-def.h
+
+ # Dependencies for the md file. The first time through, we just assume
+@@ -2661,19 +2670,36 @@ s-tm-texi: build/genhooks$(build_exeext) $(srcdir)/doc/tm.texi.in
+ false; \
+ fi
+
+-gimple-match.cc: s-match gimple-match-head.cc gimple-match-exports.cc ; @true
+-generic-match.cc: s-match generic-match-head.cc ; @true
+-
+-s-match: build/genmatch$(build_exeext) $(srcdir)/match.pd cfn-operators.pd
+- $(RUN_GEN) build/genmatch$(build_exeext) --gimple $(srcdir)/match.pd \
+- > tmp-gimple-match.cc
+- $(RUN_GEN) build/genmatch$(build_exeext) --generic $(srcdir)/match.pd \
+- > tmp-generic-match.cc
+- $(SHELL) $(srcdir)/../move-if-change tmp-gimple-match.cc \
+- gimple-match.cc
+- $(SHELL) $(srcdir)/../move-if-change tmp-generic-match.cc \
+- generic-match.cc
+- $(STAMP) s-match
++$(GIMPLE_MATCH_PD_SEQ_SRC): s-gimple-match gimple-match-head.cc \
++ gimple-match-exports.cc; @true
++gimple-match-auto.h: s-gimple-match gimple-match-head.cc \
++ gimple-match-exports.cc; @true
++$(GENERIC_MATCH_PD_SEQ_SRC): s-generic-match generic-match-head.cc; @true
++generic-match-auto.h: s-generic-match generic-match-head.cc; @true
++
++s-gimple-match: build/genmatch$(build_exeext) \
++ $(srcdir)/match.pd cfn-operators.pd
++ $(RUN_GEN) build/genmatch$(build_exeext) --gimple \
++ --header=tmp-gimple-match-auto.h --include=gimple-match-auto.h \
++ $(srcdir)/match.pd $(patsubst %, tmp-%, $(GIMPLE_MATCH_PD_SEQ_SRC))
++ $(foreach id, $(MATCH_SPLITS_SEQ), \
++ $(SHELL) $(srcdir)/../move-if-change tmp-gimple-match-$(id).cc \
++ gimple-match-$(id).cc;)
++ $(SHELL) $(srcdir)/../move-if-change tmp-gimple-match-auto.h \
++ gimple-match-auto.h
++ $(STAMP) s-gimple-match
++
++s-generic-match: build/genmatch$(build_exeext) \
++ $(srcdir)/match.pd cfn-operators.pd
++ $(RUN_GEN) build/genmatch$(build_exeext) --generic \
++ --header=tmp-generic-match-auto.h --include=generic-match-auto.h \
++ $(srcdir)/match.pd $(patsubst %, tmp-%, $(GENERIC_MATCH_PD_SEQ_SRC))
++ $(foreach id, $(MATCH_SPLITS_SEQ), \
++ $(SHELL) $(srcdir)/../move-if-change tmp-generic-match-$(id).cc \
++ generic-match-$(id).cc;)
++ $(SHELL) $(srcdir)/../move-if-change tmp-generic-match-auto.h \
++ generic-match-auto.h
++ $(STAMP) s-generic-match
+
+ GTFILES = $(CPPLIB_H) $(srcdir)/input.h $(srcdir)/coretypes.h \
+ $(host_xm_file_list) \
+@@ -2808,7 +2834,8 @@ generated_files = config.h tm.h $(TM_P_H) $(TM_D_H) $(TM_H) multilib.h \
+ $(ALL_GTFILES_H) gtype-desc.cc gtype-desc.h version.h \
+ options.h target-hooks-def.h insn-opinit.h \
+ common/common-target-hooks-def.h pass-instances.def \
+- gimple-match.cc generic-match.cc \
++ $(GIMPLE_MATCH_PD_SEQ_SRC) $(GENERIC_MATCH_PD_SEQ_SRC) \
++ gimple-match-auto.h generic-match-auto.h \
+ c-family/c-target-hooks-def.h d/d-target-hooks-def.h \
+ case-cfn-macros.h \
+ cfn-operators.pd omp-device-properties.h
+diff --git a/gcc/config.in b/gcc/config.in
+index 5281a12a707c..ea60c5b11fc5 100644
+--- a/gcc/config.in
++++ b/gcc/config.in
+@@ -67,6 +67,12 @@
+ #endif
+
+
++/* Define to larger than one set the number of match.pd partitions to make. */
++#ifndef USED_FOR_TARGET
++#undef DEFAULT_MATCHPD_PARTITIONS
++#endif
++
++
+ /* Define to larger than zero set the default stack clash protector size. */
+ #ifndef USED_FOR_TARGET
+ #undef DEFAULT_STK_CLASH_GUARD_SIZE
+diff --git a/gcc/configure b/gcc/configure
+index ade0af23e8cc..542d100c2b73 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -838,6 +838,7 @@ enable_gcov
+ enable_shared
+ enable_fixed_point
+ enable_decimal_float
++DEFAULT_MATCHPD_PARTITIONS
+ with_float
+ with_cpu
+ enable_multiarch
+@@ -965,6 +966,7 @@ enable_valgrind_annotations
+ enable_multilib
+ enable_multiarch
+ with_stack_clash_protection_guard_size
++with_matchpd_partitions
+ enable___cxa_atexit
+ enable_decimal_float
+ enable_fixed_point
+@@ -1832,6 +1834,9 @@ Optional Packages:
+ --with-stack-clash-protection-guard-size=size
+ Set the default stack clash protection guard size
+ for specific targets as a power of two in bytes.
++ --with-matchpd-partitions=num
++ Set the number of partitions to make for gimple and
++ generic when splitting match.pd. [default=10]
+ --with-dwarf2 force the default debug format to be DWARF 2 (or
+ later)
+ --with-specs=SPECS add SPECS to driver command-line processing
+@@ -7918,6 +7923,26 @@ cat >>confdefs.h <<_ACEOF
+ _ACEOF
+
+
++# Specify the number of splits of match.pd to generate.
++
++# Check whether --with-matchpd-partitions was given.
++if test "${with_matchpd_partitions+set}" = set; then :
++ withval=$with_matchpd_partitions; DEFAULT_MATCHPD_PARTITIONS="$with_matchpd_partitions"
++else
++ DEFAULT_MATCHPD_PARTITIONS=10
++fi
++
++if (test $DEFAULT_MATCHPD_PARTITIONS -lt 1); then
++ as_fn_error $? "Invalid value $DEFAULT_MATCHPD_PARTITIONS for --with-matchpd-partitions. Cannot be negative." "$LINENO" 5
++fi
++
++
++cat >>confdefs.h <<_ACEOF
++#define DEFAULT_MATCHPD_PARTITIONS $DEFAULT_MATCHPD_PARTITIONS
++_ACEOF
++
++
++
+ # Enable __cxa_atexit for C++.
+ # Check whether --enable-__cxa_atexit was given.
+ if test "${enable___cxa_atexit+set}" = set; then :
+@@ -19871,7 +19896,7 @@ else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+-#line 19874 "configure"
++#line 19899 "configure"
+ #include "confdefs.h"
+
+ #if HAVE_DLFCN_H
+@@ -19977,7 +20002,7 @@ else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+-#line 19980 "configure"
++#line 20005 "configure"
+ #include "confdefs.h"
+
+ #if HAVE_DLFCN_H
+diff --git a/gcc/configure.ac b/gcc/configure.ac
+index bf8ff4d63906..31aa8566a3e7 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -943,6 +943,21 @@ fi
+ AC_DEFINE_UNQUOTED(DEFAULT_STK_CLASH_GUARD_SIZE, $DEFAULT_STK_CLASH_GUARD_SIZE,
+ [Define to larger than zero set the default stack clash protector size.])
+
++# Specify the number of splits of match.pd to generate.
++AC_ARG_WITH(matchpd-partitions,
++[AS_HELP_STRING([--with-matchpd-partitions=num],
++[Set the number of partitions to make for gimple and generic when splitting match.pd. [default=10]])],
++[DEFAULT_MATCHPD_PARTITIONS="$with_matchpd_partitions"], [DEFAULT_MATCHPD_PARTITIONS=10])
++if (test $DEFAULT_MATCHPD_PARTITIONS -lt 1); then
++ AC_MSG_ERROR(m4_normalize([
++ Invalid value $DEFAULT_MATCHPD_PARTITIONS for --with-matchpd-partitions. \
++ Cannot be negative.]))
++fi
++
++AC_DEFINE_UNQUOTED(DEFAULT_MATCHPD_PARTITIONS, $DEFAULT_MATCHPD_PARTITIONS,
++ [Define to larger than one set the number of match.pd partitions to make.])
++AC_SUBST(DEFAULT_MATCHPD_PARTITIONS)
++
+ # Enable __cxa_atexit for C++.
+ AC_ARG_ENABLE(__cxa_atexit,
+ [AS_HELP_STRING([--enable-__cxa_atexit], [enable __cxa_atexit for C++])],
+--
+2.44.0
+
diff --git a/13.2.0/gentoo/82_all_Makefile.in-clean-up-match.pd-related-dependencies.patch b/13.2.0/gentoo/82_all_Makefile.in-clean-up-match.pd-related-dependencies.patch
new file mode 100644
index 0000000..2512660
--- /dev/null
+++ b/13.2.0/gentoo/82_all_Makefile.in-clean-up-match.pd-related-dependencies.patch
@@ -0,0 +1,60 @@
+From 2c1f550db00c7dd9abede5644a3acd915767e0ad Mon Sep 17 00:00:00 2001
+From: Alexander Monakov <amonakov@ispras.ru>
+Date: Fri, 5 May 2023 19:46:25 +0300
+Subject: [PATCH 07/15] Makefile.in: clean up match.pd-related dependencies
+
+Clean up confusing changes from the recent refactoring for
+parallel match.pd build.
+
+gimple-match-head.o is not built. Remove related flags adjustment.
+
+Autogenerated gimple-match-N.o files do not depend on
+gimple-match-exports.cc.
+
+{gimple,generic)-match-auto.h only depend on the prerequisites of the
+corresponding s-{gimple,generic}-match stamp file, not any .cc file.
+
+gcc/ChangeLog:
+
+ * Makefile.in: (gimple-match-head.o-warn): Remove.
+ (GIMPLE_MATCH_PD_SEQ_SRC): Do not depend on
+ gimple-match-exports.cc.
+ (gimple-match-auto.h): Only depend on s-gimple-match.
+ (generic-match-auto.h): Likewise.
+
+(cherry picked from commit 31c70a7daa368767f0f58e0389deb2c69d9e14fd)
+---
+ gcc/Makefile.in | 9 +++------
+ 1 file changed, 3 insertions(+), 6 deletions(-)
+
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index f0c34d00ecbc..fe3af5c8008c 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -230,7 +230,6 @@ gengtype-lex.o-warn = -Wno-error
+ libgcov-util.o-warn = -Wno-error
+ libgcov-driver-tool.o-warn = -Wno-error
+ libgcov-merge-tool.o-warn = -Wno-error
+-gimple-match-head.o-warn = -Wno-unused
+ gimple-match-exports.o-warn = -Wno-unused
+ dfp.o-warn = -Wno-strict-aliasing
+
+@@ -2670,12 +2669,10 @@ s-tm-texi: build/genhooks$(build_exeext) $(srcdir)/doc/tm.texi.in
+ false; \
+ fi
+
+-$(GIMPLE_MATCH_PD_SEQ_SRC): s-gimple-match gimple-match-head.cc \
+- gimple-match-exports.cc; @true
+-gimple-match-auto.h: s-gimple-match gimple-match-head.cc \
+- gimple-match-exports.cc; @true
++$(GIMPLE_MATCH_PD_SEQ_SRC): s-gimple-match gimple-match-head.cc; @true
++gimple-match-auto.h: s-gimple-match; @true
+ $(GENERIC_MATCH_PD_SEQ_SRC): s-generic-match generic-match-head.cc; @true
+-generic-match-auto.h: s-generic-match generic-match-head.cc; @true
++generic-match-auto.h: s-generic-match; @true
+
+ s-gimple-match: build/genmatch$(build_exeext) \
+ $(srcdir)/match.pd cfn-operators.pd
+--
+2.44.0
+
diff --git a/13.2.0/gentoo/84_all_x86_PR110792-Early-clobber-issues-with-rot32di2.patch b/13.2.0/gentoo/84_all_x86_PR110792-Early-clobber-issues-with-rot32di2.patch
new file mode 100644
index 0000000..e3c09cc
--- /dev/null
+++ b/13.2.0/gentoo/84_all_x86_PR110792-Early-clobber-issues-with-rot32di2.patch
@@ -0,0 +1,186 @@
+https://gcc.gnu.org/PR110792
+https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=790c1f60a5662b16eb19eb4b81922995863c7571
+https://github.com/randombit/botan/issues/3637
+
+From 85628c5653ff40963158a24c60eeec6a3b5a8e56 Mon Sep 17 00:00:00 2001
+From: Roger Sayle <roger@nextmovesoftware.com>
+Date: Thu, 3 Aug 2023 07:12:04 +0100
+Subject: [PATCH] PR target/110792: Early clobber issues with
+ rot32di2_doubleword on i386.
+
+This patch is a conservative fix for PR target/110792, a wrong-code
+regression affecting doubleword rotations by BITS_PER_WORD, which
+effectively swaps the highpart and lowpart words, when the source to be
+rotated resides in memory. The issue is that if the register used to
+hold the lowpart of the destination is mentioned in the address of
+the memory operand, the current define_insn_and_split unintentionally
+clobbers it before reading the highpart.
+
+Hence, for the testcase, the incorrectly generated code looks like:
+
+ salq $4, %rdi // calculate address
+ movq WHIRL_S+8(%rdi), %rdi // accidentally clobber addr
+ movq WHIRL_S(%rdi), %rbp // load (wrong) lowpart
+
+Traditionally, the textbook way to fix this would be to add an
+explicit early clobber to the instruction's constraints.
+
+ (define_insn_and_split "<insn>32di2_doubleword"
+- [(set (match_operand:DI 0 "register_operand" "=r,r,r")
++ [(set (match_operand:DI 0 "register_operand" "=r,r,&r")
+ (any_rotate:DI (match_operand:DI 1 "nonimmediate_operand" "0,r,o")
+ (const_int 32)))]
+
+but unfortunately this currently generates significantly worse code,
+due to a strange choice of reloads (effectively memcpy), which ends up
+looking like:
+
+ salq $4, %rdi // calculate address
+ movdqa WHIRL_S(%rdi), %xmm0 // load the double word in SSE reg.
+ movaps %xmm0, -16(%rsp) // store the SSE reg back to the stack
+ movq -8(%rsp), %rdi // load highpart
+ movq -16(%rsp), %rbp // load lowpart
+
+Note that reload's "&" doesn't distinguish between the memory being
+early clobbered, vs the registers used in an addressing mode being
+early clobbered.
+
+The fix proposed in this patch is to remove the third alternative, that
+allowed offsetable memory as an operand, forcing reload to place the
+operand into a register before the rotation. This results in:
+
+ salq $4, %rdi
+ movq WHIRL_S(%rdi), %rax
+ movq WHIRL_S+8(%rdi), %rdi
+ movq %rax, %rbp
+
+I believe there's a more advanced solution, by swapping the order of
+the loads (if first destination register is mentioned in the address),
+or inserting a lea insn (if both destination registers are mentioned
+in the address), but this fix is a minimal "safe" solution, that
+should hopefully be suitable for backporting.
+
+2023-08-03 Roger Sayle <roger@nextmovesoftware.com>
+
+gcc/ChangeLog
+ PR target/110792
+ * config/i386/i386.md (<any_rotate>ti3): For rotations by 64 bits
+ place operand in a register before gen_<insn>64ti2_doubleword.
+ (<any_rotate>di3): Likewise, for rotations by 32 bits, place
+ operand in a register before gen_<insn>32di2_doubleword.
+ (<any_rotate>32di2_doubleword): Constrain operand to be in register.
+ (<any_rotate>64ti2_doubleword): Likewise.
+
+gcc/testsuite/ChangeLog
+ PR target/110792
+ * g++.target/i386/pr110792.C: New 32-bit C++ test case.
+ * gcc.target/i386/pr110792.c: New 64-bit C test case.
+
+(cherry picked from commit 790c1f60a5662b16eb19eb4b81922995863c7571)
+---
+ gcc/config/i386/i386.md | 18 ++++++++++++------
+ gcc/testsuite/g++.target/i386/pr110792.C | 16 ++++++++++++++++
+ gcc/testsuite/gcc.target/i386/pr110792.c | 18 ++++++++++++++++++
+ 3 files changed, 46 insertions(+), 6 deletions(-)
+ create mode 100644 gcc/testsuite/g++.target/i386/pr110792.C
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr110792.c
+
+diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
+index f3a3305..a71e837 100644
+--- a/gcc/config/i386/i386.md
++++ b/gcc/config/i386/i386.md
+@@ -14359,7 +14359,10 @@
+ emit_insn (gen_ix86_<insn>ti3_doubleword
+ (operands[0], operands[1], operands[2]));
+ else if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 64)
+- emit_insn (gen_<insn>64ti2_doubleword (operands[0], operands[1]));
++ {
++ operands[1] = force_reg (TImode, operands[1]);
++ emit_insn (gen_<insn>64ti2_doubleword (operands[0], operands[1]));
++ }
+ else
+ {
+ rtx amount = force_reg (QImode, operands[2]);
+@@ -14394,7 +14397,10 @@
+ emit_insn (gen_ix86_<insn>di3_doubleword
+ (operands[0], operands[1], operands[2]));
+ else if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 32)
+- emit_insn (gen_<insn>32di2_doubleword (operands[0], operands[1]));
++ {
++ operands[1] = force_reg (DImode, operands[1]);
++ emit_insn (gen_<insn>32di2_doubleword (operands[0], operands[1]));
++ }
+ else
+ FAIL;
+
+@@ -14562,8 +14568,8 @@
+ })
+
+ (define_insn_and_split "<insn>32di2_doubleword"
+- [(set (match_operand:DI 0 "register_operand" "=r,r,r")
+- (any_rotate:DI (match_operand:DI 1 "nonimmediate_operand" "0,r,o")
++ [(set (match_operand:DI 0 "register_operand" "=r,r")
++ (any_rotate:DI (match_operand:DI 1 "register_operand" "0,r")
+ (const_int 32)))]
+ "!TARGET_64BIT"
+ "#"
+@@ -14580,8 +14586,8 @@
+ })
+
+ (define_insn_and_split "<insn>64ti2_doubleword"
+- [(set (match_operand:TI 0 "register_operand" "=r,r,r")
+- (any_rotate:TI (match_operand:TI 1 "nonimmediate_operand" "0,r,o")
++ [(set (match_operand:TI 0 "register_operand" "=r,r")
++ (any_rotate:TI (match_operand:TI 1 "register_operand" "0,r")
+ (const_int 64)))]
+ "TARGET_64BIT"
+ "#"
+diff --git a/gcc/testsuite/g++.target/i386/pr110792.C b/gcc/testsuite/g++.target/i386/pr110792.C
+new file mode 100644
+index 0000000..ce21a7a
+--- /dev/null
++++ b/gcc/testsuite/g++.target/i386/pr110792.C
+@@ -0,0 +1,16 @@
++/* { dg-do compile { target ia32 } } */
++/* { dg-options "-O2" } */
++
++template <int ROT, typename T>
++inline T rotr(T input)
++{
++ return static_cast<T>((input >> ROT) | (input << (8 * sizeof(T) - ROT)));
++}
++
++unsigned long long WHIRL_S[256] = {0x18186018C07830D8};
++unsigned long long whirl(unsigned char x0)
++{
++ const unsigned long long s4 = WHIRL_S[x0&0xFF];
++ return rotr<32>(s4);
++}
++/* { dg-final { scan-assembler-not "movl\tWHIRL_S\\+4\\(,%eax,8\\), %eax" } } */
+diff --git a/gcc/testsuite/gcc.target/i386/pr110792.c b/gcc/testsuite/gcc.target/i386/pr110792.c
+new file mode 100644
+index 0000000..b65125c
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr110792.c
+@@ -0,0 +1,18 @@
++/* { dg-do compile { target int128 } } */
++/* { dg-options "-O2" } */
++
++static inline unsigned __int128 rotr(unsigned __int128 input)
++{
++ return ((input >> 64) | (input << (64)));
++}
++
++unsigned __int128 WHIRL_S[256] = {((__int128)0x18186018C07830D8) << 64 |0x18186018C07830D8};
++unsigned __int128 whirl(unsigned char x0)
++{
++ register int t __asm("rdi") = x0&0xFF;
++ const unsigned __int128 s4 = WHIRL_S[t];
++ register unsigned __int128 tt __asm("rdi") = rotr(s4);
++ asm("":::"memory");
++ return tt;
++}
++/* { dg-final { scan-assembler-not "movq\tWHIRL_S\\+8\\(%rdi\\), %rdi" } } */
+--
+2.41.0
+
diff --git a/13.2.0/gentoo/85_all_x86_PR110792-Early-clobber-issues-with-rot32di2-test-fixup.patch b/13.2.0/gentoo/85_all_x86_PR110792-Early-clobber-issues-with-rot32di2-test-fixup.patch
new file mode 100644
index 0000000..059f68c
--- /dev/null
+++ b/13.2.0/gentoo/85_all_x86_PR110792-Early-clobber-issues-with-rot32di2-test-fixup.patch
@@ -0,0 +1,39 @@
+From 529909f9e92dd3b0ed0383f45a44d2b5f8a58958 Mon Sep 17 00:00:00 2001
+From: Roger Sayle <roger@nextmovesoftware.com>
+Date: Sun, 6 Aug 2023 23:19:10 +0100
+Subject: [PATCH] [Committed] Avoid FAIL of gcc.target/i386/pr110792.c
+
+My apologies (again), I managed to mess up the 64-bit version of the
+test case for PR 110792. Unlike the 32-bit version, the 64-bit case
+contains exactly the same load instructions, just in a different order
+making the correct and incorrect behaviours impossible to distinguish
+with a scan-assembler-not. Somewhere between checking that this test
+failed in a clean tree without the patch, and getting the escaping
+correct, I'd failed to notice that this also FAILs in the patched tree.
+Doh! Instead of removing the test completely, I've left it as a
+compilation test.
+
+The original fix is tested by the 32-bit test case.
+
+Committed to mainline as obvious. Sorry for the incovenience.
+
+2023-08-06 Roger Sayle <roger@nextmovesoftware.com>
+
+gcc/testsuite/ChangeLog
+ PR target/110792
+ * gcc.target/i386/pr110792.c: Remove dg-final scan-assembler-not.
+---
+ gcc/testsuite/gcc.target/i386/pr110792.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/gcc/testsuite/gcc.target/i386/pr110792.c b/gcc/testsuite/gcc.target/i386/pr110792.c
+index b65125c48b62..eea4e1877dbb 100644
+--- a/gcc/testsuite/gcc.target/i386/pr110792.c
++++ b/gcc/testsuite/gcc.target/i386/pr110792.c
+@@ -15,4 +15,3 @@ unsigned __int128 whirl(unsigned char x0)
+ asm("":::"memory");
+ return tt;
+ }
+-/* { dg-final { scan-assembler-not "movq\tWHIRL_S\\+8\\(%rdi\\), %rdi" } } */
+--
+2.39.3
diff --git a/13.2.0/gentoo/86_all_build-Replace-seq-for-portability-with-GNU-Make-vari.patch b/13.2.0/gentoo/86_all_build-Replace-seq-for-portability-with-GNU-Make-vari.patch
new file mode 100644
index 0000000..892adbc
--- /dev/null
+++ b/13.2.0/gentoo/86_all_build-Replace-seq-for-portability-with-GNU-Make-vari.patch
@@ -0,0 +1,73 @@
+https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=319aef8d2fde32be5cfed99f321c7f90e33d1f1d
+
+From a18a994030d16f58ebced231e778ec4e06a98abb Mon Sep 17 00:00:00 2001
+From: Jakub Jelinek <jakub@redhat.com>
+Date: Sat, 6 May 2023 02:32:17 +0200
+Subject: [PATCH 08/15] build: Replace seq for portability with GNU Make
+ variant
+
+Some hosts like AIX don't have seq command, this patch replaces it
+with something that uses just GNU make features we've been using
+for this already before for the parallel make check.
+
+2023-05-06 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile.in (check_p_numbers): Rename to one_to_9999, move
+ earlier with helper variables also renamed.
+ (MATCH_SPLUT_SEQ): Use $(wordlist 1,$(NUM_MATCH_SPLITS),$(one_to_9999))
+ instead of $(shell seq 1 $(NUM_MATCH_SPLITS)).
+ (check_p_subdirs): Use $(one_to_9999) instead of $(check_p_numbers).
+
+(cherry picked from commit 319aef8d2fde32be5cfed99f321c7f90e33d1f1d)
+---
+ gcc/Makefile.in | 22 ++++++++++++----------
+ 1 file changed, 12 insertions(+), 10 deletions(-)
+
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index fe3af5c8008c..975fbb61ea8a 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -214,9 +214,19 @@ rtl-ssa-warn = $(STRICT_WARN)
+ GCC_WARN_CFLAGS = $(LOOSE_WARN) $(C_LOOSE_WARN) $($(@D)-warn) $(if $(filter-out $(STRICT_WARN),$($(@D)-warn)),,$(C_STRICT_WARN)) $(NOCOMMON_FLAG) $($@-warn)
+ GCC_WARN_CXXFLAGS = $(LOOSE_WARN) $($(@D)-warn) $(NOCOMMON_FLAG) $($@-warn)
+
++# 1 2 3 ... 9999
++one_to_9999_0:=1 2 3 4 5 6 7 8 9
++one_to_9999_1:=0 $(one_to_9999_0)
++one_to_9999_2:=$(foreach i,$(one_to_9999_0),$(addprefix $(i),$(one_to_9999_1)))
++one_to_9999_3:=$(addprefix 0,$(one_to_9999_1)) $(one_to_9999_2)
++one_to_9999_4:=$(foreach i,$(one_to_9999_0),$(addprefix $(i),$(one_to_9999_3)))
++one_to_9999_5:=$(addprefix 0,$(one_to_9999_3)) $(one_to_9999_4)
++one_to_9999_6:=$(foreach i,$(one_to_9999_0),$(addprefix $(i),$(one_to_9999_5)))
++one_to_9999:=$(one_to_9999_0) $(one_to_9999_2) $(one_to_9999_4) $(one_to_9999_6)
++
+ # The number of splits to be made for the match.pd files.
+ NUM_MATCH_SPLITS = @DEFAULT_MATCHPD_PARTITIONS@
+-MATCH_SPLITS_SEQ = $(shell seq 1 $(NUM_MATCH_SPLITS))
++MATCH_SPLITS_SEQ = $(wordlist 1,$(NUM_MATCH_SPLITS),$(one_to_9999))
+ GIMPLE_MATCH_PD_SEQ_SRC = $(patsubst %, gimple-match-%.cc, $(MATCH_SPLITS_SEQ))
+ GIMPLE_MATCH_PD_SEQ_O = $(patsubst %, gimple-match-%.o, $(MATCH_SPLITS_SEQ))
+ GENERIC_MATCH_PD_SEQ_SRC = $(patsubst %, generic-match-%.cc, $(MATCH_SPLITS_SEQ))
+@@ -4220,18 +4230,10 @@ $(patsubst %,%-subtargets,$(lang_checks)): check-%-subtargets:
+ check_p_tool=$(firstword $(subst _, ,$*))
+ check_p_count=$(check_$(check_p_tool)_parallelize)
+ check_p_subno=$(word 2,$(subst _, ,$*))
+-check_p_numbers0:=1 2 3 4 5 6 7 8 9
+-check_p_numbers1:=0 $(check_p_numbers0)
+-check_p_numbers2:=$(foreach i,$(check_p_numbers0),$(addprefix $(i),$(check_p_numbers1)))
+-check_p_numbers3:=$(addprefix 0,$(check_p_numbers1)) $(check_p_numbers2)
+-check_p_numbers4:=$(foreach i,$(check_p_numbers0),$(addprefix $(i),$(check_p_numbers3)))
+-check_p_numbers5:=$(addprefix 0,$(check_p_numbers3)) $(check_p_numbers4)
+-check_p_numbers6:=$(foreach i,$(check_p_numbers0),$(addprefix $(i),$(check_p_numbers5)))
+-check_p_numbers:=$(check_p_numbers0) $(check_p_numbers2) $(check_p_numbers4) $(check_p_numbers6)
+ check_p_subdir=$(subst _,,$*)
+ check_p_subdirs=$(wordlist 1,$(check_p_count),$(wordlist 1, \
+ $(if $(GCC_TEST_PARALLEL_SLOTS),$(GCC_TEST_PARALLEL_SLOTS),128), \
+- $(check_p_numbers)))
++ $(one_to_9999)))
+
+ # For parallelized check-% targets, this decides whether parallelization
+ # is desirable (if -jN is used). If desirable, recursive make is run with
+--
+2.44.0
+
diff --git a/13.2.0/gentoo/87_all_Remove-DEFAULT_MATCHPD_PARTITIONS-macro.patch b/13.2.0/gentoo/87_all_Remove-DEFAULT_MATCHPD_PARTITIONS-macro.patch
new file mode 100644
index 0000000..1f47154
--- /dev/null
+++ b/13.2.0/gentoo/87_all_Remove-DEFAULT_MATCHPD_PARTITIONS-macro.patch
@@ -0,0 +1,90 @@
+https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=bc45e18d433f879a02e369d027829f90f9e85724
+
+From b60091fe7d22e0cac71461dceeb804e37555b5d3 Mon Sep 17 00:00:00 2001
+From: Tamar Christina <tamar.christina@arm.com>
+Date: Mon, 12 Jun 2023 14:06:08 +0100
+Subject: [PATCH 09/15] Remove DEFAULT_MATCHPD_PARTITIONS macro
+
+As Jakub pointed out, DEFAULT_MATCHPD_PARTITIONS
+is now unused and can be removed.
+
+gcc/ChangeLog:
+
+ * config.in: Regenerate.
+ * configure: Regenerate.
+ * configure.ac: Remove DEFAULT_MATCHPD_PARTITIONS.
+
+(cherry picked from commit bc45e18d433f879a02e369d027829f90f9e85724)
+---
+ gcc/config.in | 6 ------
+ gcc/configure | 9 ++-------
+ gcc/configure.ac | 2 --
+ 3 files changed, 2 insertions(+), 15 deletions(-)
+
+diff --git a/gcc/config.in b/gcc/config.in
+index ea60c5b11fc5..5281a12a707c 100644
+--- a/gcc/config.in
++++ b/gcc/config.in
+@@ -67,12 +67,6 @@
+ #endif
+
+
+-/* Define to larger than one set the number of match.pd partitions to make. */
+-#ifndef USED_FOR_TARGET
+-#undef DEFAULT_MATCHPD_PARTITIONS
+-#endif
+-
+-
+ /* Define to larger than zero set the default stack clash protector size. */
+ #ifndef USED_FOR_TARGET
+ #undef DEFAULT_STK_CLASH_GUARD_SIZE
+diff --git a/gcc/configure b/gcc/configure
+index 542d100c2b73..cc8247037569 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -7937,11 +7937,6 @@ if (test $DEFAULT_MATCHPD_PARTITIONS -lt 1); then
+ fi
+
+
+-cat >>confdefs.h <<_ACEOF
+-#define DEFAULT_MATCHPD_PARTITIONS $DEFAULT_MATCHPD_PARTITIONS
+-_ACEOF
+-
+-
+
+ # Enable __cxa_atexit for C++.
+ # Check whether --enable-__cxa_atexit was given.
+@@ -19896,7 +19891,7 @@ else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+-#line 19899 "configure"
++#line 19894 "configure"
+ #include "confdefs.h"
+
+ #if HAVE_DLFCN_H
+@@ -20002,7 +19997,7 @@ else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+-#line 20005 "configure"
++#line 20000 "configure"
+ #include "confdefs.h"
+
+ #if HAVE_DLFCN_H
+diff --git a/gcc/configure.ac b/gcc/configure.ac
+index 31aa8566a3e7..d02ffc22a3a3 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -954,8 +954,6 @@ if (test $DEFAULT_MATCHPD_PARTITIONS -lt 1); then
+ Cannot be negative.]))
+ fi
+
+-AC_DEFINE_UNQUOTED(DEFAULT_MATCHPD_PARTITIONS, $DEFAULT_MATCHPD_PARTITIONS,
+- [Define to larger than one set the number of match.pd partitions to make.])
+ AC_SUBST(DEFAULT_MATCHPD_PARTITIONS)
+
+ # Enable __cxa_atexit for C++.
+--
+2.44.0
+
diff --git a/13.2.0/gentoo/88_all_Makefile.in-Make-TM_P_H-depend-on-TREE_H-PR111021.patch b/13.2.0/gentoo/88_all_Makefile.in-Make-TM_P_H-depend-on-TREE_H-PR111021.patch
new file mode 100644
index 0000000..0a92592
--- /dev/null
+++ b/13.2.0/gentoo/88_all_Makefile.in-Make-TM_P_H-depend-on-TREE_H-PR111021.patch
@@ -0,0 +1,66 @@
+https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=8353b9c5f5af0e65cb04fcbb7325d6a566006cd4
+
+From 87192b63d3ab56543461cb456c4f8b2f1085fd6c Mon Sep 17 00:00:00 2001
+From: Kewen Lin <linkw@linux.ibm.com>
+Date: Fri, 18 Aug 2023 05:03:40 -0500
+Subject: [PATCH 11/15] Makefile.in: Make TM_P_H depend on $(TREE_H) [PR111021]
+
+As PR111021 shows, the below ${port}-protos.h include tree.h
+for code_helper and tree_code:
+
+ arm/arm-protos.h:#include "tree.h"
+ cris/cris-protos.h:#include "tree.h" (H-P removed this in r14-3218)
+ microblaze/microblaze-protos.h:#include "tree.h"
+ rl78/rl78-protos.h:#include "tree.h"
+ stormy16/stormy16-protos.h:#include "tree.h"
+
+, when compiling build/gencondmd.cc, the include hierarchy
+makes it depend on tm_p.h -> ${port}-protos.h -> tree.h,
+which further includes (depends on) some files that are
+generated during the building, such as: all-tree.def,
+tree-check.h and so on. The previous commit r14-3215
+should already force build/gencondmd.cc to depend on
+${TREE_H}, so the reported build failure should be gone.
+
+But for a long term maintenance, especially one day some
+build/xxx.cc requires tm_p.h but not recog.h, the ${TREE_H}
+dependence could be missed and a build failure will show
+up. So this patch is to make TM_P_H depend on $(TREE_H),
+any new build/xxx.cc depending on tm_p.h will be able to
+consider ${TREE_H}.
+
+It's tested with cross-builds for the affected ports with
+steps:
+ 1) dropped the fix r14-3215;
+ 2) reproduced the build failure with serial build;
+ 3) applied this patch, serial built and verified all passed;
+ 4) added back r14-3215, serial built and verified all passed;
+
+ PR bootstrap/111021
+
+gcc/ChangeLog:
+
+ * Makefile.in (TM_P_H): Add $(TREE_H) as dependence.
+
+(cherry picked from commit 8353b9c5f5af0e65cb04fcbb7325d6a566006cd4)
+---
+ gcc/Makefile.in | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index 975fbb61ea8a..115d2a6d9b76 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -886,7 +886,8 @@ OPTIONS_C_EXTRA = $(PRETTY_PRINT_H)
+ BCONFIG_H = bconfig.h $(build_xm_file_list)
+ CONFIG_H = config.h $(host_xm_file_list)
+ TCONFIG_H = tconfig.h $(xm_file_list)
+-TM_P_H = tm_p.h $(tm_p_file_list)
++# Some $(target)-protos.h depends on tree.h
++TM_P_H = tm_p.h $(tm_p_file_list) $(TREE_H)
+ TM_D_H = tm_d.h $(tm_d_file_list)
+ GTM_H = tm.h $(tm_file_list) insn-constants.h
+ TM_H = $(GTM_H) insn-flags.h $(OPTIONS_H)
+--
+2.44.0
+
diff --git a/13.2.0/gentoo/89_all_Makefile.in-Make-recog.h-depend-on-TREE_H-PR111021.patch b/13.2.0/gentoo/89_all_Makefile.in-Make-recog.h-depend-on-TREE_H-PR111021.patch
new file mode 100644
index 0000000..e0c84ae
--- /dev/null
+++ b/13.2.0/gentoo/89_all_Makefile.in-Make-recog.h-depend-on-TREE_H-PR111021.patch
@@ -0,0 +1,45 @@
+https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=ecb95399f43873e1f34119ac260bbea2ef358e53
+
+From 45b0ac72b82e483ac2b8380ce08cedcfd021afb0 Mon Sep 17 00:00:00 2001
+From: Kewen Lin <linkw@linux.ibm.com>
+Date: Tue, 15 Aug 2023 03:01:20 -0500
+Subject: [PATCH 12/15] Makefile.in: Make recog.h depend on $(TREE_H)
+ [PR111021]
+
+Commit r14-3093 introduced a random build failure on
+build/gencondmd.cc building. Since r14-3093 make recog.h
+include tree.h, which further includes (depends on) some
+files that are generated during the building, such as:
+all-tree.def, tree-check.h etc, when building file
+build/gencondmd.cc, the build can fail if these dependences
+are not ready. So this patch is to teach this dependence.
+
+Thank Jan-Benedict Glaw for testing this!
+
+ PR bootstrap/111021
+
+gcc/ChangeLog:
+
+ * Makefile.in (RECOG_H): Add $(TREE_H) as dependence.
+
+(cherry picked from commit ecb95399f43873e1f34119ac260bbea2ef358e53)
+---
+ gcc/Makefile.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index 115d2a6d9b76..2c16b14ad0f3 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -985,7 +985,7 @@ GIMPLE_H = gimple.h gimple.def gsstruct.def $(VEC_H) \
+ $(GGC_H) $(BASIC_BLOCK_H) $(TREE_H) tree-ssa-operands.h \
+ tree-ssa-alias.h $(INTERNAL_FN_H) $(HASH_TABLE_H) is-a.h
+ GCOV_IO_H = gcov-io.h version.h auto-host.h gcov-counter.def
+-RECOG_H = recog.h
++RECOG_H = recog.h $(TREE_H)
+ EMIT_RTL_H = emit-rtl.h
+ FLAGS_H = flags.h flag-types.h $(OPTIONS_H)
+ OPTIONS_H = options.h flag-types.h $(OPTIONS_H_EXTRA)
+--
+2.44.0
+
diff --git a/13.2.0/gentoo/90_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch b/13.2.0/gentoo/90_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch
new file mode 100644
index 0000000..f6ded53
--- /dev/null
+++ b/13.2.0/gentoo/90_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch
@@ -0,0 +1,1404 @@
+https://gcc.gnu.org/PR54179
+https://inbox.sourceware.org/gcc-patches/de0f7bdc-d236-4f5b-9504-d5bfb215d023@gmail.com/
+
+From d63f858f41e2bb0e159d15ed8ee41bf303325ee7 Mon Sep 17 00:00:00 2001
+From: Robin Dapp <rdapp.gcc@gmail.com>
+Date: Fri, 27 Oct 2023 21:04:25 +0200
+Subject: [PATCH 13/15] genemit: Split insn-emit.cc into ten files.
+
+After working with Sam off-list (thanks) I managed to get hppa to
+build. Initially it looked as if hppa just had a very small number of
+instruction patterns so we wouldn't generate all 10 output files.
+However, the actual issue (which we will only hit with a low
+pattern count) was with counting all the patterns vs only counting
+the patterns that will be output. A wrong pattern count lead to
+prematurely stopping to write output files.
+
+With that corrected, hppa "just works" until I hit linker errors
+due to relocations - most likely unrelated:
+
+bin/ld: unwind-dw2-fde-dip_s.o(.data.rel.ro+0): cannot handle
+R_PARISC_FPTR64 for __pthread_key_create@@GLIBC_2.34
+
+Attached is v3 that has been bootstrapped and tested on x86 and power10,
+aarch64 bootstrap was ok, testsuite is still running. A riscv build and
+testsuite run was successful as well.
+
+Regards
+ Robin
+
+>From 248744c328440bff9cc339d2bf622852cbaac343 Mon Sep 17 00:00:00 2001
+From: Robin Dapp <rdapp@ventanamicro.com>
+Date: Thu, 12 Oct 2023 11:23:26 +0200
+Subject: [PATCH v3] genemit: Split insn-emit.cc into several partitions.
+
+On riscv insn-emit.cc has grown to over 1.2 mio lines of code and
+compiling it takes considerable time.
+Therefore, this patch adjust genemit to create several partitions
+(insn-emit-1.cc to insn-emit-n.cc). The available patterns are
+written to the given files in a sequential fashion.
+
+Similar to match.pd a configure option --with-emitinsn-partitions=num
+is introduced that makes the number of partition configurable.
+
+gcc/ChangeLog:
+
+ PR bootstrap/84402
+ PR target/111600
+
+ * Makefile.in: Handle split insn-emit.cc.
+ * configure: Regenerate.
+ * configure.ac: Add --with-insnemit-partitions.
+ * genemit.cc (output_peephole2_scratches): Print to file instead
+ of stdout.
+ (print_code): Ditto.
+ (gen_rtx_scratch): Ditto.
+ (gen_exp): Ditto.
+ (gen_emit_seq): Ditto.
+ (emit_c_code): Ditto.
+ (gen_insn): Ditto.
+ (gen_expand): Ditto.
+ (gen_split): Ditto.
+ (output_add_clobbers): Ditto.
+ (output_added_clobbers_hard_reg_p): Ditto.
+ (print_overload_arguments): Ditto.
+ (print_overload_test): Ditto.
+ (handle_overloaded_code_for): Ditto.
+ (handle_overloaded_gen): Ditto.
+ (print_header): New function.
+ (handle_arg): New function.
+ (main): Split output into 10 files.
+ * gensupport.cc (count_patterns): New function.
+ * gensupport.h (count_patterns): Define.
+ * read-md.cc (md_reader::print_md_ptr_loc): Add file argument.
+ * read-md.h (class md_reader): Change definition.
+---
+ gcc/Makefile.in | 36 ++-
+ gcc/configure | 24 +-
+ gcc/configure.ac | 13 ++
+ gcc/genemit.cc | 542 +++++++++++++++++++++++++---------------------
+ gcc/gensupport.cc | 55 +++++
+ gcc/gensupport.h | 1 +
+ gcc/read-md.cc | 4 +-
+ gcc/read-md.h | 2 +-
+ 8 files changed, 422 insertions(+), 255 deletions(-)
+
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index 2c16b14ad0f3..b0c118e6d189 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -232,6 +232,13 @@ GIMPLE_MATCH_PD_SEQ_O = $(patsubst %, gimple-match-%.o, $(MATCH_SPLITS_SEQ))
+ GENERIC_MATCH_PD_SEQ_SRC = $(patsubst %, generic-match-%.cc, $(MATCH_SPLITS_SEQ))
+ GENERIC_MATCH_PD_SEQ_O = $(patsubst %, generic-match-%.o, $(MATCH_SPLITS_SEQ))
+
++# The number of splits to be made for the insn-emit files.
++NUM_INSNEMIT_SPLITS = @DEFAULT_INSNEMIT_PARTITIONS@
++INSNEMIT_SPLITS_SEQ = $(wordlist 1,$(NUM_INSNEMIT_SPLITS),$(one_to_9999))
++INSNEMIT_SEQ_SRC = $(patsubst %, insn-emit-%.cc, $(INSNEMIT_SPLITS_SEQ))
++INSNEMIT_SEQ_TMP = $(patsubst %, tmp-emit-%.cc, $(INSNEMIT_SPLITS_SEQ))
++INSNEMIT_SEQ_O = $(patsubst %, insn-emit-%.o, $(INSNEMIT_SPLITS_SEQ))
++
+ # These files are to have specific diagnostics suppressed, or are not to
+ # be subject to -Werror:
+ # flex output may yield harmless "no previous prototype" warnings
+@@ -1331,7 +1338,7 @@ OBJS = \
+ insn-attrtab.o \
+ insn-automata.o \
+ insn-dfatab.o \
+- insn-emit.o \
++ $(INSNEMIT_SEQ_O) \
+ insn-extract.o \
+ insn-latencytab.o \
+ insn-modes.o \
+@@ -1817,7 +1824,8 @@ TREECHECKING = @TREECHECKING@
+ FULL_DRIVER_NAME=$(target_noncanonical)-gcc-$(version)$(exeext)
+
+ MOSTLYCLEANFILES = insn-flags.h insn-config.h insn-codes.h \
+- insn-output.cc insn-recog.cc insn-emit.cc insn-extract.cc insn-peep.cc \
++ insn-output.cc insn-recog.cc $(INSNEMIT_SEQ_SRC) \
++ insn-extract.cc insn-peep.cc \
+ insn-attr.h insn-attr-common.h insn-attrtab.cc insn-dfatab.cc \
+ insn-latencytab.cc insn-opinit.cc insn-opinit.h insn-preds.cc insn-constants.h \
+ tm-preds.h tm-constrs.h checksum-options $(GIMPLE_MATCH_PD_SEQ_SRC) \
+@@ -2434,11 +2442,11 @@ $(common_out_object_file): $(common_out_file)
+ # and compile them.
+
+ .PRECIOUS: insn-config.h insn-flags.h insn-codes.h insn-constants.h \
+- insn-emit.cc insn-recog.cc insn-extract.cc insn-output.cc insn-peep.cc \
+- insn-attr.h insn-attr-common.h insn-attrtab.cc insn-dfatab.cc \
+- insn-latencytab.cc insn-preds.cc $(GIMPLE_MATCH_PD_SEQ_SRC) \
+- $(GENERIC_MATCH_PD_SEQ_SRC) gimple-match-auto.h generic-match-auto.h \
+- insn-target-def.h
++ $(INSNEMIT_SEQ_SRC) insn-recog.cc insn-extract.cc insn-output.cc \
++ insn-peep.cc insn-attr.h insn-attr-common.h insn-attrtab.cc \
++ insn-dfatab.cc insn-latencytab.cc insn-preds.cc \
++ $(GIMPLE_MATCH_PD_SEQ_SRC) $(GENERIC_MATCH_PD_SEQ_SRC) \
++ gimple-match-auto.h generic-match-auto.h insn-target-def.h
+
+ # Dependencies for the md file. The first time through, we just assume
+ # the md file itself and the generated dependency file (in order to get
+@@ -2461,7 +2469,7 @@ s-mddeps: $(md_file) $(MD_INCLUDES) build/genmddeps$(build_exeext)
+ simple_rtl_generated_h = insn-attr.h insn-attr-common.h insn-codes.h \
+ insn-config.h insn-flags.h insn-target-def.h
+
+-simple_rtl_generated_c = insn-automata.cc insn-emit.cc \
++simple_rtl_generated_c = insn-automata.cc \
+ insn-extract.cc insn-output.cc \
+ insn-peep.cc insn-recog.cc
+
+@@ -2490,8 +2498,20 @@ $(simple_generated_c:insn-%.cc=s-%): s-%: build/gen%$(build_exeext)
+ $(SHELL) $(srcdir)/../move-if-change tmp-$*.cc insn-$*.cc
+ $(STAMP) s-$*
+
++# genemit splits its output into different files and doesn't write to
++# stdout. (but rather to tmp-emit-01.cc..tmp-emit-10.cc)
++$(INSNEMIT_SEQ_SRC): s-tmp-emit; @true
++s-tmp-emit: build/genemit$(build_exeext) $(MD_DEPS) insn-conditions.md
++ $(RUN_GEN) build/genemit$(build_exeext) $(md_file) insn-conditions.md \
++ $(addprefix -O,${INSNEMIT_SEQ_TMP})
++ $(foreach id, $(INSNEMIT_SPLITS_SEQ), \
++ $(SHELL) $(srcdir)/../move-if-change tmp-emit-$(id).cc \
++ insn-emit-$(id).cc;)
++ $(STAMP) s-tmp-emit
++
+ # gencheck doesn't read the machine description, and the file produced
+ # doesn't use the insn-* convention.
++
+ tree-check.h: s-check ; @true
+ s-check : build/gencheck$(build_exeext)
+ $(RUN_GEN) build/gencheck$(build_exeext) > tmp-check.h
+diff --git a/gcc/configure b/gcc/configure
+index cc8247037569..c98088bea90d 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -838,6 +838,7 @@ enable_gcov
+ enable_shared
+ enable_fixed_point
+ enable_decimal_float
++DEFAULT_INSNEMIT_PARTITIONS
+ DEFAULT_MATCHPD_PARTITIONS
+ with_float
+ with_cpu
+@@ -967,6 +968,7 @@ enable_multilib
+ enable_multiarch
+ with_stack_clash_protection_guard_size
+ with_matchpd_partitions
++with_insnemit_partitions
+ enable___cxa_atexit
+ enable_decimal_float
+ enable_fixed_point
+@@ -1837,6 +1839,9 @@ Optional Packages:
+ --with-matchpd-partitions=num
+ Set the number of partitions to make for gimple and
+ generic when splitting match.pd. [default=10]
++ --with-insnemit-partitions=num
++ Set the number of partitions of insn-emit.cc for
++ genemit to create. [default=10]
+ --with-dwarf2 force the default debug format to be DWARF 2 (or
+ later)
+ --with-specs=SPECS add SPECS to driver command-line processing
+@@ -7938,6 +7943,21 @@ fi
+
+
+
++# Specify the number of splits of insn-emit.cc to generate.
++
++# Check whether --with-insnemit-partitions was given.
++if test "${with_insnemit_partitions+set}" = set; then :
++ withval=$with_insnemit_partitions; DEFAULT_INSNEMIT_PARTITIONS="$with_insnemit_partitions"
++else
++ DEFAULT_INSNEMIT_PARTITIONS=10
++fi
++
++if (test $DEFAULT_INSNEMIT_PARTITIONS -lt 1); then
++ as_fn_error $? "Invalid value $DEFAULT_INSNEMIT_PARTITIONS for --with-insnemit-partitions. Cannot be negative." "$LINENO" 5
++fi
++
++
++
+ # Enable __cxa_atexit for C++.
+ # Check whether --enable-__cxa_atexit was given.
+ if test "${enable___cxa_atexit+set}" = set; then :
+@@ -19891,7 +19911,7 @@ else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+-#line 19894 "configure"
++#line 19914 "configure"
+ #include "confdefs.h"
+
+ #if HAVE_DLFCN_H
+@@ -19997,7 +20017,7 @@ else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+-#line 20000 "configure"
++#line 20020 "configure"
+ #include "confdefs.h"
+
+ #if HAVE_DLFCN_H
+diff --git a/gcc/configure.ac b/gcc/configure.ac
+index d02ffc22a3a3..7021f95da3ee 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -956,6 +956,19 @@ fi
+
+ AC_SUBST(DEFAULT_MATCHPD_PARTITIONS)
+
++# Specify the number of splits of insn-emit.cc to generate.
++AC_ARG_WITH(insnemit-partitions,
++[AS_HELP_STRING([--with-insnemit-partitions=num],
++[Set the number of partitions of insn-emit.cc for genemit to create. [default=10]])],
++[DEFAULT_INSNEMIT_PARTITIONS="$with_insnemit_partitions"], [DEFAULT_INSNEMIT_PARTITIONS=10])
++if (test $DEFAULT_INSNEMIT_PARTITIONS -lt 1); then
++ AC_MSG_ERROR(m4_normalize([
++ Invalid value $DEFAULT_INSNEMIT_PARTITIONS for --with-insnemit-partitions. \
++ Cannot be negative.]))
++fi
++
++AC_SUBST(DEFAULT_INSNEMIT_PARTITIONS)
++
+ # Enable __cxa_atexit for C++.
+ AC_ARG_ENABLE(__cxa_atexit,
+ [AS_HELP_STRING([--enable-__cxa_atexit], [enable __cxa_atexit for C++])],
+diff --git a/gcc/genemit.cc b/gcc/genemit.cc
+index 33c9ec05d6fc..18c95e3f6412 100644
+--- a/gcc/genemit.cc
++++ b/gcc/genemit.cc
+@@ -49,29 +49,29 @@ struct clobber_ent
+ struct clobber_ent *next;
+ };
+
+-static void output_peephole2_scratches (rtx);
++static void output_peephole2_scratches (rtx, FILE*);
+
+ /* True for <X>_optab if that optab isn't allowed to fail. */
+ static bool nofail_optabs[NUM_OPTABS];
+
+ static void
+-print_code (RTX_CODE code)
++print_code (RTX_CODE code, FILE *file)
+ {
+ const char *p1;
+ for (p1 = GET_RTX_NAME (code); *p1; p1++)
+- putchar (TOUPPER (*p1));
++ fprintf (file, "%c", TOUPPER (*p1));
+ }
+
+ static void
+-gen_rtx_scratch (rtx x, enum rtx_code subroutine_type)
++gen_rtx_scratch (rtx x, enum rtx_code subroutine_type, FILE *file)
+ {
+ if (subroutine_type == DEFINE_PEEPHOLE2)
+ {
+- printf ("operand%d", XINT (x, 0));
++ fprintf (file, "operand%d", XINT (x, 0));
+ }
+ else
+ {
+- printf ("gen_rtx_SCRATCH (%smode)", GET_MODE_NAME (GET_MODE (x)));
++ fprintf (file, "gen_rtx_SCRATCH (%smode)", GET_MODE_NAME (GET_MODE (x)));
+ }
+ }
+
+@@ -79,7 +79,8 @@ gen_rtx_scratch (rtx x, enum rtx_code subroutine_type)
+ substituting any operand references appearing within. */
+
+ static void
+-gen_exp (rtx x, enum rtx_code subroutine_type, char *used, md_rtx_info *info)
++gen_exp (rtx x, enum rtx_code subroutine_type, char *used, md_rtx_info *info,
++ FILE *file)
+ {
+ RTX_CODE code;
+ int i;
+@@ -89,7 +90,7 @@ gen_exp (rtx x, enum rtx_code subroutine_type, char *used, md_rtx_info *info)
+
+ if (x == 0)
+ {
+- printf ("NULL_RTX");
++ fprintf (file, "NULL_RTX");
+ return;
+ }
+
+@@ -103,67 +104,67 @@ gen_exp (rtx x, enum rtx_code subroutine_type, char *used, md_rtx_info *info)
+ {
+ if (used[XINT (x, 0)])
+ {
+- printf ("copy_rtx (operand%d)", XINT (x, 0));
++ fprintf (file, "copy_rtx (operand%d)", XINT (x, 0));
+ return;
+ }
+ used[XINT (x, 0)] = 1;
+ }
+- printf ("operand%d", XINT (x, 0));
++ fprintf (file, "operand%d", XINT (x, 0));
+ return;
+
+ case MATCH_OP_DUP:
+- printf ("gen_rtx_fmt_");
++ fprintf (file, "gen_rtx_fmt_");
+ for (i = 0; i < XVECLEN (x, 1); i++)
+- printf ("e");
+- printf (" (GET_CODE (operand%d), ", XINT (x, 0));
++ fprintf (file, "e");
++ fprintf (file, " (GET_CODE (operand%d), ", XINT (x, 0));
+ if (GET_MODE (x) == VOIDmode)
+- printf ("GET_MODE (operand%d)", XINT (x, 0));
++ fprintf (file, "GET_MODE (operand%d)", XINT (x, 0));
+ else
+- printf ("%smode", GET_MODE_NAME (GET_MODE (x)));
++ fprintf (file, "%smode", GET_MODE_NAME (GET_MODE (x)));
+ for (i = 0; i < XVECLEN (x, 1); i++)
+ {
+- printf (",\n\t\t");
+- gen_exp (XVECEXP (x, 1, i), subroutine_type, used, info);
++ fprintf (file, ",\n\t\t");
++ gen_exp (XVECEXP (x, 1, i), subroutine_type, used, info, file);
+ }
+- printf (")");
++ fprintf (file, ")");
+ return;
+
+ case MATCH_OPERATOR:
+- printf ("gen_rtx_fmt_");
++ fprintf (file, "gen_rtx_fmt_");
+ for (i = 0; i < XVECLEN (x, 2); i++)
+- printf ("e");
+- printf (" (GET_CODE (operand%d)", XINT (x, 0));
+- printf (", %smode", GET_MODE_NAME (GET_MODE (x)));
++ fprintf (file, "e");
++ fprintf (file, " (GET_CODE (operand%d)", XINT (x, 0));
++ fprintf (file, ", %smode", GET_MODE_NAME (GET_MODE (x)));
+ for (i = 0; i < XVECLEN (x, 2); i++)
+ {
+- printf (",\n\t\t");
+- gen_exp (XVECEXP (x, 2, i), subroutine_type, used, info);
++ fprintf (file, ",\n\t\t");
++ gen_exp (XVECEXP (x, 2, i), subroutine_type, used, info, file);
+ }
+- printf (")");
++ fprintf (file, ")");
+ return;
+
+ case MATCH_PARALLEL:
+ case MATCH_PAR_DUP:
+- printf ("operand%d", XINT (x, 0));
++ fprintf (file, "operand%d", XINT (x, 0));
+ return;
+
+ case MATCH_SCRATCH:
+- gen_rtx_scratch (x, subroutine_type);
++ gen_rtx_scratch (x, subroutine_type, file);
+ return;
+
+ case PC:
+- printf ("pc_rtx");
++ fprintf (file, "pc_rtx");
+ return;
+ case RETURN:
+- printf ("ret_rtx");
++ fprintf (file, "ret_rtx");
+ return;
+ case SIMPLE_RETURN:
+- printf ("simple_return_rtx");
++ fprintf (file, "simple_return_rtx");
+ return;
+ case CLOBBER:
+ if (REG_P (XEXP (x, 0)))
+ {
+- printf ("gen_hard_reg_clobber (%smode, %i)",
++ fprintf (file, "gen_hard_reg_clobber (%smode, %i)",
+ GET_MODE_NAME (GET_MODE (XEXP (x, 0))),
+ REGNO (XEXP (x, 0)));
+ return;
+@@ -172,22 +173,22 @@ gen_exp (rtx x, enum rtx_code subroutine_type, char *used, md_rtx_info *info)
+
+ case CONST_INT:
+ if (INTVAL (x) == 0)
+- printf ("const0_rtx");
++ fprintf (file, "const0_rtx");
+ else if (INTVAL (x) == 1)
+- printf ("const1_rtx");
++ fprintf (file, "const1_rtx");
+ else if (INTVAL (x) == -1)
+- printf ("constm1_rtx");
++ fprintf (file, "constm1_rtx");
+ else if (-MAX_SAVED_CONST_INT <= INTVAL (x)
+ && INTVAL (x) <= MAX_SAVED_CONST_INT)
+- printf ("const_int_rtx[MAX_SAVED_CONST_INT + (%d)]",
++ fprintf (file, "const_int_rtx[MAX_SAVED_CONST_INT + (%d)]",
+ (int) INTVAL (x));
+ else if (INTVAL (x) == STORE_FLAG_VALUE)
+- printf ("const_true_rtx");
++ fprintf (file, "const_true_rtx");
+ else
+ {
+- printf ("GEN_INT (");
+- printf (HOST_WIDE_INT_PRINT_DEC_C, INTVAL (x));
+- printf (")");
++ fprintf (file, "GEN_INT (");
++ fprintf (file, HOST_WIDE_INT_PRINT_DEC_C, INTVAL (x));
++ fprintf (file, ")");
+ }
+ return;
+
+@@ -195,7 +196,7 @@ gen_exp (rtx x, enum rtx_code subroutine_type, char *used, md_rtx_info *info)
+ /* Handle `const_double_zero' rtx. */
+ if (CONST_DOUBLE_REAL_VALUE (x)->cl == rvc_zero)
+ {
+- printf ("CONST_DOUBLE_ATOF (\"0\", %smode)",
++ fprintf (file, "CONST_DOUBLE_ATOF (\"0\", %smode)",
+ GET_MODE_NAME (GET_MODE (x)));
+ return;
+ }
+@@ -210,12 +211,12 @@ gen_exp (rtx x, enum rtx_code subroutine_type, char *used, md_rtx_info *info)
+ break;
+ }
+
+- printf ("gen_rtx_");
+- print_code (code);
+- printf (" (");
++ fprintf (file, "gen_rtx_");
++ print_code (code, file);
++ fprintf (file, " (");
+ if (!always_void_p (code))
+ {
+- printf ("%smode", GET_MODE_NAME (GET_MODE (x)));
++ fprintf (file, "%smode", GET_MODE_NAME (GET_MODE (x)));
+ sep = ",\n\t";
+ }
+
+@@ -225,41 +226,41 @@ gen_exp (rtx x, enum rtx_code subroutine_type, char *used, md_rtx_info *info)
+ {
+ if (fmt[i] == '0')
+ break;
+- fputs (sep, stdout);
++ fputs (sep, file);
+ switch (fmt[i])
+ {
+ case 'e': case 'u':
+- gen_exp (XEXP (x, i), subroutine_type, used, info);
++ gen_exp (XEXP (x, i), subroutine_type, used, info, file);
+ break;
+
+ case 'i':
+- printf ("%u", XINT (x, i));
++ fprintf (file, "%u", XINT (x, i));
+ break;
+
+ case 'r':
+- printf ("%u", REGNO (x));
++ fprintf (file, "%u", REGNO (x));
+ break;
+
+ case 'p':
+ /* We don't have a way of parsing polynomial offsets yet,
+ and hopefully never will. */
+- printf ("%d", SUBREG_BYTE (x).to_constant ());
++ fprintf (file, "%d", SUBREG_BYTE (x).to_constant ());
+ break;
+
+ case 's':
+- printf ("\"%s\"", XSTR (x, i));
++ fprintf (file, "\"%s\"", XSTR (x, i));
+ break;
+
+ case 'E':
+ {
+ int j;
+- printf ("gen_rtvec (%d", XVECLEN (x, i));
++ fprintf (file, "gen_rtvec (%d", XVECLEN (x, i));
+ for (j = 0; j < XVECLEN (x, i); j++)
+ {
+- printf (",\n\t\t");
+- gen_exp (XVECEXP (x, i, j), subroutine_type, used, info);
++ fprintf (file, ",\n\t\t");
++ gen_exp (XVECEXP (x, i, j), subroutine_type, used, info, file);
+ }
+- printf (")");
++ fprintf (file, ")");
+ break;
+ }
+
+@@ -268,14 +269,14 @@ gen_exp (rtx x, enum rtx_code subroutine_type, char *used, md_rtx_info *info)
+ }
+ sep = ",\n\t";
+ }
+- printf (")");
++ fprintf (file, ")");
+ }
+
+ /* Output code to emit the instruction patterns in VEC, with each element
+ becoming a separate instruction. USED is as for gen_exp. */
+
+ static void
+-gen_emit_seq (rtvec vec, char *used, md_rtx_info *info)
++gen_emit_seq (rtvec vec, char *used, md_rtx_info *info, FILE *file)
+ {
+ for (int i = 0, len = GET_NUM_ELEM (vec); i < len; ++i)
+ {
+@@ -283,17 +284,17 @@ gen_emit_seq (rtvec vec, char *used, md_rtx_info *info)
+ rtx next = RTVEC_ELT (vec, i);
+ if (const char *name = get_emit_function (next))
+ {
+- printf (" %s (", name);
+- gen_exp (next, DEFINE_EXPAND, used, info);
+- printf (");\n");
++ fprintf (file, " %s (", name);
++ gen_exp (next, DEFINE_EXPAND, used, info, file);
++ fprintf (file, ");\n");
+ if (!last_p && needs_barrier_p (next))
+- printf (" emit_barrier ();");
++ fprintf (file, " emit_barrier ();");
+ }
+ else
+ {
+- printf (" emit (");
+- gen_exp (next, DEFINE_EXPAND, used, info);
+- printf (", %s);\n", last_p ? "false" : "true");
++ fprintf (file, " emit (");
++ gen_exp (next, DEFINE_EXPAND, used, info, file);
++ fprintf (file, ", %s);\n", last_p ? "false" : "true");
+ }
+ }
+ }
+@@ -303,27 +304,27 @@ gen_emit_seq (rtvec vec, char *used, md_rtx_info *info)
+ for use in error messages. */
+
+ static void
+-emit_c_code (const char *code, bool can_fail_p, const char *name)
++emit_c_code (const char *code, bool can_fail_p, const char *name, FILE *file)
+ {
+ if (can_fail_p)
+- printf ("#define FAIL return (end_sequence (), _val)\n");
++ fprintf (file, "#define FAIL return (end_sequence (), _val)\n");
+ else
+- printf ("#define FAIL _Pragma (\"GCC error \\\"%s cannot FAIL\\\"\")"
++ fprintf (file, "#define FAIL _Pragma (\"GCC error \\\"%s cannot FAIL\\\"\")"
+ " (void)0\n", name);
+- printf ("#define DONE return (_val = get_insns (), "
++ fprintf (file, "#define DONE return (_val = get_insns (), "
+ "end_sequence (), _val)\n");
+
+- rtx_reader_ptr->print_md_ptr_loc (code);
+- printf ("%s\n", code);
++ rtx_reader_ptr->print_md_ptr_loc (code, file);
++ fprintf (file, "%s\n", code);
+
+- printf ("#undef DONE\n");
+- printf ("#undef FAIL\n");
++ fprintf (file, "#undef DONE\n");
++ fprintf (file, "#undef FAIL\n");
+ }
+
+ /* Generate the `gen_...' function for a DEFINE_INSN. */
+
+ static void
+-gen_insn (md_rtx_info *info)
++gen_insn (md_rtx_info *info, FILE *file)
+ {
+ struct pattern_stats stats;
+ int i;
+@@ -409,7 +410,7 @@ gen_insn (md_rtx_info *info)
+ if (XSTR (insn, 0)[0] == 0 || XSTR (insn, 0)[0] == '*')
+ return;
+
+- printf ("/* %s:%d */\n", info->loc.filename, info->loc.lineno);
++ fprintf (file, "/* %s:%d */\n", info->loc.filename, info->loc.lineno);
+
+ /* Find out how many operands this function has. */
+ get_pattern_stats (&stats, XVEC (insn, 1));
+@@ -417,17 +418,17 @@ gen_insn (md_rtx_info *info)
+ fatal_at (info->loc, "match_dup operand number has no match_operand");
+
+ /* Output the function name and argument declarations. */
+- printf ("rtx\ngen_%s (", XSTR (insn, 0));
++ fprintf (file, "rtx\ngen_%s (", XSTR (insn, 0));
+ if (stats.num_generator_args)
+ for (i = 0; i < stats.num_generator_args; i++)
+ if (i)
+- printf (",\n\trtx operand%d ATTRIBUTE_UNUSED", i);
++ fprintf (file, ",\n\trtx operand%d ATTRIBUTE_UNUSED", i);
+ else
+- printf ("rtx operand%d ATTRIBUTE_UNUSED", i);
++ fprintf (file, "rtx operand%d ATTRIBUTE_UNUSED", i);
+ else
+- printf ("void");
+- printf (")\n");
+- printf ("{\n");
++ fprintf (file, "void");
++ fprintf (file, ")\n");
++ fprintf (file, "{\n");
+
+ /* Output code to construct and return the rtl for the instruction body. */
+
+@@ -436,16 +437,16 @@ gen_insn (md_rtx_info *info)
+ char *used = (XVECLEN (insn, 1) == 1
+ ? NULL
+ : XCNEWVEC (char, stats.num_generator_args));
+- printf (" return ");
+- gen_exp (pattern, DEFINE_INSN, used, info);
+- printf (";\n}\n\n");
++ fprintf (file, " return ");
++ gen_exp (pattern, DEFINE_INSN, used, info, file);
++ fprintf (file, ";\n}\n\n");
+ XDELETEVEC (used);
+ }
+
+ /* Generate the `gen_...' function for a DEFINE_EXPAND. */
+
+ static void
+-gen_expand (md_rtx_info *info)
++gen_expand (md_rtx_info *info, FILE *file)
+ {
+ struct pattern_stats stats;
+ int i;
+@@ -466,17 +467,17 @@ gen_expand (md_rtx_info *info)
+ "numbers above all other operands", XSTR (expand, 0));
+
+ /* Output the function name and argument declarations. */
+- printf ("rtx\ngen_%s (", XSTR (expand, 0));
++ fprintf (file, "rtx\ngen_%s (", XSTR (expand, 0));
+ if (stats.num_generator_args)
+ for (i = 0; i < stats.num_generator_args; i++)
+ if (i)
+- printf (",\n\trtx operand%d", i);
++ fprintf (file, ",\n\trtx operand%d", i);
+ else
+- printf ("rtx operand%d", i);
++ fprintf (file, "rtx operand%d", i);
+ else
+- printf ("void");
+- printf (")\n");
+- printf ("{\n");
++ fprintf (file, "void");
++ fprintf (file, ")\n");
++ fprintf (file, "{\n");
+
+ /* If we don't have any C code to write, only one insn is being written,
+ and no MATCH_DUPs are present, we can just return the desired insn
+@@ -485,18 +486,18 @@ gen_expand (md_rtx_info *info)
+ && stats.max_opno >= stats.max_dup_opno
+ && XVECLEN (expand, 1) == 1)
+ {
+- printf (" return ");
+- gen_exp (XVECEXP (expand, 1, 0), DEFINE_EXPAND, NULL, info);
+- printf (";\n}\n\n");
++ fprintf (file, " return ");
++ gen_exp (XVECEXP (expand, 1, 0), DEFINE_EXPAND, NULL, info, file);
++ fprintf (file, ";\n}\n\n");
+ return;
+ }
+
+ /* For each operand referred to only with MATCH_DUPs,
+ make a local variable. */
+ for (i = stats.num_generator_args; i <= stats.max_dup_opno; i++)
+- printf (" rtx operand%d;\n", i);
+- printf (" rtx_insn *_val = 0;\n");
+- printf (" start_sequence ();\n");
++ fprintf (file, " rtx operand%d;\n", i);
++ fprintf (file, " rtx_insn *_val = 0;\n");
++ fprintf (file, " start_sequence ();\n");
+
+ /* The fourth operand of DEFINE_EXPAND is some code to be executed
+ before the actual construction.
+@@ -506,13 +507,13 @@ gen_expand (md_rtx_info *info)
+ So copy the operand values there before executing it. */
+ if (XSTR (expand, 3) && *XSTR (expand, 3))
+ {
+- printf (" {\n");
++ fprintf (file, " {\n");
+ if (stats.num_operand_vars > 0)
+- printf (" rtx operands[%d];\n", stats.num_operand_vars);
++ fprintf (file, " rtx operands[%d];\n", stats.num_operand_vars);
+
+ /* Output code to copy the arguments into `operands'. */
+ for (i = 0; i < stats.num_generator_args; i++)
+- printf (" operands[%d] = operand%d;\n", i, i);
++ fprintf (file, " operands[%d] = operand%d;\n", i, i);
+
+ /* Output the special code to be executed before the sequence
+ is generated. */
+@@ -524,7 +525,7 @@ gen_expand (md_rtx_info *info)
+ if (nofail_optabs[p.op])
+ can_fail_p = false;
+ }
+- emit_c_code (XSTR (expand, 3), can_fail_p, XSTR (expand, 0));
++ emit_c_code (XSTR (expand, 3), can_fail_p, XSTR (expand, 0), file);
+
+ /* Output code to copy the arguments back out of `operands'
+ (unless we aren't going to use them at all). */
+@@ -532,29 +533,29 @@ gen_expand (md_rtx_info *info)
+ {
+ for (i = 0; i <= MAX (stats.max_opno, stats.max_dup_opno); i++)
+ {
+- printf (" operand%d = operands[%d];\n", i, i);
+- printf (" (void) operand%d;\n", i);
++ fprintf (file, " operand%d = operands[%d];\n", i, i);
++ fprintf (file, " (void) operand%d;\n", i);
+ }
+ }
+- printf (" }\n");
++ fprintf (file, " }\n");
+ }
+
+ used = XCNEWVEC (char, stats.num_operand_vars);
+- gen_emit_seq (XVEC (expand, 1), used, info);
++ gen_emit_seq (XVEC (expand, 1), used, info, file);
+ XDELETEVEC (used);
+
+ /* Call `get_insns' to extract the list of all the
+ insns emitted within this gen_... function. */
+
+- printf (" _val = get_insns ();\n");
+- printf (" end_sequence ();\n");
+- printf (" return _val;\n}\n\n");
++ fprintf (file, " _val = get_insns ();\n");
++ fprintf (file, " end_sequence ();\n");
++ fprintf (file, " return _val;\n}\n\n");
+ }
+
+ /* Like gen_expand, but generates insns resulting from splitting SPLIT. */
+
+ static void
+-gen_split (md_rtx_info *info)
++gen_split (md_rtx_info *info, FILE *file)
+ {
+ struct pattern_stats stats;
+ int i;
+@@ -580,62 +581,62 @@ gen_split (md_rtx_info *info)
+ /* Output the prototype, function name and argument declarations. */
+ if (GET_CODE (split) == DEFINE_PEEPHOLE2)
+ {
+- printf ("extern rtx_insn *gen_%s_%d (rtx_insn *, rtx *);\n",
++ fprintf (file, "extern rtx_insn *gen_%s_%d (rtx_insn *, rtx *);\n",
+ name, info->index);
+- printf ("rtx_insn *\ngen_%s_%d (rtx_insn *curr_insn ATTRIBUTE_UNUSED,"
++ fprintf (file, "rtx_insn *\ngen_%s_%d (rtx_insn *curr_insn ATTRIBUTE_UNUSED,"
+ " rtx *operands%s)\n",
+ name, info->index, unused);
+ }
+ else
+ {
+- printf ("extern rtx_insn *gen_split_%d (rtx_insn *, rtx *);\n",
++ fprintf (file, "extern rtx_insn *gen_split_%d (rtx_insn *, rtx *);\n",
+ info->index);
+- printf ("rtx_insn *\ngen_split_%d "
++ fprintf (file, "rtx_insn *\ngen_split_%d "
+ "(rtx_insn *curr_insn ATTRIBUTE_UNUSED, rtx *operands%s)\n",
+ info->index, unused);
+ }
+- printf ("{\n");
++ fprintf (file, "{\n");
+
+ /* Declare all local variables. */
+ for (i = 0; i < stats.num_operand_vars; i++)
+- printf (" rtx operand%d;\n", i);
+- printf (" rtx_insn *_val = NULL;\n");
++ fprintf (file, " rtx operand%d;\n", i);
++ fprintf (file, " rtx_insn *_val = NULL;\n");
+
+ if (GET_CODE (split) == DEFINE_PEEPHOLE2)
+- output_peephole2_scratches (split);
++ output_peephole2_scratches (split, file);
+
+ const char *fn = info->loc.filename;
+ for (const char *p = fn; *p; p++)
+ if (*p == '/')
+ fn = p + 1;
+
+- printf (" if (dump_file)\n");
+- printf (" fprintf (dump_file, \"Splitting with gen_%s_%d (%s:%d)\\n\");\n",
++ fprintf (file, " if (dump_file)\n");
++ fprintf (file, " fprintf (dump_file, \"Splitting with gen_%s_%d (%s:%d)\\n\");\n",
+ name, info->index, fn, info->loc.lineno);
+
+- printf (" start_sequence ();\n");
++ fprintf (file, " start_sequence ();\n");
+
+ /* The fourth operand of DEFINE_SPLIT is some code to be executed
+ before the actual construction. */
+
+ if (XSTR (split, 3))
+- emit_c_code (XSTR (split, 3), true, name);
++ emit_c_code (XSTR (split, 3), true, name, file);
+
+ /* Output code to copy the arguments back out of `operands' */
+ for (i = 0; i < stats.num_operand_vars; i++)
+ {
+- printf (" operand%d = operands[%d];\n", i, i);
+- printf (" (void) operand%d;\n", i);
++ fprintf (file, " operand%d = operands[%d];\n", i, i);
++ fprintf (file, " (void) operand%d;\n", i);
+ }
+
+- gen_emit_seq (XVEC (split, 2), used, info);
++ gen_emit_seq (XVEC (split, 2), used, info, file);
+
+ /* Call `get_insns' to make a list of all the
+ insns emitted within this gen_... function. */
+
+- printf (" _val = get_insns ();\n");
+- printf (" end_sequence ();\n");
+- printf (" return _val;\n}\n\n");
++ fprintf (file, " _val = get_insns ();\n");
++ fprintf (file, " end_sequence ();\n");
++ fprintf (file, " return _val;\n}\n\n");
+
+ free (used);
+ }
+@@ -645,37 +646,37 @@ gen_split (md_rtx_info *info)
+ the end of the vector. */
+
+ static void
+-output_add_clobbers (md_rtx_info *info)
++output_add_clobbers (md_rtx_info *info, FILE *file)
+ {
+ struct clobber_pat *clobber;
+ struct clobber_ent *ent;
+ int i;
+
+- printf ("\n\nvoid\nadd_clobbers (rtx pattern ATTRIBUTE_UNUSED, int insn_code_number)\n");
+- printf ("{\n");
+- printf (" switch (insn_code_number)\n");
+- printf (" {\n");
++ fprintf (file, "\n\nvoid\nadd_clobbers (rtx pattern ATTRIBUTE_UNUSED, int insn_code_number)\n");
++ fprintf (file, "{\n");
++ fprintf (file, " switch (insn_code_number)\n");
++ fprintf (file, " {\n");
+
+ for (clobber = clobber_list; clobber; clobber = clobber->next)
+ {
+ for (ent = clobber->insns; ent; ent = ent->next)
+- printf (" case %d:\n", ent->code_number);
++ fprintf (file, " case %d:\n", ent->code_number);
+
+ for (i = clobber->first_clobber; i < XVECLEN (clobber->pattern, 1); i++)
+ {
+- printf (" XVECEXP (pattern, 0, %d) = ", i);
++ fprintf (file, " XVECEXP (pattern, 0, %d) = ", i);
+ gen_exp (XVECEXP (clobber->pattern, 1, i),
+- GET_CODE (clobber->pattern), NULL, info);
+- printf (";\n");
++ GET_CODE (clobber->pattern), NULL, info, file);
++ fprintf (file, ";\n");
+ }
+
+- printf (" break;\n\n");
++ fprintf (file, " break;\n\n");
+ }
+
+- printf (" default:\n");
+- printf (" gcc_unreachable ();\n");
+- printf (" }\n");
+- printf ("}\n");
++ fprintf (file, " default:\n");
++ fprintf (file, " gcc_unreachable ();\n");
++ fprintf (file, " }\n");
++ fprintf (file, "}\n");
+ }
+
+ /* Write a function, `added_clobbers_hard_reg_p' that is given an insn_code
+@@ -684,16 +685,16 @@ output_add_clobbers (md_rtx_info *info)
+ SCRATCH. */
+
+ static void
+-output_added_clobbers_hard_reg_p (void)
++output_added_clobbers_hard_reg_p (FILE *file)
+ {
+ struct clobber_pat *clobber;
+ struct clobber_ent *ent;
+ int clobber_p, used;
+
+- printf ("\n\nint\nadded_clobbers_hard_reg_p (int insn_code_number)\n");
+- printf ("{\n");
+- printf (" switch (insn_code_number)\n");
+- printf (" {\n");
++ fprintf (file, "\n\nint\nadded_clobbers_hard_reg_p (int insn_code_number)\n");
++ fprintf (file, "{\n");
++ fprintf (file, " switch (insn_code_number)\n");
++ fprintf (file, " {\n");
+
+ for (clobber_p = 0; clobber_p <= 1; clobber_p++)
+ {
+@@ -702,25 +703,25 @@ output_added_clobbers_hard_reg_p (void)
+ if (clobber->has_hard_reg == clobber_p)
+ for (ent = clobber->insns; ent; ent = ent->next)
+ {
+- printf (" case %d:\n", ent->code_number);
++ fprintf (file, " case %d:\n", ent->code_number);
+ used++;
+ }
+
+ if (used)
+- printf (" return %d;\n\n", clobber_p);
++ fprintf (file, " return %d;\n\n", clobber_p);
+ }
+
+- printf (" default:\n");
+- printf (" gcc_unreachable ();\n");
+- printf (" }\n");
+- printf ("}\n");
++ fprintf (file, " default:\n");
++ fprintf (file, " gcc_unreachable ();\n");
++ fprintf (file, " }\n");
++ fprintf (file, "}\n");
+ }
+
+ /* Generate code to invoke find_free_register () as needed for the
+ scratch registers used by the peephole2 pattern in SPLIT. */
+
+ static void
+-output_peephole2_scratches (rtx split)
++output_peephole2_scratches (rtx split, FILE *file)
+ {
+ int i;
+ int insn_nr = 0;
+@@ -745,12 +746,12 @@ output_peephole2_scratches (rtx split)
+
+ if (first)
+ {
+- printf (" HARD_REG_SET _regs_allocated;\n");
+- printf (" CLEAR_HARD_REG_SET (_regs_allocated);\n");
++ fprintf (file, " HARD_REG_SET _regs_allocated;\n");
++ fprintf (file, " CLEAR_HARD_REG_SET (_regs_allocated);\n");
+ first = false;
+ }
+
+- printf (" if ((operands[%d] = peep2_find_free_register (%d, %d, \"%s\", %smode, &_regs_allocated)) == NULL_RTX)\n\
++ fprintf (file, " if ((operands[%d] = peep2_find_free_register (%d, %d, \"%s\", %smode, &_regs_allocated)) == NULL_RTX)\n\
+ return NULL;\n",
+ XINT (elt, 0),
+ insn_nr, last_insn_nr,
+@@ -766,50 +767,50 @@ output_peephole2_scratches (rtx split)
+ /* Print "arg<N>" parameter declarations for each argument N of ONAME. */
+
+ static void
+-print_overload_arguments (overloaded_name *oname)
++print_overload_arguments (overloaded_name *oname, FILE *file)
+ {
+ for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
+- printf ("%s%s arg%d", i == 0 ? "" : ", ", oname->arg_types[i], i);
++ fprintf (file, "%s%s arg%d", i == 0 ? "" : ", ", oname->arg_types[i], i);
+ }
+
+ /* Print code to test whether INSTANCE should be chosen, given that
+ argument N of the overload is available as "arg<N>". */
+
+ static void
+-print_overload_test (overloaded_instance *instance)
++print_overload_test (overloaded_instance *instance, FILE *file)
+ {
+ for (unsigned int i = 0; i < instance->arg_values.length (); ++i)
+- printf ("%sarg%d == %s", i == 0 ? " if (" : "\n && ",
++ fprintf (file, "%sarg%d == %s", i == 0 ? " if (" : "\n && ",
+ i, instance->arg_values[i]);
+- printf (")\n");
++ fprintf (file, ")\n");
+ }
+
+ /* Emit a maybe_code_for_* function for ONAME. */
+
+ static void
+-handle_overloaded_code_for (overloaded_name *oname)
++handle_overloaded_code_for (overloaded_name *oname, FILE *file)
+ {
+ /* Print the function prototype. */
+- printf ("\ninsn_code\nmaybe_code_for_%s (", oname->name);
+- print_overload_arguments (oname);
+- printf (")\n{\n");
++ fprintf (file, "\ninsn_code\nmaybe_code_for_%s (", oname->name);
++ print_overload_arguments (oname, file);
++ fprintf (file, ")\n{\n");
+
+ /* Use a sequence of "if" statements for each instance. */
+ for (overloaded_instance *instance = oname->first_instance;
+ instance; instance = instance->next)
+ {
+- print_overload_test (instance);
+- printf (" return CODE_FOR_%s;\n", instance->name);
++ print_overload_test (instance, file);
++ fprintf (file, " return CODE_FOR_%s;\n", instance->name);
+ }
+
+ /* Return null if no match was found. */
+- printf (" return CODE_FOR_nothing;\n}\n");
++ fprintf (file, " return CODE_FOR_nothing;\n}\n");
+ }
+
+ /* Emit a maybe_gen_* function for ONAME. */
+
+ static void
+-handle_overloaded_gen (overloaded_name *oname)
++handle_overloaded_gen (overloaded_name *oname, FILE *file)
+ {
+ unsigned HOST_WIDE_INT seen = 0;
+ /* All patterns must have the same number of operands. */
+@@ -826,25 +827,25 @@ handle_overloaded_gen (overloaded_name *oname)
+ seen |= mask;
+
+ /* Print the function prototype. */
+- printf ("\nrtx\nmaybe_gen_%s (", oname->name);
+- print_overload_arguments (oname);
++ fprintf (file, "\nrtx\nmaybe_gen_%s (", oname->name);
++ print_overload_arguments (oname, file);
+ for (int i = 0; i < stats.num_generator_args; ++i)
+- printf (", rtx x%d", i);
+- printf (")\n{\n");
++ fprintf (file, ", rtx x%d", i);
++ fprintf (file, ")\n{\n");
+
+ /* Use maybe_code_for_*, instead of duplicating the selection
+ logic here. */
+- printf (" insn_code code = maybe_code_for_%s (", oname->name);
++ fprintf (file, " insn_code code = maybe_code_for_%s (", oname->name);
+ for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
+- printf ("%sarg%d", i == 0 ? "" : ", ", i);
+- printf (");\n"
++ fprintf (file, "%sarg%d", i == 0 ? "" : ", ", i);
++ fprintf (file, ");\n"
+ " if (code != CODE_FOR_nothing)\n"
+ " {\n"
+ " gcc_assert (insn_data[code].n_generator_args == %d);\n"
+ " return GEN_FCN (code) (", stats.num_generator_args);
+ for (int i = 0; i < stats.num_generator_args; ++i)
+- printf ("%sx%d", i == 0 ? "" : ", ", i);
+- printf (");\n"
++ fprintf (file, "%sx%d", i == 0 ? "" : ", ", i);
++ fprintf (file, ");\n"
+ " }\n"
+ " else\n"
+ " return NULL_RTX;\n"
+@@ -852,12 +853,68 @@ handle_overloaded_gen (overloaded_name *oname)
+ }
+ }
+
++void
++print_header (FILE *file)
++{
++ fprintf (file, "/* Generated automatically by the program `genemit'\n\
++from the machine description file `md'. */\n\n");
++
++ fprintf (file, "#define IN_TARGET_CODE 1\n");
++ fprintf (file, "#include \"config.h\"\n");
++ fprintf (file, "#include \"system.h\"\n");
++ fprintf (file, "#include \"coretypes.h\"\n");
++ fprintf (file, "#include \"backend.h\"\n");
++ fprintf (file, "#include \"predict.h\"\n");
++ fprintf (file, "#include \"tree.h\"\n");
++ fprintf (file, "#include \"rtl.h\"\n");
++ fprintf (file, "#include \"alias.h\"\n");
++ fprintf (file, "#include \"varasm.h\"\n");
++ fprintf (file, "#include \"stor-layout.h\"\n");
++ fprintf (file, "#include \"calls.h\"\n");
++ fprintf (file, "#include \"memmodel.h\"\n");
++ fprintf (file, "#include \"tm_p.h\"\n");
++ fprintf (file, "#include \"flags.h\"\n");
++ fprintf (file, "#include \"insn-config.h\"\n");
++ fprintf (file, "#include \"expmed.h\"\n");
++ fprintf (file, "#include \"dojump.h\"\n");
++ fprintf (file, "#include \"explow.h\"\n");
++ fprintf (file, "#include \"emit-rtl.h\"\n");
++ fprintf (file, "#include \"stmt.h\"\n");
++ fprintf (file, "#include \"expr.h\"\n");
++ fprintf (file, "#include \"insn-codes.h\"\n");
++ fprintf (file, "#include \"optabs.h\"\n");
++ fprintf (file, "#include \"dfp.h\"\n");
++ fprintf (file, "#include \"output.h\"\n");
++ fprintf (file, "#include \"recog.h\"\n");
++ fprintf (file, "#include \"df.h\"\n");
++ fprintf (file, "#include \"resource.h\"\n");
++ fprintf (file, "#include \"reload.h\"\n");
++ fprintf (file, "#include \"diagnostic-core.h\"\n");
++ fprintf (file, "#include \"regs.h\"\n");
++ fprintf (file, "#include \"tm-constrs.h\"\n");
++ fprintf (file, "#include \"ggc.h\"\n");
++ fprintf (file, "#include \"target.h\"\n\n");
++}
++
++auto_vec<const char *, 10> output_files;
++
++static bool
++handle_arg (const char *arg)
++{
++ if (arg[1] == 'O')
++ {
++ output_files.safe_push (&arg[2]);
++ return true;
++ }
++ return false;
++}
++
+ int
+ main (int argc, const char **argv)
+ {
+ progname = "genemit";
+
+- if (!init_rtx_reader_args (argc, argv))
++ if (!init_rtx_reader_args_cb (argc, argv, handle_arg))
+ return (FATAL_EXIT_CODE);
+
+ #define DEF_INTERNAL_OPTAB_FN(NAME, FLAGS, OPTAB, TYPE) \
+@@ -867,86 +924,87 @@ main (int argc, const char **argv)
+ /* Assign sequential codes to all entries in the machine description
+ in parallel with the tables in insn-output.cc. */
+
+- printf ("/* Generated automatically by the program `genemit'\n\
+-from the machine description file `md'. */\n\n");
++ int npatterns = count_patterns ();
++ md_rtx_info info;
++
++ bool to_stdout = false;
++ int npatterns_per_file = npatterns;
++ if (!output_files.is_empty ())
++ npatterns_per_file = npatterns / output_files.length () + 1;
++ else
++ to_stdout = true;
+
+- printf ("#define IN_TARGET_CODE 1\n");
+- printf ("#include \"config.h\"\n");
+- printf ("#include \"system.h\"\n");
+- printf ("#include \"coretypes.h\"\n");
+- printf ("#include \"backend.h\"\n");
+- printf ("#include \"predict.h\"\n");
+- printf ("#include \"tree.h\"\n");
+- printf ("#include \"rtl.h\"\n");
+- printf ("#include \"alias.h\"\n");
+- printf ("#include \"varasm.h\"\n");
+- printf ("#include \"stor-layout.h\"\n");
+- printf ("#include \"calls.h\"\n");
+- printf ("#include \"memmodel.h\"\n");
+- printf ("#include \"tm_p.h\"\n");
+- printf ("#include \"flags.h\"\n");
+- printf ("#include \"insn-config.h\"\n");
+- printf ("#include \"expmed.h\"\n");
+- printf ("#include \"dojump.h\"\n");
+- printf ("#include \"explow.h\"\n");
+- printf ("#include \"emit-rtl.h\"\n");
+- printf ("#include \"stmt.h\"\n");
+- printf ("#include \"expr.h\"\n");
+- printf ("#include \"insn-codes.h\"\n");
+- printf ("#include \"optabs.h\"\n");
+- printf ("#include \"dfp.h\"\n");
+- printf ("#include \"output.h\"\n");
+- printf ("#include \"recog.h\"\n");
+- printf ("#include \"df.h\"\n");
+- printf ("#include \"resource.h\"\n");
+- printf ("#include \"reload.h\"\n");
+- printf ("#include \"diagnostic-core.h\"\n");
+- printf ("#include \"regs.h\"\n");
+- printf ("#include \"tm-constrs.h\"\n");
+- printf ("#include \"ggc.h\"\n");
+- printf ("#include \"target.h\"\n\n");
++ gcc_assert (npatterns_per_file > 1);
+
+- /* Read the machine description. */
++ /* Reverse so we can pop the first-added element. */
++ output_files.reverse ();
+
+- md_rtx_info info;
++ int count = 0;
++ FILE *file = NULL;
++
++ /* Read the machine description. */
+ while (read_md_rtx (&info))
+- switch (GET_CODE (info.def))
+- {
+- case DEFINE_INSN:
+- gen_insn (&info);
+- break;
++ {
++ if (count == 0 || count == npatterns_per_file)
++ {
++ bool is_last = !to_stdout && output_files.is_empty ();
++ if (file && !is_last)
++ if (fclose (file) != 0)
++ return FATAL_EXIT_CODE;
+
+- case DEFINE_EXPAND:
+- printf ("/* %s:%d */\n", info.loc.filename, info.loc.lineno);
+- gen_expand (&info);
+- break;
++ if (!output_files.is_empty ())
++ {
++ const char *const filename = output_files.pop ();
++ file = fopen (filename, "w");
++ }
++ else if (to_stdout)
++ file = stdout;
++ else
++ break;
+
+- case DEFINE_SPLIT:
+- printf ("/* %s:%d */\n", info.loc.filename, info.loc.lineno);
+- gen_split (&info);
+- break;
++ print_header (file);
++ count = 0;
++ }
+
+- case DEFINE_PEEPHOLE2:
+- printf ("/* %s:%d */\n", info.loc.filename, info.loc.lineno);
+- gen_split (&info);
+- break;
++ switch (GET_CODE (info.def))
++ {
++ case DEFINE_INSN:
++ gen_insn (&info, file);
++ break;
+
+- default:
+- break;
+- }
++ case DEFINE_EXPAND:
++ fprintf (file, "/* %s:%d */\n", info.loc.filename, info.loc.lineno);
++ gen_expand (&info, file);
++ break;
++
++ case DEFINE_SPLIT:
++ fprintf (file, "/* %s:%d */\n", info.loc.filename, info.loc.lineno);
++ gen_split (&info, file);
++ break;
++
++ case DEFINE_PEEPHOLE2:
++ fprintf (file, "/* %s:%d */\n", info.loc.filename, info.loc.lineno);
++ gen_split (&info, file);
++ break;
++
++ default:
++ break;
++ }
++
++ count++;
++ }
+
+ /* Write out the routines to add CLOBBERs to a pattern and say whether they
+ clobber a hard reg. */
+- output_add_clobbers (&info);
+- output_added_clobbers_hard_reg_p ();
++ output_add_clobbers (&info, file);
++ output_added_clobbers_hard_reg_p (file);
+
+ for (overloaded_name *oname = rtx_reader_ptr->get_overloads ();
+ oname; oname = oname->next)
+ {
+- handle_overloaded_code_for (oname);
+- handle_overloaded_gen (oname);
++ handle_overloaded_code_for (oname, file);
++ handle_overloaded_gen (oname, file);
+ }
+
+- fflush (stdout);
+- return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
++ return (fclose (file) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
+ }
+diff --git a/gcc/gensupport.cc b/gcc/gensupport.cc
+index f9efc6eb7572..f941f76a739f 100644
+--- a/gcc/gensupport.cc
++++ b/gcc/gensupport.cc
+@@ -2631,6 +2631,61 @@ init_rtx_reader_args (int argc, const char **argv)
+ return init_rtx_reader_args_cb (argc, argv, 0);
+ }
+
++/* Count the number of patterns in all queues and return the count. */
++int
++count_patterns ()
++{
++ int count = 0, truth = 1;
++ rtx def;
++ class queue_elem *cur = define_attr_queue;
++ while (cur)
++ {
++ def = cur->data;
++
++ truth = maybe_eval_c_test (get_c_test (def));
++ if (truth || !insn_elision)
++ count++;
++ cur = cur->next;
++ }
++
++ cur = define_pred_queue;
++ while (cur)
++ {
++ def = cur->data;
++
++ truth = maybe_eval_c_test (get_c_test (def));
++ if (truth || !insn_elision)
++ count++;
++ cur = cur->next;
++ }
++
++ cur = define_insn_queue;
++ truth = 1;
++ while (cur)
++ {
++ def = cur->data;
++
++ truth = maybe_eval_c_test (get_c_test (def));
++ if (truth || !insn_elision)
++ count++;
++ cur = cur->next;
++ }
++
++ cur = other_queue;
++ truth = 1;
++ while (cur)
++ {
++ def = cur->data;
++
++ truth = maybe_eval_c_test (get_c_test (def));
++ if (truth || !insn_elision)
++ count++;
++ cur = cur->next;
++ }
++
++ return count;
++}
++
+ /* Try to read a single rtx from the file. Return true on success,
+ describing it in *INFO. */
+
+diff --git a/gcc/gensupport.h b/gcc/gensupport.h
+index a1edfbd71908..510ba19405e4 100644
+--- a/gcc/gensupport.h
++++ b/gcc/gensupport.h
+@@ -129,6 +129,7 @@ extern rtx add_implicit_parallel (rtvec);
+ extern rtx_reader *init_rtx_reader_args_cb (int, const char **,
+ bool (*)(const char *));
+ extern rtx_reader *init_rtx_reader_args (int, const char **);
++extern int count_patterns ();
+ extern bool read_md_rtx (md_rtx_info *);
+ extern unsigned int get_num_insn_codes ();
+
+diff --git a/gcc/read-md.cc b/gcc/read-md.cc
+index fd38818e3a3e..46ab9065e3e4 100644
+--- a/gcc/read-md.cc
++++ b/gcc/read-md.cc
+@@ -132,9 +132,9 @@ md_reader::fprint_md_ptr_loc (FILE *outf, const void *ptr)
+
+ /* Special fprint_md_ptr_loc for writing to STDOUT. */
+ void
+-md_reader::print_md_ptr_loc (const void *ptr)
++md_reader::print_md_ptr_loc (const void *ptr, FILE *file)
+ {
+- fprint_md_ptr_loc (stdout, ptr);
++ fprint_md_ptr_loc (file, ptr);
+ }
+
+ /* Return a condition that satisfies both COND1 and COND2. Either string
+diff --git a/gcc/read-md.h b/gcc/read-md.h
+index b309c9c3deb6..2adcb58478fe 100644
+--- a/gcc/read-md.h
++++ b/gcc/read-md.h
+@@ -194,7 +194,7 @@ class md_reader
+ const struct ptr_loc *get_md_ptr_loc (const void *ptr);
+ void copy_md_ptr_loc (const void *new_ptr, const void *old_ptr);
+ void fprint_md_ptr_loc (FILE *outf, const void *ptr);
+- void print_md_ptr_loc (const void *ptr);
++ void print_md_ptr_loc (const void *ptr, FILE * = stdout);
+
+ struct enum_type *lookup_enum_type (const char *name);
+ void traverse_enum_types (htab_trav callback, void *info);
+--
+2.44.0
+
diff --git a/13.2.0/gentoo/91_all_riscv_PR106271-multilib-bootstrap.patch b/13.2.0/gentoo/91_all_riscv_PR106271-multilib-bootstrap.patch
new file mode 100644
index 0000000..2d2933f
--- /dev/null
+++ b/13.2.0/gentoo/91_all_riscv_PR106271-multilib-bootstrap.patch
@@ -0,0 +1,37 @@
+https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=47f95bc4be4eb14730ab3eaaaf8f6e71fda47690
+https://gcc.gnu.org/PR106271
+https://bugs.gentoo.org/890636
+
+From 976280d3fbfc5c1315befb36cebf07a6f1f0c518 Mon Sep 17 00:00:00 2001
+From: Raphael Moreira Zinsly <rzinsly@ventanamicro.com>
+Date: Tue, 22 Aug 2023 11:37:04 -0600
+Subject: [PATCH] RISC-V: Add multiarch support on riscv-linux-gnu
+
+This adds multiarch support to the RISC-V port so that bootstraps work with
+Debian out-of-the-box. Without this patch the stage1 compiler is unable to
+find headers/libraries when building the stage1 runtime.
+
+This is functionally (and possibly textually) equivalent to Debian's fix for
+the same problem.
+
+gcc/
+ * config/riscv/t-linux: Add MULTIARCH_DIRNAME.
+
+(cherry picked from commit 47f95bc4be4eb14730ab3eaaaf8f6e71fda47690)
+---
+ gcc/config/riscv/t-linux | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/gcc/config/riscv/t-linux b/gcc/config/riscv/t-linux
+index 216d2776a183..a6f64f88d25c 100644
+--- a/gcc/config/riscv/t-linux
++++ b/gcc/config/riscv/t-linux
+@@ -1,3 +1,5 @@
+ # Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/
+ MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES)))
+ MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES))
++
++MULTIARCH_DIRNAME := $(call if_multiarch,$(firstword $(subst -, ,$(target)))-linux-gnu)
+--
+2.44.0
+
diff --git a/13.2.0/gentoo/92_all_riscv_PR109760-gstreamer.patch b/13.2.0/gentoo/92_all_riscv_PR109760-gstreamer.patch
new file mode 100644
index 0000000..ef79d70
--- /dev/null
+++ b/13.2.0/gentoo/92_all_riscv_PR109760-gstreamer.patch
@@ -0,0 +1,337 @@
+https://bugs.gentoo.org/928234
+https://gcc.gnu.org/PR109760
+https://gcc.gnu.org/PR110095
+https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=55914b016de8c8514c58eb59822677a69e44135c
+
+From 55914b016de8c8514c58eb59822677a69e44135c Mon Sep 17 00:00:00 2001
+From: Die Li <lidie@eswincomputing.com>
+Date: Fri, 19 May 2023 23:00:13 -0600
+Subject: [PATCH] Fix riscv_expand_conditional_move.
+
+Two issues have been observed in current riscv_expand_conditional_move
+implementation.
+1. Before introduction of TARGET_XTHEADCONDMOV, op0 of comparision expression
+is used for mode comparision with word_mode, but after TARGET_XTHEADCONDMOV
+megered with TARGET_SFB_ALU, dest of if-then-else is used for mode comparision with
+word_mode, and from md file mode of dest is DI or SI which can be different with
+word_mode in RV64.
+
+2. TARGET_XTHEADCONDMOV cannot be generated when the mode of the comparison is E_VOID.
+
+This patch solves the issues above.
+
+Provide an example from the newly added test case.
+
+Testcase:
+int ConNmv_reg_reg_reg(int x, int y, int z, int n){
+ if (x != y) return z;
+ return n;
+}
+
+Cflags:
+-O2 -march=rv64gc_xtheadcondmov -mabi=lp64d
+
+before patch:
+ConNmv_reg_reg_reg:
+ bne a0,a1,.L23
+ mv a2,a3
+.L23:
+ mv a0,a2
+ ret
+
+after patch:
+ConNmv_reg_reg_reg:
+ sub a1,a0,a1
+ th.mveqz a2,zero,a1
+ th.mvnez a3,zero,a1
+ or a0,a2,a3
+ ret
+
+Co-Authored by: Fei Gao <gaofei@eswincomputing.com>
+Signed-off-by: Die Li <lidie@eswincomputing.com>
+
+gcc/ChangeLog:
+
+ * config/riscv/riscv.cc (riscv_expand_conditional_move): Fix mode
+ checking.
+
+gcc/testsuite/ChangeLog:
+
+ * gcc.target/riscv/xtheadcondmov-indirect-rv32.c: New test.
+ * gcc.target/riscv/xtheadcondmov-indirect-rv64.c: New test.
+---
+ gcc/config/riscv/riscv.cc | 4 +-
+ .../riscv/xtheadcondmov-indirect-rv32.c | 116 ++++++++++++++++++
+ .../riscv/xtheadcondmov-indirect-rv64.c | 116 ++++++++++++++++++
+ 3 files changed, 234 insertions(+), 2 deletions(-)
+ create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadcondmov-indirect-rv32.c
+ create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadcondmov-indirect-rv64.c
+
+diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
+index 2a7b43849e5..7bb38978261 100644
+--- a/gcc/config/riscv/riscv.cc
++++ b/gcc/config/riscv/riscv.cc
+@@ -3488,7 +3488,7 @@ riscv_expand_conditional_move (rtx dest, rtx op, rtx cons, rtx alt)
+ && GET_MODE_CLASS (mode) == MODE_INT
+ && reg_or_0_operand (cons, mode)
+ && reg_or_0_operand (alt, mode)
+- && GET_MODE (op) == mode
++ && (GET_MODE (op) == mode || GET_MODE (op) == E_VOIDmode)
+ && GET_MODE (op0) == mode
+ && GET_MODE (op1) == mode
+ && (code == EQ || code == NE))
+@@ -3497,7 +3497,7 @@ riscv_expand_conditional_move (rtx dest, rtx op, rtx cons, rtx alt)
+ return true;
+ }
+ else if (TARGET_SFB_ALU
+- && mode == word_mode)
++ && GET_MODE (op0) == word_mode)
+ {
+ riscv_emit_int_compare (&code, &op0, &op1);
+ rtx cond = gen_rtx_fmt_ee (code, GET_MODE (op0), op0, op1);
+diff --git a/gcc/testsuite/gcc.target/riscv/xtheadcondmov-indirect-rv32.c b/gcc/testsuite/gcc.target/riscv/xtheadcondmov-indirect-rv32.c
+new file mode 100644
+index 00000000000..9afdc2eabfd
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/riscv/xtheadcondmov-indirect-rv32.c
+@@ -0,0 +1,116 @@
++/* { dg-do compile } */
++/* { dg-options "-O2 -march=rv32gc_xtheadcondmov -mabi=ilp32 -mriscv-attribute" } */
++/* { dg-skip-if "" { *-*-* } { "-O0" "-Os" "-Og" } } */
++/* { dg-final { check-function-bodies "**" "" } } */
++
++/*
++**ConEmv_imm_imm_reg:
++** addi a5,a0,-1000
++** li a0,10
++** th.mvnez a0,zero,a5
++** th.mveqz a1,zero,a5
++** or a0,a0,a1
++** ret
++*/
++int ConEmv_imm_imm_reg(int x, int y){
++ if (x == 1000) return 10;
++ return y;
++}
++
++/*
++**ConEmv_imm_reg_reg:
++** addi a5,a0,-1000
++** th.mvnez a1,zero,a5
++** th.mveqz a2,zero,a5
++** or a0,a1,a2
++** ret
++*/
++int ConEmv_imm_reg_reg(int x, int y, int z){
++ if (x == 1000) return y;
++ return z;
++}
++
++/*
++**ConEmv_reg_imm_reg:
++** sub a1,a0,a1
++** li a0,10
++** th.mvnez a0,zero,a1
++** th.mveqz a2,zero,a1
++** or a0,a0,a2
++** ret
++*/
++int ConEmv_reg_imm_reg(int x, int y, int z){
++ if (x == y) return 10;
++ return z;
++}
++
++/*
++**ConEmv_reg_reg_reg:
++** sub a1,a0,a1
++** th.mvnez a2,zero,a1
++** th.mveqz a3,zero,a1
++** or a0,a2,a3
++** ret
++*/
++int ConEmv_reg_reg_reg(int x, int y, int z, int n){
++ if (x == y) return z;
++ return n;
++}
++
++/*
++**ConNmv_imm_imm_reg:
++** li a5,9998336
++** addi a4,a0,-1000
++** addi a5,a5,1664
++** th.mvnez a1,zero,a4
++** th.mveqz a5,zero,a4
++** or a0,a1,a5
++** ret
++*/
++int ConNmv_imm_imm_reg(int x, int y){
++ if (x != 1000) return 10000000;
++ return y;
++}
++
++/*
++**ConNmv_imm_reg_reg:
++** addi a5,a0,-1000
++** th.mveqz a1,zero,a5
++** th.mvnez a2,zero,a5
++** or a0,a1,a2
++** ret
++*/
++int ConNmv_imm_reg_reg(int x, int y, int z){
++ if (x != 1000) return y;
++ return z;
++}
++
++/*
++**ConNmv_reg_imm_reg:
++** sub a1,a0,a1
++** li a0,10
++** th.mveqz a0,zero,a1
++** th.mvnez a2,zero,a1
++** or a0,a0,a2
++** ret
++*/
++int ConNmv_reg_imm_reg(int x, int y, int z){
++ if (x != y) return 10;
++ return z;
++}
++
++/*
++**ConNmv_reg_reg_reg:
++** sub a1,a0,a1
++** th.mveqz a2,zero,a1
++** th.mvnez a3,zero,a1
++** or a0,a2,a3
++** ret
++*/
++int ConNmv_reg_reg_reg(int x, int y, int z, int n){
++ if (x != y) return z;
++ return n;
++}
++
++
++/* { dg-final { scan-assembler ".attribute arch, \"rv32i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_xtheadcondmov1p0\"" } } */
+diff --git a/gcc/testsuite/gcc.target/riscv/xtheadcondmov-indirect-rv64.c b/gcc/testsuite/gcc.target/riscv/xtheadcondmov-indirect-rv64.c
+new file mode 100644
+index 00000000000..a1982fd90bd
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/riscv/xtheadcondmov-indirect-rv64.c
+@@ -0,0 +1,116 @@
++/* { dg-do compile } */
++/* { dg-options "-O2 -march=rv64gc_xtheadcondmov -mabi=lp64d -mriscv-attribute" } */
++/* { dg-skip-if "" { *-*-* } { "-O0" "-Os" "-Og" } } */
++/* { dg-final { check-function-bodies "**" "" } } */
++
++/*
++**ConEmv_imm_imm_reg:
++** addi a5,a0,-1000
++** li a0,10
++** th.mvnez a0,zero,a5
++** th.mveqz a1,zero,a5
++** or a0,a0,a1
++** ret
++*/
++int ConEmv_imm_imm_reg(int x, int y){
++ if (x == 1000) return 10;
++ return y;
++}
++
++/*
++**ConEmv_imm_reg_reg:
++** addi a5,a0,-1000
++** th.mvnez a1,zero,a5
++** th.mveqz a2,zero,a5
++** or a0,a1,a2
++** ret
++*/
++int ConEmv_imm_reg_reg(int x, int y, int z){
++ if (x == 1000) return y;
++ return z;
++}
++
++/*
++**ConEmv_reg_imm_reg:
++** sub a1,a0,a1
++** li a0,10
++** th.mvnez a0,zero,a1
++** th.mveqz a2,zero,a1
++** or a0,a0,a2
++** ret
++*/
++int ConEmv_reg_imm_reg(int x, int y, int z){
++ if (x == y) return 10;
++ return z;
++}
++
++/*
++**ConEmv_reg_reg_reg:
++** sub a1,a0,a1
++** th.mvnez a2,zero,a1
++** th.mveqz a3,zero,a1
++** or a0,a2,a3
++** ret
++*/
++int ConEmv_reg_reg_reg(int x, int y, int z, int n){
++ if (x == y) return z;
++ return n;
++}
++
++/*
++**ConNmv_imm_imm_reg:
++** li a5,9998336
++** addi a4,a0,-1000
++** addi a5,a5,1664
++** th.mvnez a1,zero,a4
++** th.mveqz a5,zero,a4
++** or a0,a1,a5
++** ret
++*/
++int ConNmv_imm_imm_reg(int x, int y){
++ if (x != 1000) return 10000000;
++ return y;
++}
++
++/*
++**ConNmv_imm_reg_reg:
++** addi a5,a0,-1000
++** th.mveqz a1,zero,a5
++** th.mvnez a2,zero,a5
++** or a0,a1,a2
++** ret
++*/
++int ConNmv_imm_reg_reg(int x, int y, int z){
++ if (x != 1000) return y;
++ return z;
++}
++
++/*
++**ConNmv_reg_imm_reg:
++** sub a1,a0,a1
++** li a0,10
++** th.mveqz a0,zero,a1
++** th.mvnez a2,zero,a1
++** or a0,a0,a2
++** ret
++*/
++int ConNmv_reg_imm_reg(int x, int y, int z){
++ if (x != y) return 10;
++ return z;
++}
++
++/*
++**ConNmv_reg_reg_reg:
++** sub a1,a0,a1
++** th.mveqz a2,zero,a1
++** th.mvnez a3,zero,a1
++** or a0,a2,a3
++** ret
++*/
++int ConNmv_reg_reg_reg(int x, int y, int z, int n){
++ if (x != y) return z;
++ return n;
++}
++
++
++/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_xtheadcondmov1p0\"" } } */
+--
+2.39.3
diff --git a/13.2.0/gentoo/README.history b/13.2.0/gentoo/README.history
new file mode 100644
index 0000000..26583a8
--- /dev/null
+++ b/13.2.0/gentoo/README.history
@@ -0,0 +1,119 @@
+15 7 Apr 2024
+
+ - 50_all_PR111632_system_cxx_headers_libcxx.patch
+ U 76_all_match.pd-don-t-emit-label-if-not-needed.patch
+ U 77_all_match.pd-Remove-commented-out-line-pragmas-unless-vv.patch
+ U 78_all_match.pd-CSE-the-dump-output-check.patch
+ U 79_all_genmatch-split-shared-code-to-gimple-match-exports.c.patch
+ U 80_all_match.pd-automatically-partition-match.cc-files.patch
+ U 81_all_match.pd-Use-splits-in-makefile-and-make-configurabl.patch
+ U 82_all_Makefile.in-clean-up-match.pd-related-dependencies.patch
+ U 86_all_build-Replace-seq-for-portability-with-GNU-Make-vari.patch
+ U 87_all_Remove-DEFAULT_MATCHPD_PARTITIONS-macro.patch
+ U 88_all_Makefile.in-Make-TM_P_H-depend-on-TREE_H-PR111021.patch
+ U 89_all_Makefile.in-Make-recog.h-depend-on-TREE_H-PR111021.patch
+ U 90_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch
+ + 92_all_riscv_PR109760-gstreamer.patch
+
+14 28 Feb 2024
+
+ + 91_all_riscv_PR106271-multilib-bootstrap.patch
+
+13 12 Feb 2024
+
+ - 91_all_PR113258_libstdc-Prefer-posix_memalign-for-aligned-new.patch
+
+12 17 Jan 2024
+
+ + 91_all_PR113258_libstdc-Prefer-posix_memalign-for-aligned-new.patch
+
+11 3 Dec 2023
+
+ U 76_all_match.pd-don-t-emit-label-if-not-needed.patch
+ U 77_all_match.pd-Remove-commented-out-line-pragmas-unless-vv.patch
+ U 78_all_match.pd-CSE-the-dump-output-check.patch
+ U 79_all_genmatch-split-shared-code-to-gimple-match-exports.c.patch
+ U 80_all_match.pd-automatically-partition-match.cc-files.patch
+ U 81_all_match.pd-Use-splits-in-makefile-and-make-configurabl.patch
+ U 87_all_Remove-DEFAULT_MATCHPD_PARTITIONS-macro.patch
+ U 88_all_Makefile.in-Make-TM_P_H-depend-on-TREE_H-PR111021.patch
+ U 89_all_Makefile.in-Make-recog.h-depend-on-TREE_H-PR111021.patch
+ U 90_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch
+ + 82_all_Makefile.in-clean-up-match.pd-related-dependencies.patch
+
+10 28 Oct 2023
+
+ U 90_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch
+
+9 16 Oct 2023
+
+ + 86_all_build-Replace-seq-for-portability-with-GNU-Make-vari.patch
+ + 87_all_Remove-DEFAULT_MATCHPD_PARTITIONS-macro.patch
+ + 88_all_Makefile.in-Make-TM_P_H-depend-on-TREE_H-PR111021.patch
+ + 89_all_Makefile.in-Make-recog.h-depend-on-TREE_H-PR111021.patch
+ + 90_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch
+
+8 1 Oct 2023
+
+ U 31_all_gm2_make_P_var.patch
+ + 50_all_system_cxx_headers_libcxx.patch
+ - 83_all_all_PR110315_crash_large_std_vector.patch
+
+7 13 Aug 2023
+ + 85_all_x86_PR110792-Early-clobber-issues-with-rot32di2-test-fixup.patch
+
+6 13 Aug 2023
+ + 84_all_x86_PR110792-Early-clobber-issues-with-rot32di2.patch
+
+5 05 Aug 2023
+ - 82_all_arm64_PR110280_ICE_fold-const.patch
+
+4 30 Jul 2023
+
+ U 31_all_gm2_make_P_var.patch
+ + 82_all_arm64_PR110280_ICE_fold-const.patch
+ + 83_all_all_PR110315_crash_large_std_vector.patch
+
+3 26 May 2023
+
+ + 76_all_match.pd-don-t-emit-label-if-not-needed.patch
+ + 77_all_match.pd-Remove-commented-out-line-pragmas-unless-vv.patch
+ + 78_all_match.pd-CSE-the-dump-output-check.patch
+ + 79_all_genmatch-split-shared-code-to-gimple-match-exports.c.patch
+ + 80_all_match.pd-automatically-partition-match.cc-files.patch
+ + 81_all_match.pd-Use-splits-in-makefile-and-make-configurabl.patch
+
+2 29 Apr 2023
+
+ - 75_all_all_PR109573_13_ICE-in-vectorizable_live_operation.patch
+ - 76_all_all_PR109585_13_rtl-alias-analysis-typo.patch
+ - 77_all_all_PR109609_13_tail-call-fnspec.patch
+
+1 26 April 2023
+
+ + 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
+ + 07_all_libiberty-asprintf.patch
+ + 08_all_libiberty-pic.patch
+ + 09_all_nopie-all-flags.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
+ + 25_all_lto-intl-workaround-PR95194.patch
+ + 26_all_enable-cet.patch
+ + 28_all_drop_CFLAGS_sed.patch
+ + 29_all_msgfmt-libstdc++-link.patch
+ + 30_all_tar_libstdc++-link.patch
+ + 31_all_gm2_make_P_var.patch
+ + 75_all_all_PR109573_13_ICE-in-vectorizable_live_operation.patch
+ + 76_all_all_PR109585_13_rtl-alias-analysis-typo.patch
+ + 77_all_all_PR109609_13_tail-call-fnspec.patch
diff --git a/13.2.0/musl/25_all_multilib_pure64.patch b/13.2.0/musl/25_all_multilib_pure64.patch
new file mode 100644
index 0000000..d55c04c
--- /dev/null
+++ b/13.2.0/musl/25_all_multilib_pure64.patch
@@ -0,0 +1,83 @@
+https://bugs.gentoo.org/675954
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90077
+
+--- a/gcc/config/aarch64/t-aarch64-linux
++++ b/gcc/config/aarch64/t-aarch64-linux
+@@ -22,7 +22,7 @@
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+--- a/gcc/config/i386/t-linux64
++++ b/gcc/config/i386/t-linux64
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
+-MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
++MULTILIB_OSDIRNAMES+= mx32=../libx32
+--- a/gcc/config/rs6000/t-linux
++++ b/gcc/config/rs6000/t-linux
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+
+--- a/gcc/config/rs6000/t-linux64
++++ b/gcc/config/rs6000/t-linux64
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS := m64/m32
+ MULTILIB_DIRNAMES := 64 32
+ MULTILIB_EXTRA_OPTS :=
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ $(COMPILE) $<
+--- a/gcc/config/rs6000/t-linux64bele
++++ b/gcc/config/rs6000/t-linux64bele
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mlittle
+ MULTILIB_DIRNAMES += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/rs6000/t-linux64lebe
++++ b/gcc/config/rs6000/t-linux64lebe
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mbig
+ MULTILIB_DIRNAMES += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
diff --git a/13.2.0/musl/50_all_cpu_indicator.patch b/13.2.0/musl/50_all_cpu_indicator.patch
new file mode 100644
index 0000000..52e8b92
--- /dev/null
+++ b/13.2.0/musl/50_all_cpu_indicator.patch
@@ -0,0 +1,37 @@
+https://gcc.gnu.org/pipermail/gcc-patches/2023-February/612648.html
+
+From d16a8ceb1c3c8a7ec381090b4c316ff4c55661c0 Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 7 May 2020 21:14:11 -0500
+Subject: [PATCH] convert "__cpu_indicator_init" to
+ "__cpu_indicator_init_local"
+
+--- a/gcc/config/i386/i386-expand.cc
++++ b/gcc/config/i386/i386-expand.cc
+@@ -12338,10 +12338,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
+ {
+ case IX86_BUILTIN_CPU_INIT:
+ {
+- /* Make it call __cpu_indicator_init in libgcc. */
++ /* Make it call __cpu_indicator_init_local in libgcc. */
+ tree call_expr, fndecl, type;
+ type = build_function_type_list (integer_type_node, NULL_TREE);
+- fndecl = build_fn_decl ("__cpu_indicator_init", type);
++ fndecl = build_fn_decl ("__cpu_indicator_init_local", type);
+ call_expr = build_call_expr (fndecl, 0);
+ return expand_expr (call_expr, target, mode, EXPAND_NORMAL);
+ }
+
+--- a/libgcc/config/i386/cpuinfo.c
++++ b/libgcc/config/i386/cpuinfo.c
+@@ -508,7 +508,7 @@ __cpu_indicator_init (void)
+ return 0;
+ }
+
+-#if defined SHARED && defined USE_ELF_SYMVER
+-__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0");
+-__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0");
++#ifndef SHARED
++int __cpu_indicator_init_local (void)
++ __attribute__ ((weak, alias ("__cpu_indicator_init")));
+ #endif
diff --git a/13.2.0/musl/50_all_libssp_unconditionally.patch b/13.2.0/musl/50_all_libssp_unconditionally.patch
new file mode 100644
index 0000000..a3b5984
--- /dev/null
+++ b/13.2.0/musl/50_all_libssp_unconditionally.patch
@@ -0,0 +1,24 @@
+https://bugs.gentoo.org/706210
+https://bugs.gentoo.org/747346
+
+Author: Timo Teräs <timo.teras@iki.fi>
+
+"Alpine musl package provides libssp_nonshared.a. We link to it unconditionally,
+as otherwise we get link failures if some objects are -fstack-protector built
+and final link happens with -fno-stack-protector. This seems to be the common
+case when bootstrapping gcc, the piepatches do not seem to fully fix the
+crosstoolchain and bootstrap sequence wrt. stack-protector flag usage."
+
+(We do the same in Gentoo.)
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -870,8 +870,7 @@
+
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+- "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ "|fstack-protector-strong|fstack-protector-explicit" \
diff --git a/13.2.0/musl/50_all_posix_memalign.patch b/13.2.0/musl/50_all_posix_memalign.patch
new file mode 100644
index 0000000..dd75a93
--- /dev/null
+++ b/13.2.0/musl/50_all_posix_memalign.patch
@@ -0,0 +1,28 @@
+--- a/gcc/config/i386/pmm_malloc.h
++++ b/gcc/config/i386/pmm_malloc.h
+@@ -27,12 +27,13 @@
+ #include <stdlib.h>
+
+ /* We can't depend on <stdlib.h> since the prototype of posix_memalign
+- may not be visible. */
++ may not be visible and we can't pollute the namespace either. */
+ #ifndef __cplusplus
+-extern int posix_memalign (void **, size_t, size_t);
++extern int __gcc_posix_memalign (void **, size_t, size_t)
+ #else
+-extern "C" int posix_memalign (void **, size_t, size_t) throw ();
++extern "C" int __gcc_posix_memalign (void **, size_t, size_t) throw ()
+ #endif
++__asm__("posix_memalign");
+
+ static __inline void *
+ _mm_malloc (size_t __size, size_t __alignment)
+@@ -42,7 +43,7 @@
+ return malloc (__size);
+ if (__alignment == 2 || (sizeof (void *) == 8 && __alignment == 4))
+ __alignment = sizeof (void *);
+- if (posix_memalign (&__ptr, __alignment, __size) == 0)
++ if (__gcc_posix_memalign (&__ptr, __alignment, __size) == 0)
+ return __ptr;
+ else
+ return NULL;
diff --git a/13.2.0/musl/50_all_sanitizer_lfs.patch b/13.2.0/musl/50_all_sanitizer_lfs.patch
new file mode 100644
index 0000000..65baea2
--- /dev/null
+++ b/13.2.0/musl/50_all_sanitizer_lfs.patch
@@ -0,0 +1,197 @@
+https://bugs.gentoo.org/900871
+https://reviews.llvm.org/D141186
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109533
+https://github.com/llvm/llvm-project/commit/a5519b99bc73d50f362d6fb306411e9fcb758b53
+--- a/libsanitizer/interception/interception_type_test.cpp
++++ b/libsanitizer/interception/interception_type_test.cpp
+@@ -24,9 +24,9 @@ COMPILER_CHECK(sizeof(::SSIZE_T) == sizeof(ssize_t));
+ COMPILER_CHECK(sizeof(::PTRDIFF_T) == sizeof(ptrdiff_t));
+ COMPILER_CHECK(sizeof(::INTMAX_T) == sizeof(intmax_t));
+
+-#if !SANITIZER_APPLE
++# if SANITIZER_GLIBC || SANITIZER_ANDROID
+ COMPILER_CHECK(sizeof(::OFF64_T) == sizeof(off64_t));
+-#endif
++# endif
+
+ // The following are the cases when pread (and friends) is used instead of
+ // pread64. In those cases we need OFF_T to match off_t. We don't care about the
+--- a/libsanitizer/sanitizer_common/sanitizer_common_syscalls.inc
++++ b/libsanitizer/sanitizer_common/sanitizer_common_syscalls.inc
+@@ -910,24 +910,26 @@ POST_SYSCALL(statfs)(long res, const void *path, void *buf) {
+ }
+ }
+
+-PRE_SYSCALL(statfs64)(const void *path, long sz, void *buf) {
+- if (path)
+- PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
+-}
++PRE_SYSCALL(fstatfs)(long fd, void *buf) {}
+
+-POST_SYSCALL(statfs64)(long res, const void *path, long sz, void *buf) {
++POST_SYSCALL(fstatfs)(long res, long fd, void *buf) {
+ if (res >= 0) {
+ if (buf)
+- POST_WRITE(buf, struct_statfs64_sz);
++ POST_WRITE(buf, struct_statfs_sz);
+ }
+ }
++# endif // !SANITIZER_ANDROID
+
+-PRE_SYSCALL(fstatfs)(long fd, void *buf) {}
++# if SANITIZER_GLIBC
++PRE_SYSCALL(statfs64)(const void *path, long sz, void *buf) {
++ if (path)
++ PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
++}
+
+-POST_SYSCALL(fstatfs)(long res, long fd, void *buf) {
++POST_SYSCALL(statfs64)(long res, const void *path, long sz, void *buf) {
+ if (res >= 0) {
+ if (buf)
+- POST_WRITE(buf, struct_statfs_sz);
++ POST_WRITE(buf, struct_statfs64_sz);
+ }
+ }
+
+@@ -939,7 +941,7 @@ POST_SYSCALL(fstatfs64)(long res, long fd, long sz, void *buf) {
+ POST_WRITE(buf, struct_statfs64_sz);
+ }
+ }
+-# endif // !SANITIZER_ANDROID
++# endif // SANITIZER_GLIBC
+
+ PRE_SYSCALL(lstat)(const void *filename, void *statbuf) {
+ if (filename)
+@@ -998,7 +1000,7 @@ POST_SYSCALL(newfstat)(long res, long fd, void *statbuf) {
+ }
+ }
+
+-# if !SANITIZER_ANDROID
++# if SANITIZER_GLIBC
+ PRE_SYSCALL(ustat)(long dev, void *ubuf) {}
+
+ POST_SYSCALL(ustat)(long res, long dev, void *ubuf) {
+@@ -1007,7 +1009,7 @@ POST_SYSCALL(ustat)(long res, long dev, void *ubuf) {
+ POST_WRITE(ubuf, struct_ustat_sz);
+ }
+ }
+-# endif // !SANITIZER_ANDROID
++# endif // SANITIZER_GLIBC
+
+ PRE_SYSCALL(stat64)(const void *filename, void *statbuf) {
+ if (filename)
+@@ -2228,7 +2230,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) {
+ }
+ }
+
+-# if !SANITIZER_ANDROID
++# if SANITIZER_GLIBC
+ PRE_SYSCALL(prlimit64)
+ (long pid, long resource, const void *new_rlim, void *old_rlim) {
+ if (new_rlim)
+--- a/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h
++++ b/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h
+@@ -269,7 +269,7 @@
+ #define SANITIZER_INTERCEPT_INET_ATON SI_POSIX
+ #define SANITIZER_INTERCEPT_SYSINFO SI_LINUX
+ #define SANITIZER_INTERCEPT_READDIR SI_POSIX
+-#define SANITIZER_INTERCEPT_READDIR64 SI_LINUX_NOT_ANDROID || SI_SOLARIS32
++#define SANITIZER_INTERCEPT_READDIR64 SI_GLIBC || SI_SOLARIS32
+ #if SI_LINUX_NOT_ANDROID && \
+ (defined(__i386) || defined(__x86_64) || defined(__mips64) || \
+ defined(__powerpc64__) || defined(__aarch64__) || defined(__arm__) || \
+@@ -308,7 +308,7 @@
+ #define SANITIZER_INTERCEPT_XPG_STRERROR_R SI_LINUX_NOT_ANDROID
+ #define SANITIZER_INTERCEPT_SCANDIR \
+ (SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS)
+-#define SANITIZER_INTERCEPT_SCANDIR64 SI_LINUX_NOT_ANDROID || SI_SOLARIS32
++#define SANITIZER_INTERCEPT_SCANDIR64 SI_GLIBC || SI_SOLARIS32
+ #define SANITIZER_INTERCEPT_GETGROUPS SI_POSIX
+ #define SANITIZER_INTERCEPT_POLL SI_POSIX
+ #define SANITIZER_INTERCEPT_PPOLL SI_LINUX_NOT_ANDROID || SI_SOLARIS
+@@ -330,10 +330,10 @@
+ #define SANITIZER_INTERCEPT_GETMNTENT_R SI_LINUX_NOT_ANDROID
+ #define SANITIZER_INTERCEPT_STATFS \
+ (SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID || SI_SOLARIS)
+-#define SANITIZER_INTERCEPT_STATFS64 SI_LINUX_NOT_ANDROID && SANITIZER_HAS_STATFS64
++#define SANITIZER_INTERCEPT_STATFS64 SI_GLIBC && SANITIZER_HAS_STATFS64
+ #define SANITIZER_INTERCEPT_STATVFS \
+ (SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID)
+-#define SANITIZER_INTERCEPT_STATVFS64 SI_LINUX_NOT_ANDROID
++#define SANITIZER_INTERCEPT_STATVFS64 SI_GLIBC
+ #define SANITIZER_INTERCEPT_INITGROUPS SI_POSIX
+ #define SANITIZER_INTERCEPT_ETHER_NTOA_ATON SI_POSIX
+ #define SANITIZER_INTERCEPT_ETHER_HOST \
+@@ -471,9 +471,9 @@
+ #define SANITIZER_INTERCEPT_LSTAT (SI_NETBSD || SI_FREEBSD || SI_STAT_LINUX)
+ #define SANITIZER_INTERCEPT___XSTAT \
+ ((!SANITIZER_INTERCEPT_STAT && SI_POSIX) || SI_STAT_LINUX)
+-#define SANITIZER_INTERCEPT___XSTAT64 SI_LINUX_NOT_ANDROID
++#define SANITIZER_INTERCEPT___XSTAT64 SI_GLIBC
+ #define SANITIZER_INTERCEPT___LXSTAT SANITIZER_INTERCEPT___XSTAT
+-#define SANITIZER_INTERCEPT___LXSTAT64 SI_LINUX_NOT_ANDROID
++#define SANITIZER_INTERCEPT___LXSTAT64 SI_GLIBC
+
+ #define SANITIZER_INTERCEPT_UTMP \
+ (SI_POSIX && !SI_MAC && !SI_FREEBSD && !SI_NETBSD)
+@@ -484,7 +484,7 @@
+ (SI_LINUX_NOT_ANDROID || SI_MAC || SI_FREEBSD || SI_NETBSD)
+
+ #define SANITIZER_INTERCEPT_MMAP SI_POSIX
+-#define SANITIZER_INTERCEPT_MMAP64 SI_LINUX_NOT_ANDROID || SI_SOLARIS
++#define SANITIZER_INTERCEPT_MMAP64 SI_GLIBC || SI_SOLARIS
+ #define SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO (SI_GLIBC || SI_ANDROID)
+ #define SANITIZER_INTERCEPT_MEMALIGN (!SI_FREEBSD && !SI_MAC && !SI_NETBSD)
+ #define SANITIZER_INTERCEPT___LIBC_MEMALIGN SI_GLIBC
+--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
+@@ -260,7 +260,7 @@ namespace __sanitizer {
+ unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
+ #endif // SANITIZER_LINUX
+
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_GLIBC
+ // Use pre-computed size of struct ustat to avoid <sys/ustat.h> which
+ // has been removed from glibc 2.28.
+ #if defined(__aarch64__) || defined(__s390x__) || defined(__mips64) || \
+@@ -281,7 +281,7 @@ namespace __sanitizer {
+ unsigned struct_ustat_sz = SIZEOF_STRUCT_USTAT;
+ unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
+ unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
+-#endif // SANITIZER_LINUX && !SANITIZER_ANDROID
++#endif // SANITIZER_GLIBC
+
+ #if SANITIZER_INTERCEPT_CRYPT_R
+ unsigned struct_crypt_data_sz = sizeof(struct crypt_data);
+@@ -1089,7 +1089,7 @@ CHECK_SIZE_AND_OFFSET(dirent, d_off);
+ #endif
+ CHECK_SIZE_AND_OFFSET(dirent, d_reclen);
+
+-#if SANITIZER_LINUX && !SANITIZER_ANDROID
++#if SANITIZER_GLIBC
+ COMPILER_CHECK(sizeof(__sanitizer_dirent64) <= sizeof(dirent64));
+ CHECK_SIZE_AND_OFFSET(dirent64, d_ino);
+ CHECK_SIZE_AND_OFFSET(dirent64, d_off);
+--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
+@@ -28,8 +28,7 @@
+ #define SANITIZER_HAS_STAT64 0
+ #define SANITIZER_HAS_STATFS64 0
+ #endif
+-#else
+-// Must be SANITIZER_LINUX then
++#elif SANITIZER_GLIBC || SANITIZER_ANDROID
+ #define SANITIZER_HAS_STAT64 1
+ #define SANITIZER_HAS_STATFS64 1
+ #endif
+@@ -517,7 +516,7 @@ struct __sanitizer_dirent {
+ };
+ # endif
+
+-# if SANITIZER_LINUX && !SANITIZER_ANDROID
++# if SANITIZER_GLIBC
+ struct __sanitizer_dirent64 {
+ unsigned long long d_ino;
+ unsigned long long d_off;
+
diff --git a/13.2.0/musl/README.history b/13.2.0/musl/README.history
new file mode 100644
index 0000000..5bceb63
--- /dev/null
+++ b/13.2.0/musl/README.history
@@ -0,0 +1,9 @@
+2 10 May 2023
+ + 50_all_sanitizer_lfs.patch
+
+1 26 Apr 2023
+
+ + 25_all_multilib_pure64.patch
+ + 50_all_posix_memalign.patch
+ + 50_all_cpu_indicator.patch
+ + 50_all_libssp_unconditionally.patch
diff --git a/14.0.0/gentoo/01_all_default-fortify-source.patch b/14.0.0/gentoo/01_all_default-fortify-source.patch
new file mode 100644
index 0000000..4cdf5f6
--- /dev/null
+++ b/14.0.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/14.0.0/gentoo/02_all_default-warn-format-security.patch b/14.0.0/gentoo/02_all_default-warn-format-security.patch
new file mode 100644
index 0000000..439d9d8
--- /dev/null
+++ b/14.0.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/14.0.0/gentoo/03_all_default-warn-trampolines.patch b/14.0.0/gentoo/03_all_default-warn-trampolines.patch
new file mode 100644
index 0000000..fb6d8bc
--- /dev/null
+++ b/14.0.0/gentoo/03_all_default-warn-trampolines.patch
@@ -0,0 +1,13 @@
+Enable -Wtrampolines by default.
+
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -798,7 +798,7 @@ Common Var(warn_system_headers) Warning
+ Do not suppress warnings from system headers.
+
+ 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/14.0.0/gentoo/04_all_nossp-on-nostdlib.patch b/14.0.0/gentoo/04_all_nossp-on-nostdlib.patch
new file mode 100644
index 0000000..30c5825
--- /dev/null
+++ b/14.0.0/gentoo/04_all_nossp-on-nostdlib.patch
@@ -0,0 +1,28 @@
+│Disable ssp on -nostdlib, -nodefaultlibs and -ffreestanding
+https://bugs.gentoo.org/484714
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -984,6 +984,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} "
++#else
++#define NO_SSP_SPEC ""
++#endif
++
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+@@ -1286,7 +1292,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|fprofile-generate*|coverage:\
+ %{!fprofile-update=single:\
+--
+2.44.0
diff --git a/14.0.0/gentoo/05_all_alpha-mieee-default.patch b/14.0.0/gentoo/05_all_alpha-mieee-default.patch
new file mode 100644
index 0000000..fd1de71
--- /dev/null
+++ b/14.0.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 <vapier@gentoo.org>
+
+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/14.0.0/gentoo/06_all_ia64_note.GNU-stack.patch b/14.0.0/gentoo/06_all_ia64_note.GNU-stack.patch
new file mode 100644
index 0000000..7a1d4c6
--- /dev/null
+++ b/14.0.0/gentoo/06_all_ia64_note.GNU-stack.patch
@@ -0,0 +1,92 @@
+http://gcc.gnu.org/PR21098
+
+
+2004-09-20 Jakub Jelinek <jakub@redhat.com>
+
+ * 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 <jakub@redhat.com>
+
+ * 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/14.0.0/gentoo/07_all_libiberty-asprintf.patch b/14.0.0/gentoo/07_all_libiberty-asprintf.patch
new file mode 100644
index 0000000..1ed2ba3
--- /dev/null
+++ b/14.0.0/gentoo/07_all_libiberty-asprintf.patch
@@ -0,0 +1,18 @@
+2008-07-25 Magnus Granberg <zorry@ume.nu>
+
+ * include/libiberty.h (asprintf): Don't declare if defined as a macro
+
+--- a/include/libiberty.h
++++ b/include/libiberty.h
+@@ -652,8 +652,11 @@ extern void *bsearch_r (const void *, const void *,
+ /* Like sprintf but provides a pointer to malloc'd storage, which must
+ be freed by the caller. */
+
++/* asprintf may be declared as a macro by glibc with __USE_FORTIFY_LEVEL. */
++#ifndef asprintf
+ extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
+ #endif
++#endif
+
+ /* Like asprintf but allocates memory without fail. This works like
+ xmalloc. */
diff --git a/14.0.0/gentoo/08_all_libiberty-pic.patch b/14.0.0/gentoo/08_all_libiberty-pic.patch
new file mode 100644
index 0000000..3f0bae1
--- /dev/null
+++ b/14.0.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/14.0.0/gentoo/10_all_sh-drop-sysroot-suffix.patch b/14.0.0/gentoo/10_all_sh-drop-sysroot-suffix.patch
new file mode 100644
index 0000000..e778f81
--- /dev/null
+++ b/14.0.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 <slyfox@gentoo.org>
+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 <slyfox@gentoo.org>
+--- 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/14.0.0/gentoo/11_all_ia64-TEXTREL.patch b/14.0.0/gentoo/11_all_ia64-TEXTREL.patch
new file mode 100644
index 0000000..f5d0a99
--- /dev/null
+++ b/14.0.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/14.0.0/gentoo/14_all_respect-build-cxxflags.patch b/14.0.0/gentoo/14_all_respect-build-cxxflags.patch
new file mode 100644
index 0000000..1f9a774
--- /dev/null
+++ b/14.0.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/14.0.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch b/14.0.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch
new file mode 100644
index 0000000..2daf73b
--- /dev/null
+++ b/14.0.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
+@@ -957,6 +957,10 @@ c_cpp_builtins (cpp_reader *pfile)
+ cpp_define (pfile, "__cpp_rtti=199711L");
+ }
+
++ #ifdef DEF_GENTOO_GLIBCXX_ASSERTIONS
++ cpp_define (pfile, "_GLIBCXX_ASSERTIONS");
++ #endif
++
+ if (cxx_dialect >= cxx11)
+ cpp_define (pfile, "__GXX_EXPERIMENTAL_CXX0X__");
+
diff --git a/14.0.0/gentoo/20_all_libstdcxx-no-vtv.patch b/14.0.0/gentoo/20_all_libstdcxx-no-vtv.patch
new file mode 100644
index 0000000..2719e2d
--- /dev/null
+++ b/14.0.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/14.0.0/gentoo/22_all_default_ssp-buffer-size.patch b/14.0.0/gentoo/22_all_default_ssp-buffer-size.patch
new file mode 100644
index 0000000..0e0dd42
--- /dev/null
+++ b/14.0.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/14.0.0/gentoo/23_all_DEF_GENTOO_ZNOW-z-now.patch b/14.0.0/gentoo/23_all_DEF_GENTOO_ZNOW-z-now.patch
new file mode 100644
index 0000000..2ed7968
--- /dev/null
+++ b/14.0.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/14.0.0/gentoo/24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch b/14.0.0/gentoo/24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch
new file mode 100644
index 0000000..b13215d
--- /dev/null
+++ b/14.0.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. */
++#ifdef DEF_GENTOO_SCP
++#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/14.0.0/gentoo/26_all_enable-cet.patch b/14.0.0/gentoo/26_all_enable-cet.patch
new file mode 100644
index 0000000..b9bbbf0
--- /dev/null
+++ b/14.0.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 <sam@gentoo.org>
+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
+@@ -51,7 +51,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-ts:-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*:"
+@@ -72,7 +72,7 @@ along with GCC; see the file COPYING3. If not see
+ " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}"
+ " %{fmodules-ts:-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*:"
+@@ -92,7 +92,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-ts:-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*:"
+@@ -107,7 +107,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)}}"
+@@ -116,7 +116,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
+@@ -999,6 +999,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. */
++#ifdef EXTRA_OPTIONS_CF
++#define DEFAULT_FLAG_CF_SPEC " %{!m16:%{!m32:%{!fcf-protection*:%{!fno-cf-protection:-fcf-protection}}}}"
++#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"
+@@ -1201,6 +1213,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;
+@@ -1261,7 +1274,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.
+
+@@ -1455,9 +1468,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}\
+@@ -1482,7 +1495,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},
+@@ -1714,6 +1727,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/14.0.0/gentoo/28_all_drop_CFLAGS_sed.patch b/14.0.0/gentoo/28_all_drop_CFLAGS_sed.patch
new file mode 100644
index 0000000..764f34c
--- /dev/null
+++ b/14.0.0/gentoo/28_all_drop_CFLAGS_sed.patch
@@ -0,0 +1,35 @@
+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
+@@ -5388,13 +5388,6 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
+ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+-# Remove the -O2: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[ ]//" -e "s/-O[gs][ ]//" -e "s/-O[0-9]*[ ]//" `
+- CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[ ]//" -e "s/-O[gs][ ]//" -e "s/-O[0-9]*[ ]//" ` ;;
+-esac
+
+
+
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -440,13 +440,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 the -O2: for historical reasons, unless bootstrapping we prefer
+-# optimizations to be activated explicitly by the toplevel.
+-case "$CC" in
+- */prev-gcc/xgcc*) ;;
+- *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" `
+- CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[[ ]]//" -e "s/-O[[gs]][[ ]]//" -e "s/-O[[0-9]]*[[ ]]//" ` ;;
+-esac
+ AC_SUBST(CFLAGS)
+ AC_SUBST(CXXFLAGS)
+ AC_SUBST(GDCFLAGS)
diff --git a/14.0.0/gentoo/29_all_msgfmt-libstdc++-link.patch b/14.0.0/gentoo/29_all_msgfmt-libstdc++-link.patch
new file mode 100644
index 0000000..0d2f113
--- /dev/null
+++ b/14.0.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/14.0.0/gentoo/30_all_tar_libstdc++-link.patch b/14.0.0/gentoo/30_all_tar_libstdc++-link.patch
new file mode 100644
index 0000000..adb414a
--- /dev/null
+++ b/14.0.0/gentoo/30_all_tar_libstdc++-link.patch
@@ -0,0 +1,57 @@
+From eae11e896edef4199a128bf6720b5bd4e5edc2f9 Mon Sep 17 00:00:00 2001
+From: Sam James <sam@gentoo.org>
+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 <sam@gentoo.org>
+--- 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/14.0.0/gentoo/76_all_ppc_PR112868-no-checking-many.patch b/14.0.0/gentoo/76_all_ppc_PR112868-no-checking-many.patch
new file mode 100644
index 0000000..dc9f5e5
--- /dev/null
+++ b/14.0.0/gentoo/76_all_ppc_PR112868-no-checking-many.patch
@@ -0,0 +1,42 @@
+https://gcc.gnu.org/PR112868 (specifically https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112868#c8)
+(see also https://gcc.gnu.org/PR113652)
+
+--- a/gcc/config/rs6000/rs6000.h
++++ b/gcc/config/rs6000/rs6000.h
+@@ -94,12 +94,6 @@
+ "%{mdejagnu-*: %<mdejagnu-*}", \
+ SUBTARGET_DRIVER_SELF_SPECS
+
+-#if CHECKING_P
+-#define ASM_OPT_ANY ""
+-#else
+-#define ASM_OPT_ANY " -many"
+-#endif
+-
+ /* Common ASM definitions used by ASM_SPEC among the various targets for
+ handling -mcpu=xxx switches. There is a parallel list in driver-rs6000.cc to
+ provide the default assembler options if the user uses -mcpu=native, so if
+@@ -166,8 +160,7 @@
+ mvsx: -mpower7; \
+ mpowerpc64: -mppc64;: %(asm_default)}; \
+ :%eMissing -mcpu option in ASM_CPU_SPEC?\n} \
+-%{mvsx: -mvsx -maltivec; maltivec: -maltivec}" \
+-ASM_OPT_ANY
++%{mvsx: -mvsx -maltivec; maltivec: -maltivec}"
+
+ #define CPP_DEFAULT_SPEC ""
+
+--- a/gcc/testsuite/lib/target-supports.exp
++++ b/gcc/testsuite/lib/target-supports.exp
+@@ -7285,7 +7285,7 @@ proc check_effective_target_powerpc_ppu_ok { } {
+ #endif
+ return 0;
+ }
+- }]
++ } "-mcpu=cell"]
+ } else {
+ return 0
+ }
+
+
+
diff --git a/14.0.0/gentoo/README.history b/14.0.0/gentoo/README.history
new file mode 100644
index 0000000..8e0250c
--- /dev/null
+++ b/14.0.0/gentoo/README.history
@@ -0,0 +1,155 @@
+26 7 Apr 2024
+
+ U 02_all_default-warn-format-security.patch
+ U 04_all_nossp-on-nostdlib.patch
+
+25 11 Mar 2024
+
+ - 50_all_PR111632_system_cxx_headers_libcxx.patch
+ - 75_all_arm_PR113915-atomics.patch
+
+24 3 Mar 2024
+
+ + 76_all_ppc_PR112868-no-checking-many.patch
+
+23 19 Feb 2024
+
+ - 75_all_PR113734_middle_end_update_vector_loop_bounds.patch
+ + 75_all_arm_PR113915-atomics.patch
+
+22 13 Feb 2024
+
+ + 75_all_PR113734_middle_end_update_vector_loop_bounds.patch
+
+21 12 Feb 2024
+
+ - 75_all_PR113731_fix-ICE-when-moving-statements-to-empty-B.patch
+ - 76_all_PR113750_fix-ICE-when-destination-BB-for-stores-st.patch
+ - 77_all_PR113808-middle-end-don-t-cache-restart_loop-in-vectorizable.patch
+ - 78_all_PR113776-c-boolean-conversion.patch
+
+20 8 Feb 2024
+
+ + 75_all_PR113731_fix-ICE-when-moving-statements-to-empty-B.patch
+ + 76_all_PR113750_fix-ICE-when-destination-BB-for-stores-st.patch
+ + 77_all_PR113808-middle-end-don-t-cache-restart_loop-in-vectorizable.patch
+ + 78_all_PR113776-c-boolean-conversion.patch
+
+19 5 Feb 2024
+
+ - 76_all_PR113467-vect-miscompile.patch
+ + 76_all_PR113731-vect-crash.patch
+
+18 30 Jan 2024
+
+ + 50_all_PR111632_system_cxx_headers_libcxx.patch
+
+17 28 Jan 2024
+
+ - 75_all_PR113364-vect.patch
+
+16 15 Jan 2024
+
+ - 75_all_Revert-middle-end-explicitly-initialize-vec_stmts-PR.patch
+ - 76_all_Revert-testsuite-un-xfail-TSVC-loops-that-check-for-.patch
+ - 77_all_Revert_arm_Add_Advanced_SIMD_cbranch_implementation.patch
+ - 78_all_Revert_testsuite_add_tests_for_early_break_vectorization.patch
+ - 79_all_Revert_AArch64_add_implementation_for_vector_cbranch.patch
+ - 80_all_Revert_middle-end_support_vectorization_of_loops_with_mult.patch
+ - 81_all_Revert-middle-end-prevent-LIM-from-hoising-vector-co.patch
+ - 82_all_testsuite_Add_more_pragma_novector_to_new_tests.patch
+ + 75_all_PR113364-vect.patch
+
+15 8 Jan 2024
+
+ U 75_all_Revert-middle-end-explicitly-initialize-vec_stmts-PR.patch
+ U 76_all_Revert-testsuite-un-xfail-TSVC-loops-that-check-for-.patch
+ U 77_all_Revert_arm_Add_Advanced_SIMD_cbranch_implementation.patch
+ + 78_all_Revert_testsuite_add_tests_for_early_break_vectorization.patch
+ + 79_all_Revert_AArch64_add_implementation_for_vector_cbranch.patch
+ + 80_all_Revert_middle-end_support_vectorization_of_loops_with_mult.patch
+ + 81_all_Revert-middle-end-prevent-LIM-from-hoising-vector-co.patch
+ + 82_all_testsuite_Add_more_pragma_novector_to_new_tests.patch
+
+14 31 Dec 2023
+
+ + 75_all_Revert-middle-end-explicitly-initialize-vec_stmts-PR.patch
+
+13 25 Dec 2023
+
+ N/A
+
+12 25 Dec 2023
+
+ + 76_all_Revert-testsuite-un-xfail-TSVC-loops-that-check-for-.patch
+ + 77_all_Revert-testsuite-Add-tests-for-early-break-vectoriza.patch
+ + 78_all_Revert-AArch64-Add-implementation-for-vector-cbranch.patch
+ + 79_all_Revert-middle-end-Support-vectorization-of-loops-wit.patch
+ + 80_all_Revert-middle-end-prevent-LIM-from-hoising-vector-co.patch
+ + 81_all_Revert-testsuite-Add-more-pragma-novector-to-new-tes.patch
+
+11 17 Dec 2023
+
+ - 76_all_PR112869_cxx.patch
+
+10 10 Dec 2023
+
+ - 75_all_PR112572-missing-notes-update.patch
+ + 76_all_PR112869_cxx.patch
+
+9 20 Nov 2023
+
+ + 75_all_PR112572-missing-notes-update.patch
+
+8 05 Nov 2023
+
+ - 75_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch
+
+7 28 Oct 2023
+
+ U 75_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch
+
+6 22 Oct 2023
+
+ U 75_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch
+
+5 21 Oct 2023
+
+ U 75_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch
+
+4 18 Oct 2023
+
+ + 75_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch
+
+3 02 Oct 2023
+
+ U 26_all_enable-cet.patch
+
+2 18 June 2023
+
+ - 09_all_nopie-all-flags.patch
+
+1 23 April 2023
+
+ + 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
+ + 07_all_libiberty-asprintf.patch
+ + 08_all_libiberty-pic.patch
+ + 09_all_nopie-all-flags.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
+ + 25_all_lto-intl-workaround-PR95194.patch
+ + 26_all_enable-cet.patch
+ + 28_all_drop_CFLAGS_sed.patch
+ + 29_all_msgfmt-libstdc++-link.patch
+ + 30_all_tar_libstdc++-link.patch
diff --git a/14.0.0/musl/25_all_multilib_pure64.patch b/14.0.0/musl/25_all_multilib_pure64.patch
new file mode 100644
index 0000000..d55c04c
--- /dev/null
+++ b/14.0.0/musl/25_all_multilib_pure64.patch
@@ -0,0 +1,83 @@
+https://bugs.gentoo.org/675954
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90077
+
+--- a/gcc/config/aarch64/t-aarch64-linux
++++ b/gcc/config/aarch64/t-aarch64-linux
+@@ -22,7 +22,7 @@
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+--- a/gcc/config/i386/t-linux64
++++ b/gcc/config/i386/t-linux64
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
+-MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
++MULTILIB_OSDIRNAMES+= mx32=../libx32
+--- a/gcc/config/rs6000/t-linux
++++ b/gcc/config/rs6000/t-linux
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+
+--- a/gcc/config/rs6000/t-linux64
++++ b/gcc/config/rs6000/t-linux64
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS := m64/m32
+ MULTILIB_DIRNAMES := 64 32
+ MULTILIB_EXTRA_OPTS :=
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ $(COMPILE) $<
+--- a/gcc/config/rs6000/t-linux64bele
++++ b/gcc/config/rs6000/t-linux64bele
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mlittle
+ MULTILIB_DIRNAMES += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/rs6000/t-linux64lebe
++++ b/gcc/config/rs6000/t-linux64lebe
+@@ -2,6 +2,6 @@
+
+ MULTILIB_OPTIONS += mbig
+ MULTILIB_DIRNAMES += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN}
diff --git a/14.0.0/musl/50_all_cpu_indicator.patch b/14.0.0/musl/50_all_cpu_indicator.patch
new file mode 100644
index 0000000..52e8b92
--- /dev/null
+++ b/14.0.0/musl/50_all_cpu_indicator.patch
@@ -0,0 +1,37 @@
+https://gcc.gnu.org/pipermail/gcc-patches/2023-February/612648.html
+
+From d16a8ceb1c3c8a7ec381090b4c316ff4c55661c0 Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 7 May 2020 21:14:11 -0500
+Subject: [PATCH] convert "__cpu_indicator_init" to
+ "__cpu_indicator_init_local"
+
+--- a/gcc/config/i386/i386-expand.cc
++++ b/gcc/config/i386/i386-expand.cc
+@@ -12338,10 +12338,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
+ {
+ case IX86_BUILTIN_CPU_INIT:
+ {
+- /* Make it call __cpu_indicator_init in libgcc. */
++ /* Make it call __cpu_indicator_init_local in libgcc. */
+ tree call_expr, fndecl, type;
+ type = build_function_type_list (integer_type_node, NULL_TREE);
+- fndecl = build_fn_decl ("__cpu_indicator_init", type);
++ fndecl = build_fn_decl ("__cpu_indicator_init_local", type);
+ call_expr = build_call_expr (fndecl, 0);
+ return expand_expr (call_expr, target, mode, EXPAND_NORMAL);
+ }
+
+--- a/libgcc/config/i386/cpuinfo.c
++++ b/libgcc/config/i386/cpuinfo.c
+@@ -508,7 +508,7 @@ __cpu_indicator_init (void)
+ return 0;
+ }
+
+-#if defined SHARED && defined USE_ELF_SYMVER
+-__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0");
+-__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0");
++#ifndef SHARED
++int __cpu_indicator_init_local (void)
++ __attribute__ ((weak, alias ("__cpu_indicator_init")));
+ #endif
diff --git a/14.0.0/musl/50_all_libssp_unconditionally.patch b/14.0.0/musl/50_all_libssp_unconditionally.patch
new file mode 100644
index 0000000..a3b5984
--- /dev/null
+++ b/14.0.0/musl/50_all_libssp_unconditionally.patch
@@ -0,0 +1,24 @@
+https://bugs.gentoo.org/706210
+https://bugs.gentoo.org/747346
+
+Author: Timo Teräs <timo.teras@iki.fi>
+
+"Alpine musl package provides libssp_nonshared.a. We link to it unconditionally,
+as otherwise we get link failures if some objects are -fstack-protector built
+and final link happens with -fno-stack-protector. This seems to be the common
+case when bootstrapping gcc, the piepatches do not seem to fully fix the
+crosstoolchain and bootstrap sequence wrt. stack-protector flag usage."
+
+(We do the same in Gentoo.)
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -870,8 +870,7 @@
+
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+- "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ "|fstack-protector-strong|fstack-protector-explicit" \
diff --git a/14.0.0/musl/50_all_posix_memalign.patch b/14.0.0/musl/50_all_posix_memalign.patch
new file mode 100644
index 0000000..dd75a93
--- /dev/null
+++ b/14.0.0/musl/50_all_posix_memalign.patch
@@ -0,0 +1,28 @@
+--- a/gcc/config/i386/pmm_malloc.h
++++ b/gcc/config/i386/pmm_malloc.h
+@@ -27,12 +27,13 @@
+ #include <stdlib.h>
+
+ /* We can't depend on <stdlib.h> since the prototype of posix_memalign
+- may not be visible. */
++ may not be visible and we can't pollute the namespace either. */
+ #ifndef __cplusplus
+-extern int posix_memalign (void **, size_t, size_t);
++extern int __gcc_posix_memalign (void **, size_t, size_t)
+ #else
+-extern "C" int posix_memalign (void **, size_t, size_t) throw ();
++extern "C" int __gcc_posix_memalign (void **, size_t, size_t) throw ()
+ #endif
++__asm__("posix_memalign");
+
+ static __inline void *
+ _mm_malloc (size_t __size, size_t __alignment)
+@@ -42,7 +43,7 @@
+ return malloc (__size);
+ if (__alignment == 2 || (sizeof (void *) == 8 && __alignment == 4))
+ __alignment = sizeof (void *);
+- if (posix_memalign (&__ptr, __alignment, __size) == 0)
++ if (__gcc_posix_memalign (&__ptr, __alignment, __size) == 0)
+ return __ptr;
+ else
+ return NULL;
diff --git a/14.0.0/musl/README.history b/14.0.0/musl/README.history
new file mode 100644
index 0000000..05b8810
--- /dev/null
+++ b/14.0.0/musl/README.history
@@ -0,0 +1,6 @@
+1 23 Apr 2023
+
+ + 25_all_multilib_pure64.patch
+ + 50_all_cpu_indicator.patch
+ + 50_all_libssp_unconditionally.patch
+ + 50_all_posix_memalign.patch
diff --git a/8.5.0/gentoo/33_all_msgfmt-libstdc++-link.patch b/8.5.0/gentoo/33_all_msgfmt-libstdc++-link.patch
new file mode 100644
index 0000000..0d2f113
--- /dev/null
+++ b/8.5.0/gentoo/33_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/8.5.0/gentoo/README.history b/8.5.0/gentoo/README.history
index b2d4c99..1466fd7 100644
--- a/8.5.0/gentoo/README.history
+++ b/8.5.0/gentoo/README.history
@@ -1,6 +1,7 @@
-3 TODO
+4 08 Feb 2023
+ 31_all_powerpcspe-pie-crt.patch
+ 32_all_powerpcspe-march-PLATFORM.patch
+ + 33_all_msgfmt-libstdc++-link.patch
2 05 July 2021
+ 30_all_remove-cyclades.patch
diff --git a/9.3.0/gentoo/75_all_remove_cyclades.patch b/9.3.0/gentoo/75_all_remove_cyclades.patch
new file mode 100644
index 0000000..57d5043
--- /dev/null
+++ b/9.3.0/gentoo/75_all_remove_cyclades.patch
@@ -0,0 +1,127 @@
+https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=f45fc759ee4bac87fcdb6bc790a221205aa3eb5a
+https://bugs.gentoo.org/829141
+
+Needed for gnat-gpl-2020.
+
+From 2b40941d23b1570cdd90083b58fa0f66aa58c86e Mon Sep 17 00:00:00 2001
+From: Tamar Christina <tamar.christina@arm.com>
+Date: Fri, 21 May 2021 12:16:56 +0100
+Subject: [PATCH 1/1] libsanitizer: Remove cyclades from libsanitizer
+
+The Linux kernel has removed the interface to cyclades from
+the latest kernel headers[1] due to them being orphaned for the
+past 13 years.
+
+libsanitizer uses this header when compiling against glibc, but
+glibcs itself doesn't seem to have any references to cyclades.
+
+Further more it seems that the driver is broken in the kernel and
+the firmware doesn't seem to be available anymore.
+
+As such since this is breaking the build of libsanitizer (and so the
+GCC bootstrap[2]) I propose to remove this.
+
+[1] https://lkml.org/lkml/2021/3/2/153
+[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100379
+
+libsanitizer/ChangeLog:
+
+ PR sanitizer/100379
+ * sanitizer_common/sanitizer_common_interceptors_ioctl.inc: Cherry-pick
+ llvm-project revision f7c5351552387bd43f6ca3631016d7f0dfe0f135.
+ * sanitizer_common/sanitizer_platform_limits_posix.cc: Likewise.
+ * sanitizer_common/sanitizer_platform_limits_posix.h: Likewise.
+---
+ .../sanitizer_common_interceptors_ioctl.inc | 9 ---------
+ .../sanitizer_platform_limits_posix.cc | 11 -----------
+ .../sanitizer_platform_limits_posix.h | 10 ----------
+ 3 files changed, 30 deletions(-)
+
+diff --git a/libsanitizer/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/libsanitizer/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
+index 5408ea17c59..7a9cd3f5968 100644
+--- a/libsanitizer/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
++++ b/libsanitizer/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
+@@ -365,15 +365,6 @@ static void ioctl_table_fill() {
+
+ #if SANITIZER_LINUX && !SANITIZER_ANDROID
+ // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE
+- _(CYGETDEFTHRESH, WRITE, sizeof(int));
+- _(CYGETDEFTIMEOUT, WRITE, sizeof(int));
+- _(CYGETMON, WRITE, struct_cyclades_monitor_sz);
+- _(CYGETTHRESH, WRITE, sizeof(int));
+- _(CYGETTIMEOUT, WRITE, sizeof(int));
+- _(CYSETDEFTHRESH, NONE, 0);
+- _(CYSETDEFTIMEOUT, NONE, 0);
+- _(CYSETTHRESH, NONE, 0);
+- _(CYSETTIMEOUT, NONE, 0);
+ _(EQL_EMANCIPATE, WRITE, struct_ifreq_sz);
+ _(EQL_ENSLAVE, WRITE, struct_ifreq_sz);
+ _(EQL_GETMASTRCFG, WRITE, struct_ifreq_sz);
+diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
+index d823a12190c..e8fce8a0287 100644
+--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
+@@ -157,7 +157,6 @@ typedef struct user_fpregs elf_fpregset_t;
+ # include <sys/procfs.h>
+ #endif
+ #include <sys/user.h>
+-#include <linux/cyclades.h>
+ #include <linux/if_eql.h>
+ #include <linux/if_plip.h>
+ #include <linux/lp.h>
+@@ -466,7 +465,6 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+
+ #if SANITIZER_LINUX && !SANITIZER_ANDROID
+ unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct);
+- unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor);
+ #if EV_VERSION > (0x010000)
+ unsigned struct_input_keymap_entry_sz = sizeof(struct input_keymap_entry);
+ #else
+@@ -833,15 +831,6 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
+
+ #if SANITIZER_LINUX && !SANITIZER_ANDROID
+- unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH;
+- unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT;
+- unsigned IOCTL_CYGETMON = CYGETMON;
+- unsigned IOCTL_CYGETTHRESH = CYGETTHRESH;
+- unsigned IOCTL_CYGETTIMEOUT = CYGETTIMEOUT;
+- unsigned IOCTL_CYSETDEFTHRESH = CYSETDEFTHRESH;
+- unsigned IOCTL_CYSETDEFTIMEOUT = CYSETDEFTIMEOUT;
+- unsigned IOCTL_CYSETTHRESH = CYSETTHRESH;
+- unsigned IOCTL_CYSETTIMEOUT = CYSETTIMEOUT;
+ unsigned IOCTL_EQL_EMANCIPATE = EQL_EMANCIPATE;
+ unsigned IOCTL_EQL_ENSLAVE = EQL_ENSLAVE;
+ unsigned IOCTL_EQL_GETMASTRCFG = EQL_GETMASTRCFG;
+diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
+index 6a673a7c995..f921bf2b5b5 100644
+--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
+@@ -1040,7 +1040,6 @@ struct __sanitizer_cookie_io_functions_t {
+
+ #if SANITIZER_LINUX && !SANITIZER_ANDROID
+ extern unsigned struct_ax25_parms_struct_sz;
+- extern unsigned struct_cyclades_monitor_sz;
+ extern unsigned struct_input_keymap_entry_sz;
+ extern unsigned struct_ipx_config_data_sz;
+ extern unsigned struct_kbdiacrs_sz;
+@@ -1385,15 +1384,6 @@ struct __sanitizer_cookie_io_functions_t {
+ #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
+
+ #if SANITIZER_LINUX && !SANITIZER_ANDROID
+- extern unsigned IOCTL_CYGETDEFTHRESH;
+- extern unsigned IOCTL_CYGETDEFTIMEOUT;
+- extern unsigned IOCTL_CYGETMON;
+- extern unsigned IOCTL_CYGETTHRESH;
+- extern unsigned IOCTL_CYGETTIMEOUT;
+- extern unsigned IOCTL_CYSETDEFTHRESH;
+- extern unsigned IOCTL_CYSETDEFTIMEOUT;
+- extern unsigned IOCTL_CYSETTHRESH;
+- extern unsigned IOCTL_CYSETTIMEOUT;
+ extern unsigned IOCTL_EQL_EMANCIPATE;
+ extern unsigned IOCTL_EQL_ENSLAVE;
+ extern unsigned IOCTL_EQL_GETMASTRCFG;
+--
+2.27.0
+
+
diff --git a/9.3.0/gentoo/README.history b/9.3.0/gentoo/README.history
index a9fffed..20f447c 100644
--- a/9.3.0/gentoo/README.history
+++ b/9.3.0/gentoo/README.history
@@ -1,5 +1,6 @@
-5 TODO
+5 17 Dec 2021
+ 33_all_vmat-PR97236.patch
+ + 75_all_remove_cyclades.patch
4 04 Nov 2020
+ 30_all_plugin-objdump.patch
diff --git a/9.4.0/gentoo/30_all_glibc_236.patch b/9.4.0/gentoo/30_all_glibc_236.patch
new file mode 100644
index 0000000..68fe0a6
--- /dev/null
+++ b/9.4.0/gentoo/30_all_glibc_236.patch
@@ -0,0 +1,37 @@
+https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=6bd956e31b2fb6fe1eee4eb1bf309247dcd19b23
+
+From 6bd956e31b2fb6fe1eee4eb1bf309247dcd19b23 Mon Sep 17 00:00:00 2001
+From: Martin Liska <mliska@suse.cz>
+Date: Mon, 11 Jul 2022 22:03:14 +0200
+Subject: [PATCH] libsanitizer: cherry-pick 9cf13067cb5088626ba7 from upstream
+
+9cf13067cb5088626ba7ee1ec4c42ec59c7995a0 [sanitizer] Remove #include <linux/fs.h> to resolve fsconfig_command/mount_attr conflict with glibc 2.36
+
+(cherry picked from commit 2701442d0cf6292f6624443c15813d6d1a3562fe)
+--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
+@@ -72,7 +72,9 @@
+ #include <sys/vt.h>
+ #include <linux/cdrom.h>
+ #include <linux/fd.h>
++#if SANITIZER_ANDROID
+ #include <linux/fs.h>
++#endif
+ #include <linux/hdreg.h>
+ #include <linux/input.h>
+ #include <linux/ioctl.h>
+@@ -822,10 +824,10 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+ unsigned IOCTL_EVIOCGPROP = IOCTL_NOT_PRESENT;
+ unsigned IOCTL_EVIOCSKEYCODE_V2 = IOCTL_NOT_PRESENT;
+ #endif
+- unsigned IOCTL_FS_IOC_GETFLAGS = FS_IOC_GETFLAGS;
+- unsigned IOCTL_FS_IOC_GETVERSION = FS_IOC_GETVERSION;
+- unsigned IOCTL_FS_IOC_SETFLAGS = FS_IOC_SETFLAGS;
+- unsigned IOCTL_FS_IOC_SETVERSION = FS_IOC_SETVERSION;
++ unsigned IOCTL_FS_IOC_GETFLAGS = _IOR('f', 1, long);
++ unsigned IOCTL_FS_IOC_GETVERSION = _IOR('v', 1, long);
++ unsigned IOCTL_FS_IOC_SETFLAGS = _IOW('f', 2, long);
++ unsigned IOCTL_FS_IOC_SETVERSION = _IOW('v', 2, long);
+ unsigned IOCTL_GIO_CMAP = GIO_CMAP;
+ unsigned IOCTL_GIO_FONT = GIO_FONT;
+ unsigned IOCTL_GIO_UNIMAP = GIO_UNIMAP;
diff --git a/9.4.0/gentoo/README.history b/9.4.0/gentoo/README.history
index 2adb561..e9aa4ec 100644
--- a/9.4.0/gentoo/README.history
+++ b/9.4.0/gentoo/README.history
@@ -1,3 +1,6 @@
+2 15 Aug 2022
+ + 30_all_glibc_236.patch
+
1 01 June 2021
+ 01_all_default-fortify-source.patch
+ 02_all_default-warn-format-security.patch
diff --git a/9.5.0/gentoo/01_all_default-fortify-source.patch b/9.5.0/gentoo/01_all_default-fortify-source.patch
new file mode 100644
index 0000000..d307474
--- /dev/null
+++ b/9.5.0/gentoo/01_all_default-fortify-source.patch
@@ -0,0 +1,22 @@
+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.c
++++ b/gcc/c-family/c-cppbuiltin.c
+@@ -951,6 +951,12 @@ 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)
++ /* Fortify Source enabled by default for optimization levels > 0 */
++ if (optimize)
++ builtin_define_with_int_value ("_FORTIFY_SOURCE", 2);
++#endif
++
+ /* Misc. */
+ if (flag_gnu89_inline)
+ cpp_define (pfile, "__GNUC_GNU_INLINE__");
diff --git a/12.0.0/gentoo/02_all_default-warn-format-security.patch b/9.5.0/gentoo/02_all_default-warn-format-security.patch
index f809abd..f809abd 100644
--- a/12.0.0/gentoo/02_all_default-warn-format-security.patch
+++ b/9.5.0/gentoo/02_all_default-warn-format-security.patch
diff --git a/9.5.0/gentoo/03_all_default-warn-trampolines.patch b/9.5.0/gentoo/03_all_default-warn-trampolines.patch
new file mode 100644
index 0000000..7a644cb
--- /dev/null
+++ b/9.5.0/gentoo/03_all_default-warn-trampolines.patch
@@ -0,0 +1,13 @@
+Enable -Wtrampolines by default.
+
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -712,7 +712,7 @@ Common Var(warn_system_headers) Warning
+ Do not suppress warnings from system headers.
+
+ Wtrampolines
+-Common Var(warn_trampolines) Warning
++Common Var(warn_trampolines) Init(1) Warning
+ Warn whenever a trampoline is generated.
+
+ Wtype-limits
diff --git a/12.0.0/gentoo/04_all_nossp-on-nostdlib.patch b/9.5.0/gentoo/04_all_nossp-on-nostdlib.patch
index 4e581a5..648d712 100644
--- a/12.0.0/gentoo/04_all_nossp-on-nostdlib.patch
+++ b/9.5.0/gentoo/04_all_nossp-on-nostdlib.patch
@@ -19,9 +19,9 @@ https://bugs.gentoo.org/484714
@@ -1131,7 +1148,7 @@ static const char *cc1_options =
%{-version:--version}\
%{-help=*:--help=%*}\
- %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\
+ %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}}\
- %{fsyntax-only:-o %j} %{-param*}\
+ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\
%{coverage:-fprofile-arcs -ftest-coverage}\
%{fprofile-arcs|fprofile-generate*|coverage:\
- %{!fprofile-update=single:\
+ %{!fprofile-update=singel:\
diff --git a/9.5.0/gentoo/05_all_alpha-mieee-default.patch b/9.5.0/gentoo/05_all_alpha-mieee-default.patch
new file mode 100644
index 0000000..b266d77
--- /dev/null
+++ b/9.5.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 <vapier@gentoo.org>
+
+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
+@@ -96,6 +96,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 Report RejectNegative Mask(IEEE)
++Target Report Mask(IEEE)
+ Emit IEEE-conformant code, without inexact exceptions.
+
+ mieee-with-inexact
+
diff --git a/9.5.0/gentoo/06_all_ia64_note.GNU-stack.patch b/9.5.0/gentoo/06_all_ia64_note.GNU-stack.patch
new file mode 100644
index 0000000..66a787e
--- /dev/null
+++ b/9.5.0/gentoo/06_all_ia64_note.GNU-stack.patch
@@ -0,0 +1,92 @@
+http://gcc.gnu.org/PR21098
+
+
+2004-09-20 Jakub Jelinek <jakub@redhat.com>
+
+ * 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 <jakub@redhat.com>
+
+ * config/ia64/linux.h (TARGET_ASM_FILE_END): Define.
+
+
+--- a/gcc/config/ia64/linux.h
++++ b/gcc/config/ia64/linux.h
+@@ -24,6 +24,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
+@@ -352,7 +352,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
+@@ -252,3 +252,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
+@@ -119,3 +119,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/9.5.0/gentoo/07_all_i386_libgcc_note.GNU-stack.patch b/9.5.0/gentoo/07_all_i386_libgcc_note.GNU-stack.patch
new file mode 100644
index 0000000..7f74945
--- /dev/null
+++ b/9.5.0/gentoo/07_all_i386_libgcc_note.GNU-stack.patch
@@ -0,0 +1,54 @@
+--- a/libgcc/config/i386/resms64.h 2018-01-03 11:03:58.000000000 +0100
++++ b/libgcc/config/i386/resms64.h 2018-05-01 12:59:48.942833419 +0200
+@@ -57,3 +57,6 @@ MS2SYSV_STUB_END(resms64_17)
+ MS2SYSV_STUB_END(resms64_18)
+
+ #endif /* __x86_64__ */
++#if defined(__linux__) && defined(__ELF__)
++.section .note.GNU-stack,"",%progbits
++#endif
+--- a/libgcc/config/i386/resms64f.h 2018-01-03 11:03:58.000000000 +0100
++++ b/libgcc/config/i386/resms64f.h 2018-05-01 13:00:23.422832853 +0200
+@@ -55,3 +55,6 @@ MS2SYSV_STUB_END(resms64f_16)
+ MS2SYSV_STUB_END(resms64f_17)
+
+ #endif /* __x86_64__ */
++#if defined(__linux__) && defined(__ELF__)
++.section .note.GNU-stack,"",%progbits
++#endif
+--- a/libgcc/config/i386/resms64fx.h 2018-02-26 20:46:34.000000000 +0100
++++ b/libgcc/config/i386/resms64fx.h 2018-05-01 13:06:49.682826518 +0200
+@@ -62,3 +62,6 @@ MS2SYSV_STUB_END(resms64fx_16)
+ MS2SYSV_STUB_END(resms64fx_17)
+
+ #endif /* __x86_64__ */
++#if defined(__linux__) && defined(__ELF__)
++.section .note.GNU-stack,"",%progbits
++#endif
+--- a/libgcc/config/i386/resms64x.h 2018-02-26 20:46:34.000000000 +0100
++++ b/libgcc/config/i386/resms64x.h 2018-05-01 13:07:21.702825993 +0200
+@@ -63,3 +63,6 @@ MS2SYSV_STUB_END(resms64x_17)
+ MS2SYSV_STUB_END(resms64x_18)
+
+ #endif /* __x86_64__ */
++#if defined(__linux__) && defined(__ELF__)
++.section .note.GNU-stack,"",%progbits
++#endif
+--- a/libgcc/config/i386/savms64.h 2018-01-03 11:03:58.000000000 +0100
++++ b/libgcc/config/i386/savms64.h 2018-05-01 13:07:48.952825546 +0200
+@@ -57,3 +57,6 @@ MS2SYSV_STUB_END(savms64_17)
+ MS2SYSV_STUB_END(savms64_18)
+
+ #endif /* __x86_64__ */
++#if defined(__linux__) && defined(__ELF__)
++.section .note.GNU-stack,"",%progbits
++#endif
+--- a/libgcc/config/i386/savms64f.h 2018-01-03 11:03:58.000000000 +0100
++++ b/libgcc/config/i386/savms64f.h 2018-05-01 13:08:30.082824871 +0200
+@@ -55,3 +55,6 @@ MS2SYSV_STUB_END(savms64f_16)
+ MS2SYSV_STUB_END(savms64f_17)
+
+ #endif /* __x86_64__ */
++#if defined(__linux__) && defined(__ELF__)
++.section .note.GNU-stack,"",%progbits
++#endif
diff --git a/12.0.0/gentoo/07_all_libiberty-asprintf.patch b/9.5.0/gentoo/08_all_libiberty-asprintf.patch
index bee0c4c..bee0c4c 100644
--- a/12.0.0/gentoo/07_all_libiberty-asprintf.patch
+++ b/9.5.0/gentoo/08_all_libiberty-asprintf.patch
diff --git a/9.5.0/gentoo/09_all_libiberty-pic.patch b/9.5.0/gentoo/09_all_libiberty-pic.patch
new file mode 100644
index 0000000..b6160a7
--- /dev/null
+++ b/9.5.0/gentoo/09_all_libiberty-pic.patch
@@ -0,0 +1,10 @@
+--- a/libiberty/Makefile.in
++++ b/libiberty/Makefile.in
+@@ -246,6 +246,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/12.0.0/gentoo/09_all_nopie-all-flags.patch b/9.5.0/gentoo/10_all_nopie-all-flags.patch
index 48536e6..48536e6 100644
--- a/12.0.0/gentoo/09_all_nopie-all-flags.patch
+++ b/9.5.0/gentoo/10_all_nopie-all-flags.patch
diff --git a/9.5.0/gentoo/11_all_extra-options.patch b/9.5.0/gentoo/11_all_extra-options.patch
new file mode 100644
index 0000000..42c288c
--- /dev/null
+++ b/9.5.0/gentoo/11_all_extra-options.patch
@@ -0,0 +1,89 @@
+On Hardened we add some options like -fstack-clash-protection and -z now
+
+--- a/gcc/common.opt 2018-03-28 16:51:09.000000000 +0200
++++ a/gcc/common.opt 2018-04-30 15:35:55.274096877 +0200
+@@ -2367,7 +2367,7 @@ Common Alias(fstack-check=, specific, no
+ Insert stack checking code into the program. Same as -fstack-check=specific.
+
+ fstack-clash-protection
+-Common Report Var(flag_stack_clash_protection) Optimization
++Common Report 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 2018-01-03 11:03:58.000000000 +0100
++++ b/gcc/defaults.h 2018-05-01 12:41:29.522851451 +0200
+@@ -1435,6 +1435,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. */
++#ifdef EXTRA_OPTIONS
++#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.c 2018-02-13 17:18:37.000000000 +0100
++++ b/gcc/toplev.c 2018-04-30 16:46:37.244027303 +0200
+@@ -1682,6 +1682,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 2011-11-22 04:01:02.000000000 +0100
++++ b/libgcc/Makefile.in 2011-12-25 15:18:22.449610631 +0100
+@@ -225,7 +225,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.
+@@ -279,7 +290,7 @@ INTERNAL_CFLAGS = $(CFLAGS) $(LIBGCC2_CF
+ -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)
++ -fno-stack-clash-protection $(INHIBIT_LIBC_CFLAGS)
+
+ # Extra flags to use when compiling crt{begin,end}.o.
+ CRTSTUFF_T_CFLAGS =
+--- a/gcc/gcc.c 2016-02-19 23:18:38.000000000 +0100
++++ b/gcc/gcc.c 2016-05-02 22:56:10.185721270 +0200
+@@ -868,6 +868,12 @@ proper position among the other output f
+ #endif
+ #endif
+
++#ifdef EXTRA_OPTIONS
++#define LINK_NOW_SPEC "%{!nonow:-z now} "
++#else
++#define LINK_NOW_SPEC ""
++#endif
++
+ #ifdef ENABLE_DEFAULT_PIE
+ #define NO_PIE_SPEC "no-pie|static"
+ #define PIE_SPEC NO_PIE_SPEC "|r|shared:;"
+@@ -1013,7 +1020,7 @@ proper position among the other output f
+ %(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:%{!nostartfiles:%S}} \
diff --git a/9.5.0/gentoo/12_all_pr55930-dependency-tracking.patch b/9.5.0/gentoo/12_all_pr55930-dependency-tracking.patch
new file mode 100644
index 0000000..a8743e0
--- /dev/null
+++ b/9.5.0/gentoo/12_all_pr55930-dependency-tracking.patch
@@ -0,0 +1,18 @@
+libatomic build failure if configured with --disable-dependency-tracking
+load_n.c:115:1: fatal error: opening dependency file .deps/load_1_.lo.Ppo: No such file or directory
+
+https://bugs.gentoo.org/463463
+http://gcc.gnu.org/PR55930
+
+--- a/libatomic/Makefile.in
++++ b/libatomic/Makefile.in
+@@ -298,7 +298,8 @@ PAT_N = $(word 2,$(PAT_SPLIT))
+ PAT_S = $(word 3,$(PAT_SPLIT))
+ IFUNC_DEF = -DIFUNC_ALT=$(PAT_S)
+ IFUNC_OPT = $(word $(PAT_S),$(IFUNC_OPTIONS))
+-M_DEPS = -MT $@ -MD -MP -MF $(DEPDIR)/$(@F).Ppo
++@AMDEP_TRUE@M_DEPS = -MT $@ -MD -MP -MF $(DEPDIR)/$(@F).Ppo
++@AMDEP_FALSE@M_DEPS =
+ M_SIZE = -DN=$(PAT_N)
+ M_IFUNC = $(if $(PAT_S),$(IFUNC_DEF) $(IFUNC_OPT))
+ M_FILE = $(PAT_BASE)_n.c
diff --git a/12.0.0/gentoo/10_all_sh-drop-sysroot-suffix.patch b/9.5.0/gentoo/13_all_sh-drop-sysroot-suffix.patch
index 3dadd4c..3dadd4c 100644
--- a/12.0.0/gentoo/10_all_sh-drop-sysroot-suffix.patch
+++ b/9.5.0/gentoo/13_all_sh-drop-sysroot-suffix.patch
diff --git a/12.0.0/gentoo/11_all_ia64-TEXTREL.patch b/9.5.0/gentoo/14_all_ia64-TEXTREL.patch
index 706dbe5..706dbe5 100644
--- a/12.0.0/gentoo/11_all_ia64-TEXTREL.patch
+++ b/9.5.0/gentoo/14_all_ia64-TEXTREL.patch
diff --git a/12.0.0/gentoo/12_all_disable-systemtap-switch.patch b/9.5.0/gentoo/15_all_disable-systemtap-switch.patch
index d5ae8d0..d5ae8d0 100644
--- a/12.0.0/gentoo/12_all_disable-systemtap-switch.patch
+++ b/9.5.0/gentoo/15_all_disable-systemtap-switch.patch
diff --git a/12.0.0/gentoo/13_all_m68k-textrel-on-libgcc.patch b/9.5.0/gentoo/16_all_m68k-textrel-on-libgcc.patch
index a2aa100..a2aa100 100644
--- a/12.0.0/gentoo/13_all_m68k-textrel-on-libgcc.patch
+++ b/9.5.0/gentoo/16_all_m68k-textrel-on-libgcc.patch
diff --git a/9.5.0/gentoo/17_all_respect-build-cxxflags.patch b/9.5.0/gentoo/17_all_respect-build-cxxflags.patch
new file mode 100644
index 0000000..14139ea
--- /dev/null
+++ b/9.5.0/gentoo/17_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
+@@ -170,6 +170,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.
+@@ -710,6 +711,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
+@@ -172,6 +172,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/9.5.0/gentoo/18_all_libgfortran-Werror.patch b/9.5.0/gentoo/18_all_libgfortran-Werror.patch
new file mode 100644
index 0000000..f6c26bf
--- /dev/null
+++ b/9.5.0/gentoo/18_all_libgfortran-Werror.patch
@@ -0,0 +1,20 @@
+libgfortran does not respect --disable-werror
+
+https://bugs.gentoo.org/433435
+http://gcc.gnu.org/PR54724
+
+
+--- a/libgfortran/configure.ac
++++ b/libgfortran/configure.ac
+@@ -140,3 +140,3 @@ AM_PROG_CC_C_O
+ if test "x$GCC" = "xyes"; then
+- AM_FCFLAGS="-I . -Wall -Werror -fimplicit-none -fno-repack-arrays -fno-underscoring"
++ AM_FCFLAGS="-I . -Wall -fimplicit-none -fno-repack-arrays -fno-underscoring"
+ ## We like to use C11 and C99 routines when available. This makes
+--- a/libgfortran/configure
++++ b/libgfortran/configure
+@@ -5764,3 +5764,3 @@ fi
+ # Add -Wall -fno-repack-arrays -fno-underscoring if we are using GCC.
+ if test "x$GCC" = "xyes"; then
+- AM_FCFLAGS="-I . -Wall -Werror -fimplicit-none -fno-repack-arrays -fno-underscoring"
++ AM_FCFLAGS="-I . -Wall -fimplicit-none -fno-repack-arrays -fno-underscoring"
diff --git a/12.0.0/gentoo/15_all_libgomp-Werror.patch b/9.5.0/gentoo/19_all_libgomp-Werror.patch
index 416808a..416808a 100644
--- a/12.0.0/gentoo/15_all_libgomp-Werror.patch
+++ b/9.5.0/gentoo/19_all_libgomp-Werror.patch
diff --git a/12.0.0/gentoo/16_all_libitm-Werror.patch b/9.5.0/gentoo/20_all_libitm-Werror.patch
index 27181e0..27181e0 100644
--- a/12.0.0/gentoo/16_all_libitm-Werror.patch
+++ b/9.5.0/gentoo/20_all_libitm-Werror.patch
diff --git a/12.0.0/gentoo/17_all_libatomic-Werror.patch b/9.5.0/gentoo/21_all_libatomic-Werror.patch
index 0550722..0550722 100644
--- a/12.0.0/gentoo/17_all_libatomic-Werror.patch
+++ b/9.5.0/gentoo/21_all_libatomic-Werror.patch
diff --git a/9.5.0/gentoo/22_all_libbacktrace-Werror.patch b/9.5.0/gentoo/22_all_libbacktrace-Werror.patch
new file mode 100644
index 0000000..57dd284
--- /dev/null
+++ b/9.5.0/gentoo/22_all_libbacktrace-Werror.patch
@@ -0,0 +1,17 @@
+libbacktrace does not respect --disable-werror
+
+https://bugs.gentoo.org/667104
+--- a/libbacktrace/configure
++++ b/libbacktrace/configure
+@@ -11634,3 +11634,3 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ if test -n "${with_target_subdir}"; then
+- WARN_FLAGS="$WARN_FLAGS -Werror"
++ WARN_FLAGS="$WARN_FLAGS"
+ fi
+--- a/libbacktrace/configure.ac
++++ b/libbacktrace/configure.ac
+@@ -138,3 +138,3 @@ ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \
+ if test -n "${with_target_subdir}"; then
+- WARN_FLAGS="$WARN_FLAGS -Werror"
++ WARN_FLAGS="$WARN_FLAGS"
+ fi
diff --git a/9.5.0/gentoo/23_all_libsanitizer-Werror.patch b/9.5.0/gentoo/23_all_libsanitizer-Werror.patch
new file mode 100644
index 0000000..0e484a4
--- /dev/null
+++ b/9.5.0/gentoo/23_all_libsanitizer-Werror.patch
@@ -0,0 +1,17 @@
+libsanitizer does not respect --disable-werror
+
+https://bugs.gentoo.org/667104
+--- a/libsanitizer/libbacktrace/Makefile.am
++++ b/libsanitizer/libbacktrace/Makefile.am
+@@ -37,3 +37,3 @@ AM_CPPFLAGS = -I $(top_srcdir)/../include -I $(top_srcdir)/../libgcc \
+ WARN_FLAGS = -W -Wall -Wwrite-strings -Wmissing-format-attribute \
+- -Wcast-qual -Werror
++ -Wcast-qual
+ C_WARN_FLAGS = $(WARN_FLAGS) -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition
+--- a/libsanitizer/libbacktrace/Makefile.in
++++ b/libsanitizer/libbacktrace/Makefile.in
+@@ -297,3 +297,3 @@ AM_CPPFLAGS = -I $(top_srcdir)/../include -I $(top_srcdir)/../libgcc \
+ WARN_FLAGS = -W -Wall -Wwrite-strings -Wmissing-format-attribute \
+- -Wcast-qual -Werror
++ -Wcast-qual
+
diff --git a/12.0.0/gentoo/20_all_libstdcxx-no-vtv.patch b/9.5.0/gentoo/24_all_libstdcxx-no-vtv.patch
index 68508bd..68508bd 100644
--- a/12.0.0/gentoo/20_all_libstdcxx-no-vtv.patch
+++ b/9.5.0/gentoo/24_all_libstdcxx-no-vtv.patch
diff --git a/9.5.0/gentoo/25_all_disable-riscv32-ABIs.patch b/9.5.0/gentoo/25_all_disable-riscv32-ABIs.patch
new file mode 100644
index 0000000..ad0128a
--- /dev/null
+++ b/9.5.0/gentoo/25_all_disable-riscv32-ABIs.patch
@@ -0,0 +1,53 @@
+Autogenerated patch disabling the 32bit RISCV support
+See https://gcc.gnu.org/PR90419
+
+diff -ruN gcc-9.1.0.orig/gcc/config/riscv/t-linux-multilib gcc-9.1.0/gcc/config/riscv/t-linux-multilib
+--- gcc-9.1.0.orig/gcc/config/riscv/t-linux-multilib 2017-02-06 22:38:37.000000000 +0100
++++ gcc-9.1.0/gcc/config/riscv/t-linux-multilib 2019-05-18 23:04:54.849400774 +0200
+@@ -1,40 +1,18 @@
+ # This file was generated by multilib-generator with the command:
+-# ./multilib-generator rv32imac-ilp32-rv32ima,rv32imaf,rv32imafd,rv32imafc,rv32imafdc- rv32imafdc-ilp32d-rv32imafd- rv64imac-lp64-rv64ima,rv64imaf,rv64imafd,rv64imafc,rv64imafdc- rv64imafdc-lp64d-rv64imafd-
+-MULTILIB_OPTIONS = march=rv32imac/march=rv32ima/march=rv32imaf/march=rv32imafd/march=rv32imafc/march=rv32imafdc/march=rv32g/march=rv32gc/march=rv64imac/march=rv64ima/march=rv64imaf/march=rv64imafd/march=rv64imafc/march=rv64imafdc/march=rv64g/march=rv64gc mabi=ilp32/mabi=ilp32d/mabi=lp64/mabi=lp64d
+-MULTILIB_DIRNAMES = rv32imac \
+-rv32ima \
+-rv32imaf \
+-rv32imafd \
+-rv32imafc \
+-rv32imafdc \
+-rv32g \
+-rv32gc \
+-rv64imac \
++# ./multilib-generator rv64imac-lp64-rv64ima,rv64imaf,rv64imafd,rv64imafc,rv64imafdc- rv64imafdc-lp64d-rv64imafd-
++MULTILIB_OPTIONS = march=rv64imac/march=rv64ima/march=rv64imaf/march=rv64imafd/march=rv64imafc/march=rv64imafdc/march=rv64g/march=rv64gc mabi=lp64/mabi=lp64d
++MULTILIB_DIRNAMES = rv64imac \
+ rv64ima \
+ rv64imaf \
+ rv64imafd \
+ rv64imafc \
+ rv64imafdc \
+ rv64g \
+-rv64gc ilp32 \
+-ilp32d \
+-lp64 \
++rv64gc lp64 \
+ lp64d
+-MULTILIB_REQUIRED = march=rv32imac/mabi=ilp32 \
+-march=rv32imafdc/mabi=ilp32d \
+-march=rv64imac/mabi=lp64 \
++MULTILIB_REQUIRED = march=rv64imac/mabi=lp64 \
+ march=rv64imafdc/mabi=lp64d
+-MULTILIB_REUSE = march.rv32imac/mabi.ilp32=march.rv32ima/mabi.ilp32 \
+-march.rv32imac/mabi.ilp32=march.rv32imaf/mabi.ilp32 \
+-march.rv32imac/mabi.ilp32=march.rv32imafd/mabi.ilp32 \
+-march.rv32imac/mabi.ilp32=march.rv32imafc/mabi.ilp32 \
+-march.rv32imac/mabi.ilp32=march.rv32imafdc/mabi.ilp32 \
+-march.rv32imac/mabi.ilp32=march.rv32g/mabi.ilp32 \
+-march.rv32imac/mabi.ilp32=march.rv32gc/mabi.ilp32 \
+-march.rv32imafdc/mabi.ilp32d=march.rv32imafd/mabi.ilp32d \
+-march.rv32imafdc/mabi.ilp32d=march.rv32gc/mabi.ilp32d \
+-march.rv32imafdc/mabi.ilp32d=march.rv32g/mabi.ilp32d \
+-march.rv64imac/mabi.lp64=march.rv64ima/mabi.lp64 \
++MULTILIB_REUSE = march.rv64imac/mabi.lp64=march.rv64ima/mabi.lp64 \
+ march.rv64imac/mabi.lp64=march.rv64imaf/mabi.lp64 \
+ march.rv64imac/mabi.lp64=march.rv64imafd/mabi.lp64 \
+ march.rv64imac/mabi.lp64=march.rv64imafc/mabi.lp64 \
diff --git a/9.5.0/gentoo/26_all_default_ssp-buffer-size.patch b/9.5.0/gentoo/26_all_default_ssp-buffer-size.patch
new file mode 100644
index 0000000..dddd06b
--- /dev/null
+++ b/9.5.0/gentoo/26_all_default_ssp-buffer-size.patch
@@ -0,0 +1,14 @@
+Change the minimal SSP buffer size.
+
+https://bugs.gentoo.org/484714
+--- a/gcc/params.def 2016-03-30 09:47:40.000000000 +0200
++++ b/gcc/params.def 2016-09-19 12:56:58.443179039 +0200
+@@ -673,7 +673,7 @@ DEFPARAM (PARAM_INTEGER_SHARE_LIMIT,
+ DEFPARAM (PARAM_SSP_BUFFER_SIZE,
+ "ssp-buffer-size",
+ "The lower bound for a buffer to be considered for stack smashing protection.",
+- 8, 1, 0)
++ 4, 1, 0)
+
+ DEFPARAM (PARAM_MIN_SIZE_FOR_STACK_SHARING,
+ "min-size-for-stack-sharing",
diff --git a/9.5.0/gentoo/27_all_hppa-faster-synth_mult.patch b/9.5.0/gentoo/27_all_hppa-faster-synth_mult.patch
new file mode 100644
index 0000000..e93aa40
--- /dev/null
+++ b/9.5.0/gentoo/27_all_hppa-faster-synth_mult.patch
@@ -0,0 +1,44 @@
+From 73a841928cc1b86f43108d2383a6242e7e61a785 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Tue, 31 Mar 2020 23:58:05 +0100
+Subject: [PATCH] gcc/expmed.h: increase cache size from 10^3 to 10^6
+
+Without this patch is takes dev-libs/xxhash 1-2 hours
+to compile. With this patch - TODO measurements.
+
+It workarounds deficiency of synth_mult() which evics
+cache entries as it calculates optimal multiplication
+algorithm. xxhash is especially hevyweight as it's a
+64-bit multiplication of large prime constants.
+
+Bug: https://gcc.gnu.org/PR87256
+Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+---
+ gcc/expmed.h | 13 ++++++++-----
+ 1 file changed, 8 insertions(+), 5 deletions(-)
+
+--- a/gcc/expmed.h
++++ b/gcc/expmed.h
+@@ -127,11 +127,14 @@ struct alg_hash_entry {
+ };
+
+ /* The number of cache/hash entries. */
+-#if HOST_BITS_PER_WIDE_INT == 64
+-#define NUM_ALG_HASH_ENTRIES 1031
+-#else
+-#define NUM_ALG_HASH_ENTRIES 307
+-#endif
++/*
++ * Workaround hppa2.0 synth_mult deficiency
++ * and allocate ~1 million slots:
++ * https://gcc.gnu.org/PR87256
++ * That should increase RAM usage up to ~24MB
++ * per process.
++ */
++#define NUM_ALG_HASH_ENTRIES 1000003
+
+ #define NUM_MODE_INT \
+ (MAX_MODE_INT - MIN_MODE_INT + 1)
+--
+2.26.0
+
diff --git a/9.5.0/gentoo/28_all_libcpp-ar.patch b/9.5.0/gentoo/28_all_libcpp-ar.patch
new file mode 100644
index 0000000..55f2944
--- /dev/null
+++ b/9.5.0/gentoo/28_all_libcpp-ar.patch
@@ -0,0 +1,143 @@
+https://bugs.gentoo.org/718004
+https://gcc.gnu.org/PR94657
+
+Make sue we use ${CHOST}-ar and not 'ar'.
+
+--- a/libcpp/configure.ac
++++ b/libcpp/configure.ac
+@@ -12,6 +12,7 @@ AC_PROG_INSTALL
+ AC_PROG_CC
+ AC_PROG_CXX
+ AC_PROG_RANLIB
++AC_CHECK_TOOL(AR, ar)
+
+ AC_USE_SYSTEM_EXTENSIONS
+ AC_SYS_LARGEFILE
+--- a/libcpp/Makefile.in
++++ b/libcpp/Makefile.in
+@@ -25,7 +25,7 @@ srcdir = @srcdir@
+ top_builddir = .
+ VPATH = @srcdir@
+ INSTALL = @INSTALL@
+-AR = ar
++AR = @AR@
+ ARFLAGS = cru
+ ACLOCAL = @ACLOCAL@
+ AUTOCONF = @AUTOCONF@
+--- a/libcpp/configure
++++ b/libcpp/configure
+@@ -657,6 +657,7 @@ ACLOCAL
+ EGREP
+ GREP
+ CPP
++AR
+ RANLIB
+ ac_ct_CXX
+ CXXFLAGS
+@@ -1038,6 +1039,7 @@ do
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
++
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+@@ -4006,6 +4008,98 @@ else
+ RANLIB="$ac_cv_prog_RANLIB"
+ fi
+
++if test -n "$ac_tool_prefix"; then
++ # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
++set dummy ${ac_tool_prefix}ar; ac_word=$2
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
++$as_echo_n "checking for $ac_word... " >&6; }
++if ${ac_cv_prog_AR+:} false; then :
++ $as_echo_n "(cached) " >&6
++else
++ if test -n "$AR"; then
++ ac_cv_prog_AR="$AR" # Let the user override the test.
++else
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_AR="${ac_tool_prefix}ar"
++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++ done
++IFS=$as_save_IFS
++
++fi
++fi
++AR=$ac_cv_prog_AR
++if test -n "$AR"; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
++$as_echo "$AR" >&6; }
++else
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++fi
++
++
++fi
++if test -z "$ac_cv_prog_AR"; then
++ ac_ct_AR=$AR
++ # Extract the first word of "ar", so it can be a program name with args.
++set dummy ar; ac_word=$2
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
++$as_echo_n "checking for $ac_word... " >&6; }
++if ${ac_cv_prog_ac_ct_AR+:} false; then :
++ $as_echo_n "(cached) " >&6
++else
++ if test -n "$ac_ct_AR"; then
++ ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
++else
++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_prog_ac_ct_AR="ar"
++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++ done
++IFS=$as_save_IFS
++
++fi
++fi
++ac_ct_AR=$ac_cv_prog_ac_ct_AR
++if test -n "$ac_ct_AR"; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
++$as_echo "$ac_ct_AR" >&6; }
++else
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++fi
++
++ if test "x$ac_ct_AR" = x; then
++ AR=""
++ else
++ case $cross_compiling:$ac_tool_warned in
++yes:)
++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
++ac_tool_warned=yes ;;
++esac
++ AR=$ac_ct_AR
++ fi
++else
++ AR="$ac_cv_prog_AR"
++fi
++
+
+
+ ac_ext=c
diff --git a/9.5.0/gentoo/29_all_plugin-objdump.patch b/9.5.0/gentoo/29_all_plugin-objdump.patch
new file mode 100644
index 0000000..a9c33fd
--- /dev/null
+++ b/9.5.0/gentoo/29_all_plugin-objdump.patch
@@ -0,0 +1,34 @@
+https://gcc.gnu.org/PR95648
+--- a/config/gcc-plugin.m4
++++ b/config/gcc-plugin.m4
+@@ -45,7 +45,7 @@ AC_DEFUN([GCC_ENABLE_PLUGINS],
+ ;;
+ *)
+ if test x$build = x$host; then
+- export_sym_check="objdump${exeext} -T"
++ export_sym_check="$ac_cv_prog_OBJDUMP -T"
+ elif test x$host = x$target; then
+ export_sym_check="$gcc_cv_objdump -T"
+ else
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -30386,7 +30386,7 @@ fi
+ ;;
+ *)
+ if test x$build = x$host; then
+- export_sym_check="objdump${exeext} -T"
++ export_sym_check="$ac_cv_prog_OBJDUMP -T"
+ elif test x$host = x$target; then
+ export_sym_check="$gcc_cv_objdump -T"
+ else
+--- a/libcc1/configure
++++ b/libcc1/configure
+@@ -14819,7 +14819,7 @@ fi
+ ;;
+ *)
+ if test x$build = x$host; then
+- export_sym_check="objdump${exeext} -T"
++ export_sym_check="$ac_cv_prog_OBJDUMP -T"
+ elif test x$host = x$target; then
+ export_sym_check="$gcc_cv_objdump -T"
+ else
diff --git a/9.5.0/gentoo/30_all_glibc_236.patch b/9.5.0/gentoo/30_all_glibc_236.patch
new file mode 100644
index 0000000..4a8c697
--- /dev/null
+++ b/9.5.0/gentoo/30_all_glibc_236.patch
@@ -0,0 +1,39 @@
+https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=6bd956e31b2fb6fe1eee4eb1bf309247dcd19b23
+
+Fix build w/ glibc 2.36.
+
+From 6bd956e31b2fb6fe1eee4eb1bf309247dcd19b23 Mon Sep 17 00:00:00 2001
+From: Martin Liska <mliska@suse.cz>
+Date: Mon, 11 Jul 2022 22:03:14 +0200
+Subject: [PATCH] libsanitizer: cherry-pick 9cf13067cb5088626ba7 from upstream
+
+9cf13067cb5088626ba7ee1ec4c42ec59c7995a0 [sanitizer] Remove #include <linux/fs.h> to resolve fsconfig_command/mount_attr conflict with glibc 2.36
+
+(cherry picked from commit 2701442d0cf6292f6624443c15813d6d1a3562fe)
+--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
+@@ -72,7 +72,9 @@
+ #include <sys/vt.h>
+ #include <linux/cdrom.h>
+ #include <linux/fd.h>
++#if SANITIZER_ANDROID
+ #include <linux/fs.h>
++#endif
+ #include <linux/hdreg.h>
+ #include <linux/input.h>
+ #include <linux/ioctl.h>
+@@ -822,10 +824,10 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+ unsigned IOCTL_EVIOCGPROP = IOCTL_NOT_PRESENT;
+ unsigned IOCTL_EVIOCSKEYCODE_V2 = IOCTL_NOT_PRESENT;
+ #endif
+- unsigned IOCTL_FS_IOC_GETFLAGS = FS_IOC_GETFLAGS;
+- unsigned IOCTL_FS_IOC_GETVERSION = FS_IOC_GETVERSION;
+- unsigned IOCTL_FS_IOC_SETFLAGS = FS_IOC_SETFLAGS;
+- unsigned IOCTL_FS_IOC_SETVERSION = FS_IOC_SETVERSION;
++ unsigned IOCTL_FS_IOC_GETFLAGS = _IOR('f', 1, long);
++ unsigned IOCTL_FS_IOC_GETVERSION = _IOR('v', 1, long);
++ unsigned IOCTL_FS_IOC_SETFLAGS = _IOW('f', 2, long);
++ unsigned IOCTL_FS_IOC_SETVERSION = _IOW('v', 2, long);
+ unsigned IOCTL_GIO_CMAP = GIO_CMAP;
+ unsigned IOCTL_GIO_FONT = GIO_FONT;
+ unsigned IOCTL_GIO_UNIMAP = GIO_UNIMAP;
diff --git a/9.5.0/gentoo/31_all_msgfmt-libstdc++-link.patch b/9.5.0/gentoo/31_all_msgfmt-libstdc++-link.patch
new file mode 100644
index 0000000..0d2f113
--- /dev/null
+++ b/9.5.0/gentoo/31_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/9.5.0/gentoo/README.history b/9.5.0/gentoo/README.history
new file mode 100644
index 0000000..a084063
--- /dev/null
+++ b/9.5.0/gentoo/README.history
@@ -0,0 +1,34 @@
+2 08 Feb 202
+ + 31_all_msgfmt-libstdc++-link.patch
+
+1 15 Aug 2022
+ + 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
+ + 07_all_i386_libgcc_note.GNU-stack.patch
+ + 08_all_libiberty-asprintf.patch
+ + 09_all_libiberty-pic.patch
+ + 10_all_nopie-all-flags.patch
+ + 11_all_extra-options.patch
+ + 12_all_pr55930-dependency-tracking.patch
+ + 13_all_sh-drop-sysroot-suffix.patch
+ + 14_all_ia64-TEXTREL.patch
+ + 15_all_disable-systemtap-switch.patch
+ + 16_all_m68k-textrel-on-libgcc.patch
+ + 17_all_respect-build-cxxflags.patch
+ + 18_all_libgfortran-Werror.patch
+ + 19_all_libgomp-Werror.patch
+ + 20_all_libitm-Werror.patch
+ + 21_all_libatomic-Werror.patch
+ + 22_all_libbacktrace-Werror.patch
+ + 23_all_libsanitizer-Werror.patch
+ + 24_all_libstdcxx-no-vtv.patch
+ + 25_all_disable-riscv32-ABIs.patch
+ + 26_all_default_ssp-buffer-size.patch
+ + 27_all_hppa-faster-synth_mult.patch
+ + 28_all_libcpp-ar.patch
+ + 29_all_plugin-objdump.patch
+ + 30_all_glibc_236.patch
diff --git a/README b/README
index 12357f1..5a5d70b 100644
--- a/README
+++ b/README
@@ -16,8 +16,9 @@ Naming
Documention
-----------
All patches need a header describing what the patch does, where it came from,
-and all relevent URLs. Read http://dev.gentoo.org/~vapier/clean-patches and
-in particular use scrub_patch() or face the wrath.
+and all relevent URLs. Read https://dev.gentoo.org/~vapier/clean-patches (or
+https://devmanual.gentoo.org/ebuild-writing/misc-files/patches/index.html#clean-patch-howto)
+and in particular use scrub_patch() or face the wrath.
Update README.history whenever you add (+), remove (-), or update (U) a patch.
diff --git a/README.Gentoo.patches b/README.Gentoo.patches
index 0463ad7..c6d3511 100644
--- a/README.Gentoo.patches
+++ b/README.Gentoo.patches
@@ -3,11 +3,11 @@
================
Gentoo patchsets that have grown too large to keep on the rsync mirrors have
-been moved to our cvs tree. From there, we bundle up all the whee little
+been moved to our git tree. From there, we bundle up all the wee little
patches into a tarball and distribute it via our public mirroring system.
If you want specific info about a patch (like wtf it does or whose great idea
-it was to change the code), read the patch ! We try to fill out the top of
+it was to change the code), read the patch! We try to fill out the top of
them with useful info such as what it does, why it's needed, bug reports,
original creators, etc.
@@ -25,13 +25,9 @@ read-write git tree: git+ssh://git@git.gentoo.org/proj/gcc-patches.git
The patch naming/applying convention might be a little confusing to the Gentoo
outsider, so here's a quick rundown. Patch tarballs are applied in Gentoo via
-a helper command called "epatch". This command is pretty forgiving when it
-comes to applying patches.
+a helper command called "eapply".
-For example, it will autodetect the required -p# by starting at 0 and counting
-up until things apply. So do not expect a patch series to all be at the same -p
-level even if they all apply from the same source directory. Typically however,
-people will use -p0 or -p1.
+Patches should use -p1.
The epatch command will also use the -E option by default as the `patch` command
can be pretty picky about removing files. We just force the issue. If you
diff --git a/make-tarball.sh b/make-tarball.sh
index bf61b4e..79fc348 100755
--- a/make-tarball.sh
+++ b/make-tarball.sh
@@ -1,4 +1,25 @@
-#!/bin/bash
+#!/usr/bin/env bash
+
+XZ_OPT=${XZ_OPT-"-T0"}
+export XZ_OPT
+
+find_ebuild() {
+ local ver=$1
+
+ for ebuild in \
+ ${ver} \
+ ~/git/gentoo/sys-devel/gcc/gcc-${ver}.ebuild \
+ /usr/local/src/gentoo/repo/gentoo/sys-devel/gcc/gcc-${ver}.ebuild \
+ "$(portageq get_repo_path $(portageq envvar EPREFIX)/ gentoo)"/sys-devel/gcc/gcc-${ver}.ebuild \
+ /usr/portage/sys-devel/gcc/gcc-${ver}.ebuild \
+ ""
+ do
+ [[ -f ${ebuild} ]] && break
+ done
+
+ echo ${ebuild}
+}
+
if [[ $# -ne 1 ]] ; then
echo "Usage: $0 <gcc ebuild>"
@@ -6,15 +27,55 @@ if [[ $# -ne 1 ]] ; then
fi
ver=${1%/}
-for ebuild in \
- ${ver} \
- /usr/local/src/gentoo/repo/gentoo/sys-devel/gcc/gcc-${ver}.ebuild \
- "$(portageq get_repo_path $(portageq envvar EPREFIX)/ gentoo)"/sys-devel/gcc/gcc-${ver}.ebuild \
- /usr/portage/sys-devel/gcc/gcc-${ver}.ebuild \
- ""
-do
- [[ -f ${ebuild} ]] && break
-done
+orig_ver=${ver}
+
+ebuild=$(find_ebuild ${ver})
+
+# If it doesn't exist, check for a snapshot version. We want to be able
+# to input e.g. '11.3.0' and fall back to '11.2.1_p2021127' if it doesn't
+# exist, as that version will become 11.3.0 anyway.
+#
+# (_p# is going to be something like gcc-11.2.1_p20211127, where gcc 11.2.1
+# will never be released (but gcc 11.2 was) and gcc 11.3 is the next release.
+# For such cases, use 11.3 as ver.)
+had_pre=0
+had_p=0
+
+if [[ -z ${ebuild} ]] ; then
+ ver=${ver%%_pre*}
+
+ ver_major=$(echo ${ver} | cut -d'.' -f1)
+ ver_minor=$(($(echo ${ver} | cut -d'.' -f2) - 1))
+ ver="${ver_major}.${ver_minor}.1_pre*"
+ ebuild=$(find_ebuild ${ver})
+
+ [[ -n ${ebuild} ]] && had_pre=1
+fi
+
+if [[ -z ${ebuild} ]] ; then
+ ver=${orig_ver%%_p*}
+
+ ver_major=$(echo ${ver} | cut -d'.' -f1)
+ ver_minor=$(($(echo ${ver} | cut -d'.' -f2) - 1))
+ ver="${ver_major}.${ver_minor}.0_pre*"
+ ebuild=$(find_ebuild ${ver})
+
+ [[ -n ${ebuild} ]] && had_p=1
+fi
+
+if [[ -z ${ebuild} ]] ; then
+ ver=${orig_ver}
+ ver=${ver%%_p*}
+
+ ver_major=$(echo ${ver} | cut -d'.' -f1)
+ ver_minor=$(($(echo ${ver} | cut -d'.' -f2) - 1))
+ ver="${ver_major}.${ver_minor}.1_p*"
+
+ ebuild=$(find_ebuild ${ver})
+
+ [[ -n ${ebuild} ]] && had_p=1
+fi
+
if [[ -z ${ebuild} ]] ; then
echo "!!! gcc ebuild '${ver}' does not exist"
exit 1
@@ -27,6 +88,18 @@ gver=${gver%%.ebuild} # trim post .ebuild
gver=${gver%%-*} # trim any -r#'s
gver=${gver%%_pre*} # trim any _pre.*#'s
+# We use the same logic as finding the ebuild above for snapshots too
+gver=${gver%%_p*}
+if [[ ${had_pre} -eq 1 ]] ; then
+ gver_major=$(echo ${gver} | cut -d'.' -f1)
+ gver_minor=$(($(echo ${gver} | cut -d'.' -f2) + 1))
+ gver="${gver_major}.${gver_minor}.0"
+elif [[ ${had_p} -eq 1 ]] ; then
+ gver_major=$(echo ${gver} | cut -d'.' -f1)
+ gver_minor=$(($(echo ${gver} | cut -d'.' -f2) + 1))
+ gver="${gver_major}.${gver_minor}.0"
+fi
+
# trim branch update number
sgver=$(echo ${gver} | sed -e 's:[0-9]::g')
[[ ${#sgver} -gt 2 ]] \
@@ -40,7 +113,8 @@ eread() {
shift
done
}
-eread UCLIBC_VER PP_VER HTB_VER HTB_GCC_VER MAN_VER SPECS_VER SPECS_GCC_VER
+
+eread MUSL_VER PP_VER HTB_VER HTB_GCC_VER MAN_VER SPECS_VER SPECS_GCC_VER
[[ -n ${HTB_VER} && -z ${HTB_GCC_VER} ]] && HTB_GCC_VER=${gver}
PATCH_VER=$(awk '{print $1; exit}' ./${gver}/gentoo/README.history)
PIE_VER=$(awk '{print $1; exit}' ./${gver}/pie/README.history)
@@ -52,7 +126,7 @@ fi
echo "Building patches for gcc version ${gver}"
echo " - PATCH: ${PATCH_VER} (taken from ${gver}/gentoo/README.history)"
-echo " - UCLIBC: ${UCLIBC_VER}"
+echo " - MUSL: ${MUSL_VER}"
echo " - PIE: ${PIE_VER} (taken from ${gver}/pie/README.history)"
echo " - SPECS: ${SPECS_VER} (${SPECS_GCC_VER:-${gver}})"
echo " - SSP: ${PP_VER}"
@@ -60,13 +134,13 @@ echo " - BOUNDS: ${HTB_GCC_VER}-${HTB_VER}"
echo " - MAN: ${MAN_VER}"
rm -rf tmp
-rm -f gcc-${gver}-*.tar.bz2
+rm -f gcc-${gver}-*.tar.bz2 gcc-${gver}-*.tar.xz
# standard jobbies
-mkdir -p tmp/patch/exclude tmp/uclibc tmp/piepatch tmp/specs
+mkdir -p tmp/patch/exclude tmp/musl tmp/piepatch tmp/specs
[[ -n ${PATCH_VER} ]] && cp ${gver}/gentoo/*.patch ${gver}/gentoo/README.history README.Gentoo.patches tmp/patch/
[[ -d ${gver}/man ]] && cp -r ${gver}/man tmp/
-[[ -n ${UCLIBC_VER} ]] && cp -r ${gver}/uclibc/* README.Gentoo.patches tmp/uclibc/
+[[ -n ${MUSL_VER} ]] && cp -r ${gver}/musl/* README.Gentoo.patches tmp/musl/
[[ -n ${PIE_VER} ]] && cp -r ${gver}/pie/* README.Gentoo.patches tmp/piepatch/
[[ -n ${PP_VER} ]] && cp -r ${gver}/ssp tmp/
[[ -n ${SPECS_VER} ]] && cp -r ${SPECS_GCC_VER:-${gver}}/specs/* tmp/specs/
@@ -78,28 +152,28 @@ find tmp/ -name CVS -type d | xargs rm -rf
# standard jobbies
[[ -n ${PATCH_VER} ]] && {
-tar -jcf gcc-${sgver}-patches-${PATCH_VER}.tar.bz2 \
+tar -acf gcc-${sgver}-patches-${PATCH_VER}.tar.xz \
-C tmp patch || exit 1 ; }
-[[ -n ${UCLIBC_VER} ]] && {
-tar -jcf gcc-${sgver}-uclibc-patches-${UCLIBC_VER}.tar.bz2 \
- -C tmp uclibc || exit 1 ; }
+[[ -n ${MUSL_VER} ]] && {
+tar -acf gcc-${sgver}-musl-patches-${MUSL_VER}.tar.xz \
+ -C tmp musl || exit 1 ; }
[[ -n ${PIE_VER} ]] && {
-tar -jcf gcc-${sgver}-piepatches-v${PIE_VER}.tar.bz2 \
+tar -acf gcc-${sgver}-piepatches-v${PIE_VER}.tar.xz \
-C tmp piepatch || exit 1 ; }
[[ -n ${SPECS_VER} ]] && {
-tar -jcf gcc-${sgver}-specs-${SPECS_VER}.tar.bz2 \
+tar -acf gcc-${sgver}-specs-${SPECS_VER}.tar.xz \
-C tmp specs || exit 1 ; }
[[ -n ${PP_VER} ]] && {
mv tmp/ssp/protector.patch tmp/ssp/gcc-${gver}-ssp.patch
-tar -jcf gcc-${gver}-ssp-${PP_VER}.tar.bz2 \
+tar -acf gcc-${gver}-ssp-${PP_VER}.tar.xz \
-C tmp ssp || exit 1 ; }
[[ -d ${gver}/man ]] && {
-tar -jcf gcc-${MAN_VER}-manpages.tar.bz2 \
+tar -acf gcc-${MAN_VER}-manpages.tar.xz \
-C tmp/man . || exit 1 ; }
# extra cruft
[[ -n ${HTB_VER} ]] && {
-bzip2 tmp/bounds-checking-*.patch \
- && cp tmp/bounds-checking-*.patch.bz2 . || exit 1 ; }
+xz tmp/bounds-checking-*.patch \
+ && cp tmp/bounds-checking-*.patch.xz . || exit 1 ; }
rm -rf tmp
-du -b *.bz2
+du -b *.xz
diff --git a/scripts/README b/scripts/README
new file mode 100644
index 0000000..06c5f91
--- /dev/null
+++ b/scripts/README
@@ -0,0 +1 @@
+testsuite-management is imported from gcc.git (contrib/testsuite-management)
diff --git a/scripts/testsuite-management/validate_failures.py b/scripts/testsuite-management/validate_failures.py
new file mode 100755
index 0000000..f81ac4f
--- /dev/null
+++ b/scripts/testsuite-management/validate_failures.py
@@ -0,0 +1,733 @@
+#!/usr/bin/env python3
+
+# Script to compare testsuite failures against a list of known-to-fail
+# tests.
+
+# Contributed by Diego Novillo <dnovillo@google.com>
+#
+# Copyright (C) 2011-2024 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 COPYING. If not, write to
+# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+"""This script provides a coarser XFAILing mechanism that requires no
+detailed DejaGNU markings. This is useful in a variety of scenarios:
+
+- Development branches with many known failures waiting to be fixed.
+- Release branches with known failures that are not considered
+ important for the particular release criteria used in that branch.
+
+The script must be executed from the toplevel build directory. When
+executed it will:
+
+1- Determine the target built: TARGET
+2- Determine the source directory: SRCDIR
+3- Look for a failure manifest file in
+ <SRCDIR>/<MANIFEST_SUBDIR>/<MANIFEST_NAME>.xfail
+4- Collect all the <tool>.sum files from the build tree.
+5- Produce a report stating:
+ a- Failures expected in the manifest but not present in the build.
+ b- Failures in the build not expected in the manifest.
+6- If all the build failures are expected in the manifest, it exits
+ with exit code 0. Otherwise, it exits with error code 1.
+
+Manifest files contain expected DejaGNU results that are otherwise
+treated as failures.
+They may also contain additional text:
+
+# This is a comment. - self explanatory
+@include file - the file is a path relative to the includer
+@remove result text - result text is removed from the expected set
+"""
+
+import datetime
+import optparse
+import os
+import re
+import sys
+
+_VALID_TEST_RESULTS = [ 'FAIL', 'UNRESOLVED', 'XPASS', 'ERROR' ]
+# <STATE>: <NAME> <DESCRIPTION"
+_VALID_TEST_RESULTS_REX = re.compile('(%s):\s*(\S+)\s*(.*)'
+ % "|".join(_VALID_TEST_RESULTS))
+
+# Formats of .sum file sections
+_TOOL_LINE_FORMAT = '\t\t=== %s tests ===\n'
+_EXP_LINE_FORMAT = '\nRunning %s:%s ...\n'
+_SUMMARY_LINE_FORMAT = '\n\t\t=== %s Summary ===\n'
+
+# ... and their compiled regexs.
+_TOOL_LINE_REX = re.compile('^\t\t=== (.*) tests ===\n')
+# Match .exp file name, optionally prefixed by a "tool:" name and a
+# path ending with "testsuite/"
+_EXP_LINE_REX = re.compile('^Running (?:.*:)?(.*) \.\.\.\n')
+_SUMMARY_LINE_REX = re.compile('^\t\t=== (.*) Summary ===\n')
+
+# Subdirectory of srcdir in which to find the manifest file.
+_MANIFEST_SUBDIR = 'contrib/testsuite-management'
+
+# Pattern for naming manifest files.
+# The first argument should be the toplevel GCC(/GNU tool) source directory.
+# The second argument is the manifest subdir.
+# The third argument is the manifest target, which defaults to the target
+# triplet used during the build.
+_MANIFEST_PATH_PATTERN = '%s/%s/%s.xfail'
+
+# The options passed to the program.
+_OPTIONS = None
+
+def Error(msg):
+ print('error: %s' % msg, file=sys.stderr)
+ sys.exit(1)
+
+
+class TestResult(object):
+ """Describes a single DejaGNU test result as emitted in .sum files.
+
+ We are only interested in representing unsuccessful tests. So, only
+ a subset of all the tests are loaded.
+
+ The summary line used to build the test result should have this format:
+
+ attrlist | XPASS: gcc.dg/unroll_1.c (test for excess errors)
+ ^^^^^^^^ ^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^
+ optional state name description
+ attributes
+
+ Attributes:
+ attrlist: A comma separated list of attributes.
+ Valid values:
+ flaky Indicates that this test may not always fail. These
+ tests are reported, but their presence does not affect
+ the results.
+
+ expire=YYYYMMDD After this date, this test will produce an error
+ whether it is in the manifest or not.
+
+ state: One of UNRESOLVED, XPASS or FAIL.
+ name: File name for the test.
+ description: String describing the test (flags used, dejagnu message, etc)
+ ordinal: Monotonically increasing integer.
+ It is used to keep results for one .exp file sorted
+ by the order the tests were run.
+ tool: Top-level testsuite name (aka "tool" in DejaGnu parlance) of the test.
+ exp: Name of .exp testsuite file.
+ """
+
+ def __init__(self, summary_line, ordinal, tool, exp):
+ try:
+ (self.attrs, summary_line) = SplitAttributesFromSummaryLine(summary_line)
+ try:
+ (self.state,
+ self.name,
+ self.description) = _VALID_TEST_RESULTS_REX.match(summary_line).groups()
+ if _OPTIONS.srcpath_regex and _OPTIONS.srcpath_regex != '':
+ self.description = re.sub(_OPTIONS.srcpath_regex, '',
+ self.description)
+ except:
+ print('Failed to parse summary line: "%s"' % summary_line,
+ file=sys.stderr)
+ raise
+ self.ordinal = ordinal
+ if tool == None or exp == None:
+ # .sum file seem to be broken. There was no "tool" and/or "exp"
+ # lines preceding this result.
+ print(f'.sum file seems to be broken: tool="{tool}", exp="{exp}", summary_line="{summary_line}"',
+ file=sys.stderr)
+ raise
+ self.tool = tool
+ self.exp = exp
+ except ValueError:
+ Error('Cannot parse summary line "%s"' % summary_line)
+
+ if self.state not in _VALID_TEST_RESULTS:
+ Error('Invalid test result %s in "%s" (parsed as "%s")' % (
+ self.state, summary_line, self))
+
+ def __lt__(self, other):
+ if (self.tool != other.tool):
+ return self.tool < other.tool
+ if (self.exp != other.exp):
+ return self.exp < other.exp
+ if (self.name != other.name):
+ return self.name < other.name
+ return self.ordinal < other.ordinal
+
+ def __hash__(self):
+ return (hash(self.state) ^ hash(self.tool) ^ hash(self.exp)
+ ^ hash(self.name) ^ hash(self.description))
+
+ # Note that we don't include "attrs" in this comparison. This means that
+ # result entries "FAIL: test" and "flaky | FAIL: test" are considered
+ # the same. Therefore the ResultSet will preserve only the first occurence.
+ # In practice this means that flaky entries should preceed expected fails
+ # entries.
+ def __eq__(self, other):
+ return (self.state == other.state and
+ self.tool == other.tool and
+ self.exp == other.exp and
+ self.name == other.name and
+ self.description == other.description)
+
+ def __ne__(self, other):
+ return not (self == other)
+
+ def __str__(self):
+ attrs = ''
+ if self.attrs:
+ attrs = '%s | ' % self.attrs
+ return '%s%s: %s %s' % (attrs, self.state, self.name, self.description)
+
+ def ExpirationDate(self):
+ # Return a datetime.date object with the expiration date for this
+ # test result. Return None, if no expiration has been set.
+ if re.search(r'expire=', self.attrs):
+ expiration = re.search(r'expire=(\d\d\d\d)(\d\d)(\d\d)', self.attrs)
+ if not expiration:
+ Error('Invalid expire= format in "%s". Must be of the form '
+ '"expire=YYYYMMDD"' % self)
+ return datetime.date(int(expiration.group(1)),
+ int(expiration.group(2)),
+ int(expiration.group(3)))
+ return None
+
+ def HasExpired(self):
+ # Return True if the expiration date of this result has passed.
+ expiration_date = self.ExpirationDate()
+ if expiration_date:
+ return _OPTIONS.expiry_today_date > expiration_date
+
+
+class ResultSet(set):
+ """Describes a set of DejaGNU test results.
+ This set can be read in from .sum files or emitted as a manifest.
+
+ Attributes:
+ current_tool: Name of the current top-level DejaGnu testsuite.
+ current_exp: Name of the current .exp testsuite file.
+ testsuites: A set of (tool, exp) tuples representing encountered testsuites.
+ """
+
+ def __init__(self):
+ super().__init__()
+ self.ResetToolExp()
+ self.testsuites=set()
+
+ def update(self, other):
+ super().update(other)
+ self.testsuites.update(other.testsuites)
+
+ def ResetToolExp(self):
+ self.current_tool = None
+ self.current_exp = None
+
+ def MakeTestResult(self, summary_line, ordinal=-1):
+ return TestResult(summary_line, ordinal,
+ self.current_tool, self.current_exp)
+
+ def Print(self, outfile=sys.stdout):
+ current_tool = None
+ current_exp = None
+
+ for result in sorted(self):
+ if current_tool != result.tool:
+ current_tool = result.tool
+ outfile.write(_TOOL_LINE_FORMAT % current_tool)
+ if current_exp != result.exp:
+ current_exp = result.exp
+ outfile.write(_EXP_LINE_FORMAT % (current_tool, current_exp))
+ outfile.write('%s\n' % result)
+
+ outfile.write(_SUMMARY_LINE_FORMAT % 'Results')
+
+ # Check if testsuite of expected_result is present in current results.
+ # This is used to compare partial test results against a full manifest.
+ def HasTestsuite(self, expected_result):
+ return (expected_result.tool, expected_result.exp) in self.testsuites
+
+def GetMakefileValue(makefile_name, value_name):
+ if os.path.exists(makefile_name):
+ makefile = open(makefile_name, encoding='latin-1', mode='r')
+ for line in makefile:
+ if line.startswith(value_name):
+ (_, value) = line.split('=', 1)
+ value = value.strip()
+ makefile.close()
+ return value
+ makefile.close()
+ return None
+
+
+def ValidBuildDirectory(builddir):
+ if (not os.path.exists(builddir) or
+ not os.path.exists('%s/Makefile' % builddir)):
+ return False
+ return True
+
+
+def IsComment(line):
+ """Return True if line is a comment."""
+ return line.startswith('#')
+
+
+def SplitAttributesFromSummaryLine(line):
+ """Splits off attributes from a summary line, if present."""
+ if '|' in line and not _VALID_TEST_RESULTS_REX.match(line):
+ (attrs, line) = line.split('|', 1)
+ attrs = attrs.strip()
+ else:
+ attrs = ''
+ line = line.strip()
+ return (attrs, line)
+
+
+def IsInterestingResult(result_set, line):
+ """Return True if line is one of the summary lines we care about."""
+ (_, line) = SplitAttributesFromSummaryLine(line)
+ valid_result = bool(_VALID_TEST_RESULTS_REX.match(line))
+
+ # If there's no tool defined it means that either the results section hasn't
+ # started yet, or it is already over.
+ if valid_result and result_set.current_tool is None:
+ if _OPTIONS.verbosity >= 3:
+ print(f'WARNING: Result "{line}" found outside sum file boundaries.',
+ file=sys.stderr)
+ return False
+
+ return valid_result
+
+
+def IsToolLine(line):
+ """Return True if line mentions the tool (in DejaGnu terms) for the following tests."""
+ return bool(_TOOL_LINE_REX.match(line))
+
+
+def IsExpLine(line):
+ """Return True if line mentions the .exp file for the following tests."""
+ return bool(_EXP_LINE_REX.match(line))
+
+
+def IsSummaryLine(line):
+ """Return True if line starts .sum footer."""
+ return bool(_SUMMARY_LINE_REX.match(line))
+
+
+def IsInclude(line):
+ """Return True if line is an include of another file."""
+ return line.startswith("@include ")
+
+
+def GetIncludeFile(line, includer):
+ """Extract the name of the include file from line."""
+ includer_dir = os.path.dirname(includer)
+ include_file = line[len("@include "):]
+ return os.path.join(includer_dir, include_file.strip())
+
+
+def IsNegativeResult(line):
+ """Return True if line should be removed from the expected results."""
+ return line.startswith("@remove ")
+
+
+def GetNegativeResult(line):
+ """Extract the name of the negative result from line."""
+ line = line[len("@remove "):]
+ return line.strip()
+
+
+def ParseManifestWorker(result_set, manifest_path):
+ """Read manifest_path, adding the contents to result_set."""
+ if _OPTIONS.verbosity >= 5:
+ print('Parsing manifest file %s.' % manifest_path)
+ manifest_file = open(manifest_path, encoding='latin-1', mode='r')
+ for orig_line in manifest_file:
+ line = orig_line.strip()
+ if line == "":
+ pass
+ elif IsComment(line):
+ pass
+ elif IsNegativeResult(line):
+ result_set.remove(result_set.MakeTestResult(GetNegativeResult(line)))
+ elif IsInclude(line):
+ ParseManifestWorker(result_set, GetIncludeFile(line, manifest_path))
+ elif IsInterestingResult(result_set, line):
+ result = result_set.MakeTestResult(line)
+ if result.HasExpired():
+ # Ignore expired manifest entries.
+ if _OPTIONS.verbosity >= 4:
+ print('WARNING: Expected failure "%s" has expired.' % line.strip())
+ continue
+ result_set.add(result)
+ elif IsExpLine(orig_line):
+ result_set.current_exp = _EXP_LINE_REX.match(orig_line).groups()[0]
+ if _OPTIONS.srcpath_regex and _OPTIONS.srcpath_regex != '':
+ result_set.current_exp = re.sub(_OPTIONS.srcpath_regex, '',
+ result_set.current_exp)
+ elif IsToolLine(orig_line):
+ result_set.current_tool = _TOOL_LINE_REX.match(orig_line).groups()[0]
+ elif IsSummaryLine(orig_line):
+ result_set.ResetToolExp()
+ else:
+ Error('Unrecognized line in manifest file: %s' % line)
+ manifest_file.close()
+
+
+def ParseManifest(manifest_path):
+ """Create a set of TestResult instances from the given manifest file."""
+ result_set = ResultSet()
+ ParseManifestWorker(result_set, manifest_path)
+ return result_set
+
+
+def ParseSummary(sum_fname):
+ """Create a set of TestResult instances from the given summary file."""
+ result_set = ResultSet()
+ # ordinal is used when sorting the results so that tests within each
+ # .exp file are kept sorted.
+ ordinal=0
+ sum_file = open(sum_fname, encoding='latin-1', mode='r')
+ for line in sum_file:
+ if IsInterestingResult(result_set, line):
+ result = result_set.MakeTestResult(line, ordinal)
+ ordinal += 1
+ if result.HasExpired():
+ # ??? What is the use-case for this? How "expiry" annotations are
+ # ??? supposed to be added to .sum results?
+ # Tests that have expired are not added to the set of expected
+ # results. If they are still present in the set of actual results,
+ # they will cause an error to be reported.
+ if _OPTIONS.verbosity >= 4:
+ print('WARNING: Expected failure "%s" has expired.' % line.strip())
+ continue
+ result_set.add(result)
+ elif IsExpLine(line):
+ result_set.current_exp = _EXP_LINE_REX.match(line).groups()[0]
+ if _OPTIONS.srcpath_regex and _OPTIONS.srcpath_regex != '':
+ result_set.current_exp = re.sub(_OPTIONS.srcpath_regex, '',
+ result_set.current_exp)
+ result_set.testsuites.add((result_set.current_tool,
+ result_set.current_exp))
+ elif IsToolLine(line):
+ result_set.current_tool = _TOOL_LINE_REX.match(line).groups()[0]
+ result_set.current_exp = None
+ elif IsSummaryLine(line):
+ result_set.ResetToolExp()
+ sum_file.close()
+ return result_set
+
+
+def GetManifest(manifest_path):
+ """Build a set of expected failures from the manifest file.
+
+ Each entry in the manifest file should have the format understood
+ by the TestResult constructor.
+
+ If no manifest file exists for this target, it returns an empty set.
+ """
+ if os.path.exists(manifest_path):
+ return ParseManifest(manifest_path)
+ else:
+ return ResultSet()
+
+
+def CollectSumFiles(builddir):
+ sum_files = []
+ for root, dirs, files in os.walk(builddir):
+ for ignored in ('.svn', '.git'):
+ if ignored in dirs:
+ dirs.remove(ignored)
+ for fname in files:
+ if fname.endswith('.sum'):
+ sum_files.append(os.path.join(root, fname))
+ return sum_files
+
+
+def GetResults(sum_files, build_results = None):
+ """Collect all the test results from the given .sum files."""
+ if build_results == None:
+ build_results = ResultSet()
+ for sum_fname in sum_files:
+ if _OPTIONS.verbosity >= 3:
+ print('\t%s' % sum_fname)
+ build_results.update(ParseSummary(sum_fname))
+ return build_results
+
+
+def CompareResults(manifest, actual):
+ """Compare sets of results and return two lists:
+ - List of results present in ACTUAL but missing from MANIFEST.
+ - List of results present in MANIFEST but missing from ACTUAL.
+ """
+ # Collect all the actual results not present in the manifest.
+ # Results in this set will be reported as errors.
+ actual_vs_manifest = ResultSet()
+ for actual_result in actual:
+ if actual_result not in manifest:
+ actual_vs_manifest.add(actual_result)
+
+ # Collect all the tests in the manifest that were not found
+ # in the actual results.
+ # Results in this set will be reported as warnings (since
+ # they are expected failures that are not failing anymore).
+ manifest_vs_actual = ResultSet()
+ for expected_result in manifest:
+ # Ignore tests marked flaky.
+ if 'flaky' in expected_result.attrs:
+ continue
+ # We try to support comparing partial results vs full manifest
+ # (e.g., manifest has failures for gcc, g++, gfortran, but we ran only
+ # g++ testsuite). To achieve this we record encountered testsuites in
+ # actual.testsuites set, and then we check it here using HasTestsuite().
+ if expected_result not in actual and actual.HasTestsuite(expected_result):
+ manifest_vs_actual.add(expected_result)
+
+ return actual_vs_manifest, manifest_vs_actual
+
+
+def GetManifestPath(user_provided_must_exist):
+ """Return the full path to the manifest file."""
+ manifest_path = _OPTIONS.manifest
+ if manifest_path:
+ if user_provided_must_exist and not os.path.exists(manifest_path):
+ Error('Manifest does not exist: %s' % manifest_path)
+ return manifest_path
+ else:
+ (srcdir, target) = GetBuildData()
+ if not srcdir:
+ Error('Could not determine the location of GCC\'s source tree. '
+ 'The Makefile does not contain a definition for "srcdir".')
+ if not target:
+ Error('Could not determine the target triplet for this build. '
+ 'The Makefile does not contain a definition for "target_alias".')
+ return _MANIFEST_PATH_PATTERN % (srcdir, _MANIFEST_SUBDIR, target)
+
+
+def GetBuildData():
+ if not ValidBuildDirectory(_OPTIONS.build_dir):
+ # If we have been given a set of results to use, we may
+ # not be inside a valid GCC build directory. In that case,
+ # the user must provide both a manifest file and a set
+ # of results to check against it.
+ if not _OPTIONS.results or not _OPTIONS.manifest:
+ Error('%s is not a valid GCC top level build directory. '
+ 'You must use --manifest and --results to do the validation.' %
+ _OPTIONS.build_dir)
+ else:
+ return None, None
+ srcdir = GetMakefileValue('%s/Makefile' % _OPTIONS.build_dir, 'srcdir =')
+ target = GetMakefileValue('%s/Makefile' % _OPTIONS.build_dir, 'target_alias=')
+ if _OPTIONS.verbosity >= 3:
+ print('Source directory: %s' % srcdir)
+ print('Build target: %s' % target)
+ return srcdir, target
+
+
+def PrintSummary(summary):
+ summary.Print()
+
+def GetSumFiles(results, build_dir):
+ if not results:
+ if _OPTIONS.verbosity >= 3:
+ print('Getting actual results from build directory %s' % build_dir)
+ sum_files = CollectSumFiles(build_dir)
+ else:
+ if _OPTIONS.verbosity >= 3:
+ print('Getting actual results from user-provided results')
+ sum_files = results.split()
+ return sum_files
+
+
+def PerformComparison(expected, actual):
+ actual_vs_expected, expected_vs_actual = CompareResults(expected, actual)
+
+ if _OPTIONS.inverse_match:
+ # Switch results if inverse comparison is requested.
+ # This is useful in detecting flaky tests that FAILed in expected set,
+ # but PASSed in actual set.
+ actual_vs_expected, expected_vs_actual \
+ = expected_vs_actual, actual_vs_expected
+
+ tests_ok = True
+ if len(actual_vs_expected) > 0:
+ if _OPTIONS.verbosity >= 3:
+ print('\n\nUnexpected results in this build (new failures)')
+ if _OPTIONS.verbosity >= 1:
+ PrintSummary(actual_vs_expected)
+ tests_ok = False
+
+ if _OPTIONS.verbosity >= 2 and len(expected_vs_actual) > 0:
+ print('\n\nExpected results not present in this build (fixed tests)'
+ '\n\nNOTE: This is not a failure. It just means that these '
+ 'tests were expected\nto fail, but either they worked in '
+ 'this configuration or they were not\npresent at all.\n')
+ PrintSummary(expected_vs_actual)
+
+ if tests_ok and _OPTIONS.verbosity >= 3:
+ print('\nSUCCESS: No unexpected failures.')
+
+ return tests_ok
+
+
+def CheckExpectedResults():
+ manifest_path = GetManifestPath(True)
+ if _OPTIONS.verbosity >= 3:
+ print('Manifest: %s' % manifest_path)
+ manifest = GetManifest(manifest_path)
+ sum_files = GetSumFiles(_OPTIONS.results, _OPTIONS.build_dir)
+ actual = GetResults(sum_files)
+
+ if _OPTIONS.verbosity >= 5:
+ print('\n\nTests expected to fail')
+ PrintSummary(manifest)
+ print('\n\nActual test results')
+ PrintSummary(actual)
+
+ return PerformComparison(manifest, actual)
+
+
+def ProduceManifest():
+ manifest_path = GetManifestPath(False)
+ if _OPTIONS.verbosity >= 3:
+ print('Manifest: %s' % manifest_path)
+ if os.path.exists(manifest_path) and not _OPTIONS.force:
+ Error('Manifest file %s already exists.\nUse --force to overwrite.' %
+ manifest_path)
+
+ sum_files = GetSumFiles(_OPTIONS.results, _OPTIONS.build_dir)
+ actual = GetResults(sum_files)
+ manifest_file = open(manifest_path, encoding='latin-1', mode='w')
+ actual.Print(manifest_file)
+ actual.Print()
+ manifest_file.close()
+
+ return True
+
+
+def CompareBuilds():
+ sum_files = GetSumFiles(_OPTIONS.results, _OPTIONS.build_dir)
+ actual = GetResults(sum_files)
+
+ clean = ResultSet()
+
+ if _OPTIONS.manifest:
+ manifest_path = GetManifestPath(True)
+ if _OPTIONS.verbosity >= 3:
+ print('Manifest: %s' % manifest_path)
+ clean = GetManifest(manifest_path)
+
+ clean_sum_files = GetSumFiles(_OPTIONS.results, _OPTIONS.clean_build)
+ clean = GetResults(clean_sum_files, clean)
+
+ return PerformComparison(clean, actual)
+
+
+def Main(argv):
+ parser = optparse.OptionParser(usage=__doc__)
+
+ # Keep the following list sorted by option name.
+ parser.add_option('--build_dir', action='store', type='string',
+ dest='build_dir', default='.',
+ help='Build directory to check (default = .)')
+ parser.add_option('--clean_build', action='store', type='string',
+ dest='clean_build', default=None,
+ help='Compare test results from this build against '
+ 'those of another (clean) build. Use this option '
+ 'when comparing the test results of your patch versus '
+ 'the test results of a clean build without your patch. '
+ 'You must provide the path to the top directory of your '
+ 'clean build.')
+ parser.add_option('--force', action='store_true', dest='force',
+ default=False, help='When used with --produce_manifest, '
+ 'it will overwrite an existing manifest file '
+ '(default = False)')
+ parser.add_option('--expiry_date', action='store',
+ dest='expiry_today_date', default=None,
+ help='Use provided date YYYYMMDD to decide whether '
+ 'manifest entries with expiry settings have expired '
+ 'or not. (default = Use today date)')
+ parser.add_option('--srcpath', action='store', type='string',
+ dest='srcpath_regex', default='[^ ]+/testsuite/',
+ help='Remove provided path (can be a regex) from '
+ 'the result entries. This is useful to remove '
+ 'occasional filesystem path from the results. '
+ '(default = "[^ ]+/testsuite/")')
+ parser.add_option('--inverse_match', action='store_true',
+ dest='inverse_match', default=False,
+ help='Inverse result sets in comparison. '
+ 'Output unexpected passes as unexpected failures and '
+ 'unexpected failures as unexpected passes. '
+ 'This is used to catch FAIL->PASS flaky tests. '
+ '(default = False)')
+ parser.add_option('--manifest', action='store', type='string',
+ dest='manifest', default=None,
+ help='Name of the manifest file to use (default = '
+ 'taken from '
+ 'contrib/testsuite-managment/<target_alias>.xfail)')
+ parser.add_option('--produce_manifest', action='store_true',
+ dest='produce_manifest', default=False,
+ help='Produce the manifest for the current '
+ 'build (default = False)')
+ parser.add_option('--results', action='store', type='string',
+ dest='results', default=None, help='Space-separated list '
+ 'of .sum files with the testing results to check. The '
+ 'only content needed from these files are the lines '
+ 'starting with FAIL, XPASS or UNRESOLVED (default = '
+ '.sum files collected from the build directory).')
+ parser.add_option('--verbosity', action='store', dest='verbosity',
+ type='int', default=3, help='Verbosity level '
+ '(default = 3). Level 0: only error output, this is '
+ 'useful in scripting when only the exit code is used. '
+ 'Level 1: output unexpected failures. '
+ 'Level 2: output unexpected passes. '
+ 'Level 3: output helpful information. '
+ 'Level 4: output notification on expired entries. '
+ 'Level 5: output debug information.')
+ global _OPTIONS
+ (_OPTIONS, _) = parser.parse_args(argv[1:])
+
+ # Set "today" date to compare expiration entries against.
+ # Setting expiration date into the future allows re-detection of flaky
+ # tests and creating fresh entries for them before the current flaky entries
+ # expire.
+ if _OPTIONS.expiry_today_date:
+ today_date = re.search(r'(\d\d\d\d)(\d\d)(\d\d)',
+ _OPTIONS.expiry_today_date)
+ if not today_date:
+ Error('Invalid --expiry_today_date format "%s". Must be of the form '
+ '"expire=YYYYMMDD"' % _OPTIONS.expiry_today_date)
+ _OPTIONS.expiry_today_date=datetime.date(int(today_date.group(1)),
+ int(today_date.group(2)),
+ int(today_date.group(3)))
+ else:
+ _OPTIONS.expiry_today_date = datetime.date.today()
+
+ if _OPTIONS.produce_manifest:
+ retval = ProduceManifest()
+ elif _OPTIONS.clean_build:
+ retval = CompareBuilds()
+ else:
+ retval = CheckExpectedResults()
+
+ if retval:
+ return 0
+ else:
+ return 2
+
+
+if __name__ == '__main__':
+ retval = Main(sys.argv)
+ sys.exit(retval)
diff --git a/scripts/testsuite-management/x86_64-unknown-linux-gnu.xfail b/scripts/testsuite-management/x86_64-unknown-linux-gnu.xfail
new file mode 100644
index 0000000..fdb8268
--- /dev/null
+++ b/scripts/testsuite-management/x86_64-unknown-linux-gnu.xfail
@@ -0,0 +1,109 @@
+FAIL: g++.dg/guality/pr55665.C -O2 line 23 p == 40
+FAIL: g++.dg/guality/pr55665.C -O3 -fomit-frame-pointer line 23 p == 40
+FAIL: g++.dg/guality/pr55665.C -O3 -g line 23 p == 40
+XPASS: gcc.dg/guality/example.c -O0 execution test
+XPASS: gcc.dg/guality/example.c -O2 execution test
+XPASS: gcc.dg/guality/example.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test
+XPASS: gcc.dg/guality/guality.c -O0 execution test
+XPASS: gcc.dg/guality/guality.c -O1 execution test
+XPASS: gcc.dg/guality/guality.c -O2 execution test
+XPASS: gcc.dg/guality/guality.c -O3 -fomit-frame-pointer execution test
+XPASS: gcc.dg/guality/guality.c -O3 -g execution test
+XPASS: gcc.dg/guality/guality.c -Os execution test
+XPASS: gcc.dg/guality/guality.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test
+XPASS: gcc.dg/guality/guality.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test
+XPASS: gcc.dg/guality/inline-params.c -O2 execution test
+XPASS: gcc.dg/guality/inline-params.c -O3 -fomit-frame-pointer execution test
+XPASS: gcc.dg/guality/inline-params.c -O3 -g execution test
+XPASS: gcc.dg/guality/inline-params.c -Os execution test
+XPASS: gcc.dg/guality/inline-params.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test
+XPASS: gcc.dg/guality/pr41353-1.c -O0 line 28 j == 28 + 37
+XPASS: gcc.dg/guality/pr41353-1.c -O1 line 28 j == 28 + 37
+XPASS: gcc.dg/guality/pr41353-1.c -O2 line 28 j == 28 + 37
+XPASS: gcc.dg/guality/pr41353-1.c -O3 -fomit-frame-pointer line 28 j == 28 + 37
+XPASS: gcc.dg/guality/pr41353-1.c -O3 -g line 28 j == 28 + 37
+XPASS: gcc.dg/guality/pr41353-1.c -Os line 28 j == 28 + 37
+XPASS: gcc.dg/guality/pr41353-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none line 28 j == 28 + 37
+XPASS: gcc.dg/guality/pr41353-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects line 28 j == 28 + 37
+XPASS: gcc.dg/guality/pr41447-1.c -O0 execution test
+XPASS: gcc.dg/guality/pr41447-1.c -O1 execution test
+XPASS: gcc.dg/guality/pr41447-1.c -O2 execution test
+XPASS: gcc.dg/guality/pr41447-1.c -O3 -fomit-frame-pointer execution test
+XPASS: gcc.dg/guality/pr41447-1.c -O3 -g execution test
+XPASS: gcc.dg/guality/pr41447-1.c -Os execution test
+XPASS: gcc.dg/guality/pr41447-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test
+XPASS: gcc.dg/guality/pr41447-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test
+XPASS: gcc.dg/guality/pr41616-1.c -O0 execution test
+XPASS: gcc.dg/guality/pr41616-1.c -O1 execution test
+XPASS: gcc.dg/guality/pr41616-1.c -O2 execution test
+XPASS: gcc.dg/guality/pr41616-1.c -O3 -fomit-frame-pointer execution test
+XPASS: gcc.dg/guality/pr41616-1.c -O3 -g execution test
+XPASS: gcc.dg/guality/pr41616-1.c -Os execution test
+XPASS: gcc.dg/guality/pr41616-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none execution test
+FAIL: gcc.dg/guality/pr43051-1.c -O3 -fomit-frame-pointer -funroll-loops line 39 c == &a[0]
+FAIL: gcc.dg/guality/pr43051-1.c -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions line 39 c == &a[0]
+FAIL: gcc.dg/guality/pr48437.c -O2 -flto -fno-use-linker-plugin -flto-partition=none line 14 i == 0
+FAIL: gcc.dg/guality/pr48437.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects line 14 i == 0
+FAIL: gcc.dg/guality/pr54200.c -Os line 20 z == 3
+FAIL: gcc.dg/guality/pr54519-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none line 20 y == 25
+FAIL: gcc.dg/guality/pr54519-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none line 20 z == 6
+FAIL: gcc.dg/guality/pr54519-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none line 23 y == 117
+FAIL: gcc.dg/guality/pr54519-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none line 23 z == 8
+FAIL: gcc.dg/guality/pr54519-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects line 20 y == 25
+FAIL: gcc.dg/guality/pr54519-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects line 20 z == 6
+FAIL: gcc.dg/guality/pr54519-2.c -O2 -flto -fno-use-linker-plugin -flto-partition=none line 17 y == 25
+FAIL: gcc.dg/guality/pr54519-2.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects line 17 y == 25
+FAIL: gcc.dg/guality/pr54519-3.c -O2 -flto -fno-use-linker-plugin -flto-partition=none line 20 y == 25
+FAIL: gcc.dg/guality/pr54519-3.c -O2 -flto -fno-use-linker-plugin -flto-partition=none line 20 z == 6
+FAIL: gcc.dg/guality/pr54519-3.c -O2 -flto -fno-use-linker-plugin -flto-partition=none line 23 y == 117
+FAIL: gcc.dg/guality/pr54519-3.c -O2 -flto -fno-use-linker-plugin -flto-partition=none line 23 z == 8
+FAIL: gcc.dg/guality/pr54519-3.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects line 20 y == 25
+FAIL: gcc.dg/guality/pr54519-3.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects line 20 z == 6
+FAIL: gcc.dg/guality/pr54519-3.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects line 23 y == 117
+FAIL: gcc.dg/guality/pr54519-3.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects line 23 z == 8
+FAIL: gcc.dg/guality/pr54519-4.c -O2 -flto -fno-use-linker-plugin -flto-partition=none line 17 y == 25
+FAIL: gcc.dg/guality/pr54519-4.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects line 17 y == 25
+FAIL: gcc.dg/guality/pr54519-5.c -O2 -flto -fno-use-linker-plugin -flto-partition=none line 17 y == 25
+FAIL: gcc.dg/guality/pr54519-5.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects line 17 y == 25
+FAIL: gcc.dg/guality/pr54693-2.c -Os line 21 x == 10 - i
+FAIL: gcc.dg/guality/pr54693-2.c -Os line 21 y == 20 - 2 * i
+FAIL: gcc.dg/guality/vla-1.c -O0 line 17 sizeof (a) == 6
+FAIL: gcc.dg/guality/vla-1.c -O0 line 24 sizeof (a) == 17 * sizeof (short)
+FAIL: gcc.dg/guality/vla-1.c -O1 line 17 sizeof (a) == 6
+FAIL: gcc.dg/guality/vla-1.c -O1 line 24 sizeof (a) == 17 * sizeof (short)
+FAIL: gcc.dg/guality/vla-1.c -O2 line 17 sizeof (a) == 6
+FAIL: gcc.dg/guality/vla-1.c -O2 line 24 sizeof (a) == 17 * sizeof (short)
+FAIL: gcc.dg/guality/vla-1.c -O3 -fomit-frame-pointer line 17 sizeof (a) == 6
+FAIL: gcc.dg/guality/vla-1.c -O3 -fomit-frame-pointer line 24 sizeof (a) == 17 * sizeof (short)
+FAIL: gcc.dg/guality/vla-1.c -O3 -g line 17 sizeof (a) == 6
+FAIL: gcc.dg/guality/vla-1.c -O3 -g line 24 sizeof (a) == 17 * sizeof (short)
+FAIL: gcc.dg/guality/vla-1.c -Os line 17 sizeof (a) == 6
+FAIL: gcc.dg/guality/vla-1.c -Os line 24 sizeof (a) == 17 * sizeof (short)
+FAIL: gcc.dg/guality/vla-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none line 17 sizeof (a) == 6
+FAIL: gcc.dg/guality/vla-1.c -O2 -flto -fno-use-linker-plugin -flto-partition=none line 24 sizeof (a) == 17 * sizeof (short)
+FAIL: gcc.dg/guality/vla-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects line 17 sizeof (a) == 6
+FAIL: gcc.dg/guality/vla-1.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects line 24 sizeof (a) == 17 * sizeof (short)
+FAIL: gcc.dg/guality/vla-2.c -O0 line 16 sizeof (a) == 5 * sizeof (int)
+FAIL: gcc.dg/guality/vla-2.c -O0 line 25 sizeof (a) == 6 * sizeof (int)
+FAIL: gcc.dg/guality/vla-2.c -O1 line 16 sizeof (a) == 5 * sizeof (int)
+FAIL: gcc.dg/guality/vla-2.c -O1 line 25 sizeof (a) == 6 * sizeof (int)
+FAIL: gcc.dg/guality/vla-2.c -O2 line 16 sizeof (a) == 5 * sizeof (int)
+FAIL: gcc.dg/guality/vla-2.c -O2 line 25 sizeof (a) == 6 * sizeof (int)
+FAIL: gcc.dg/guality/vla-2.c -O3 -fomit-frame-pointer line 16 sizeof (a) == 5 * sizeof (int)
+FAIL: gcc.dg/guality/vla-2.c -O3 -fomit-frame-pointer line 25 sizeof (a) == 6 * sizeof (int)
+FAIL: gcc.dg/guality/vla-2.c -O3 -g line 16 sizeof (a) == 5 * sizeof (int)
+FAIL: gcc.dg/guality/vla-2.c -O3 -g line 25 sizeof (a) == 6 * sizeof (int)
+FAIL: gcc.dg/guality/vla-2.c -Os line 16 sizeof (a) == 5 * sizeof (int)
+FAIL: gcc.dg/guality/vla-2.c -Os line 25 sizeof (a) == 6 * sizeof (int)
+FAIL: gcc.dg/guality/vla-2.c -O2 -flto -fno-use-linker-plugin -flto-partition=none line 16 sizeof (a) == 5 * sizeof (int)
+FAIL: gcc.dg/guality/vla-2.c -O2 -flto -fno-use-linker-plugin -flto-partition=none line 25 sizeof (a) == 6 * sizeof (int)
+FAIL: gcc.dg/guality/vla-2.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects line 16 sizeof (a) == 5 * sizeof (int)
+FAIL: gcc.dg/guality/vla-2.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects line 25 sizeof (a) == 6 * sizeof (int)
+FAIL: gcc.dg/tree-ssa/slsr-39.c scan-tree-dump-times slsr "MEM" 4
+FAIL: libmudflap.c++/pass41-frag.cxx ( -O) execution test
+FAIL: libmudflap.c++/pass41-frag.cxx (-O2) execution test
+FAIL: libmudflap.c++/pass41-frag.cxx (-O3) execution test
+FAIL: libmudflap.c++/pass55-frag.cxx (-O3) execution test
+FAIL: sourcelocation output - source compiled test
+FAIL: sourcelocation -findirect-dispatch output - source compiled test
+FAIL: sourcelocation -O3 output - source compiled test