From 44363a7dc862fb1277cccb83a9358567ced811b7 Mon Sep 17 00:00:00 2001 From: q66 Date: Wed, 10 Jun 2020 04:40:40 +0200 Subject: [PATCH] gcc: expand libssp musl patch to disable splitstack on musl/x86 This doesn't seem to affect our actual native gcc build, since it compiles gotools just fine, which means the macro is never triggered. However, it does help our x86 crosstoolchains, as otherwise the gccgo crosscompiler seems to think that -fsplit-stack can be passed. This is because of gcc/go/gospec.c, which contains code like this: ``` supports_split_stack = 1; /* If we are linking, pass -fsplit-stack if it is supported. */ if ((library >= 0) && supports_split_stack) { generate_option (OPT_fsplit_stack, NULL, 1, CL_DRIVER, &new_decoded_options[j]); j++; } ``` Also, refactor gccgo enablement code and reenable it on i686-musl. Fixes https://github.com/void-linux/void-packages/issues/22742 --- srcpkgs/gcc/files/libssp-musl.patch | 34 +++++++++++++++++++++++++++-- srcpkgs/gcc/template | 32 +++++++++++++-------------- 2 files changed, 48 insertions(+), 18 deletions(-) diff --git a/srcpkgs/gcc/files/libssp-musl.patch b/srcpkgs/gcc/files/libssp-musl.patch index 9729a49f09..8a692c0d66 100644 --- a/srcpkgs/gcc/files/libssp-musl.patch +++ b/srcpkgs/gcc/files/libssp-musl.patch @@ -1,5 +1,9 @@ ---- gcc-6.1.0/gcc/gcc.c.orig -+++ gcc-6.1.0/gcc/gcc.c +First part taken from Alpine. + +Second part added to prevent gccgo from thinking it can -fsplit-stack on musl. + +--- a/gcc/gcc.c ++++ b/gcc/gcc.c @@ -876,9 +876,8 @@ #endif @@ -11,3 +15,29 @@ #else #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ "|fstack-protector-strong|fstack-protector-explicit" \ +--- a/gcc/config/i386/gnu-user-common.h ++++ b/gcc/config/i386/gnu-user-common.h +@@ -64,9 +64,3 @@ along with GCC; see the file COPYING3. If not see + + /* Static stack checking is supported by means of probes. */ + #define STACK_CHECK_STATIC_BUILTIN 1 +- +-/* We only build the -fsplit-stack support in libgcc if the +- assembler has full support for the CFI directives. */ +-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE +-#define TARGET_CAN_SPLIT_STACK +-#endif +--- a/gcc/config/i386/gnu.h ++++ b/gcc/config/i386/gnu.h +@@ -40,11 +40,6 @@ along with GCC. If not, see . + /* i386 glibc provides __stack_chk_guard in %gs:0x14. */ + #define TARGET_THREAD_SSP_OFFSET 0x14 + +-/* We only build the -fsplit-stack support in libgcc if the +- assembler has full support for the CFI directives. */ +-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE +-#define TARGET_CAN_SPLIT_STACK +-#endif + /* We steal the last transactional memory word. */ + #define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30 + #endif diff --git a/srcpkgs/gcc/template b/srcpkgs/gcc/template index ae3947b47b..ead6f05a49 100644 --- a/srcpkgs/gcc/template +++ b/srcpkgs/gcc/template @@ -36,11 +36,13 @@ _have_gccgo=yes # MIPS does not have libucontext yet # no support for ppcle in gccgo (missing GOARCH and stuff) case "$XBPS_TARGET_MACHINE" in - i686-musl|mips*-musl|ppcle*) _have_gccgo=no ;; + mips*-musl|ppcle*) _have_gccgo=no ;; esac if [ "$CHROOT_READY" ]; then hostmakedepends="tar texinfo perl flex" +else + _have_gccgo=no fi makedepends="zlib-devel" depends="binutils libgcc-devel-${version}_${revision} @@ -75,12 +77,13 @@ fi if [ "$CHROOT_READY" ]; then subpackages+=" gcc-fortran libgfortran-devel libgfortran" subpackages+=" gcc-objc gcc-objc++ libobjc-devel libobjc" - if [ "$_have_gccgo" = "yes" ]; then - subpackages+=" gcc-go gcc-go-tools libgo-devel libgo" - # we need this for gcc-go on musl - if [ "$XBPS_TARGET_LIBC" = "musl" ]; then - makedepends+=" libucontext-devel" - fi +fi + +if [ "$_have_gccgo" = "yes" ]; then + subpackages+=" gcc-go gcc-go-tools libgo-devel libgo" + # we need this for gcc-go on musl + if [ "$XBPS_TARGET_LIBC" = "musl" ]; then + makedepends+=" libucontext-devel" fi fi @@ -245,18 +248,15 @@ do_configure() { _args+=" --enable-fast-character" fi - if [ "$_have_gccgo" = "yes" -a -n "$CHROOT_READY" ]; then + if [ "$_have_gccgo" = "yes" ]; then _langs+=",go" fi - case "$XBPS_TARGET_MACHINE" in - *-musl) _args+=" --disable-libsanitizer";; - esac - case "$XBPS_TARGET_MACHINE" in - *-musl) _args+=" --disable-symvers" - _args+=" libat_cv_have_ifunc=no" - ;; - esac + if [ "$XBPS_TARGET_LIBC" = "musl" ]; then + _args+=" --disable-libsanitizer" + _args+=" --disable-symvers" + _args+=" libat_cv_have_ifunc=no" + fi case "$XBPS_TARGET_MACHINE" in ppc*) _args+=" --disable-vtable-verify";;