commit:     1e1dff79a6968283d142703fb8b0ab2b46dccff8
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Apr 24 23:15:17 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Apr 25 00:13:49 2022 +0000
URL:        https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=1e1dff79

12.0.0: cut patchset 5

- Rebase 20_all_libstdcxx-no-vtv.patch
- Add rebased musl patches

Bug: https://bugs.gentoo.org/840128
Closes: https://bugs.gentoo.org/840170
Signed-off-by: Sam James <sam <AT> gentoo.org>

 12.0.0/gentoo/20_all_libstdcxx-no-vtv.patch        | 12 +--
 12.0.0/gentoo/README.history                       | 19 +++++
 12.0.0/musl/25_all_multilib_pure64.patch           | 89 ++++++++++++++++++++++
 12.0.0/musl/50_all_cpu_indicator.patch             | 35 +++++++++
 12.0.0/musl/50_all_posix_memalign.patch            | 29 +++++++
 .../nocross/50_all_libssp_unconditionally.patch    | 24 ++++++
 make-tarball.sh                                    | 30 +++++++-
 7 files changed, 228 insertions(+), 10 deletions(-)

diff --git a/12.0.0/gentoo/20_all_libstdcxx-no-vtv.patch 
b/12.0.0/gentoo/20_all_libstdcxx-no-vtv.patch
index e557b35..2719e2d 100644
--- a/12.0.0/gentoo/20_all_libstdcxx-no-vtv.patch
+++ b/12.0.0/gentoo/20_all_libstdcxx-no-vtv.patch
@@ -10,9 +10,9 @@ Bug: https://gcc.gnu.org/PR85884
        $(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
 @@ -642,7 +642,6 @@ CXXLINK = \
@@ -20,9 +20,9 @@ Bug: https://gcc.gnu.org/PR85884
        $(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
 @@ -214,5 +214,4 @@ CXXLINK = \

diff --git a/12.0.0/gentoo/README.history b/12.0.0/gentoo/README.history
index 8d046ab..383b57a 100644
--- a/12.0.0/gentoo/README.history
+++ b/12.0.0/gentoo/README.history
@@ -1,3 +1,22 @@
+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

diff --git a/12.0.0/musl/25_all_multilib_pure64.patch 
b/12.0.0/musl/25_all_multilib_pure64.patch
new file mode 100644
index 0000000..4ff0a25
--- /dev/null
+++ b/12.0.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.0.0/musl/50_all_cpu_indicator.patch 
b/12.0.0/musl/50_all_cpu_indicator.patch
new file mode 100644
index 0000000..a7d199f
--- /dev/null
+++ b/12.0.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.0.0/musl/50_all_posix_memalign.patch 
b/12.0.0/musl/50_all_posix_memalign.patch
new file mode 100644
index 0000000..a288e1d
--- /dev/null
+++ b/12.0.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.0.0/musl/nocross/50_all_libssp_unconditionally.patch 
b/12.0.0/musl/nocross/50_all_libssp_unconditionally.patch
new file mode 100644
index 0000000..a3b5984
--- /dev/null
+++ b/12.0.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 <[email protected]>
+
+"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/make-tarball.sh b/make-tarball.sh
index 1d08c02..5a8dd77 100755
--- a/make-tarball.sh
+++ b/make-tarball.sh
@@ -1,4 +1,5 @@
 #!/bin/bash
+#set -x
 
 find_ebuild() {
        local ver=$1
@@ -33,14 +34,29 @@ ebuild=$(find_ebuild ${ver})
 # (_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%%_p*}
+       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=${ver%%_p*}
+
+       ver_major=$(echo ${ver} | cut -d'.' -f1)
+       ver_minor=$(($(echo ${ver} | cut -d'.' -f3) - 1))
        ver="${ver_major}.${ver_minor}.1_p*"
 
        ebuild=$(find_ebuild ${ver})
+
+       [[ -n ${ebuild} ]] && had_p=1
 fi
 
 if [[ -z ${ebuild} ]] ; then
@@ -57,9 +73,15 @@ gver=${gver%%_pre*}        # trim any _pre.*#'s
 
 # We use the same logic as finding the ebuild above for snapshots too
 gver=${gver%%_p*}
-gver_major=$(echo ${gver} | cut -d'.' -f1)
-gver_minor=$(($(echo ${gver} | cut -d'.' -f2) + 1))
-gver="${gver_major}.${gver_minor}.0"
+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'.' -f3) - 1))
+       gver="${gver_major}.${gver_minor}.0"
+fi
 
 # trim branch update number
 sgver=$(echo ${gver} | sed -e 's:[0-9]::g')

Reply via email to