From e4e4d460b98a5d1f4a864104017c003d724967ed Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 16 Aug 2021 12:07:26 +0300 Subject: [PATCH] gcc: fix build with mold Mold fails to dynamically link GCC, static linking works fine. This should hopefully be fixed upstream soon. --- core/gcc/build | 8 +++++++- core/gcc/checksums | 1 + core/gcc/patches/static-bin.patch | 22 ++++++++++++++++++++++ core/gcc/sources | 1 + 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 core/gcc/patches/static-bin.patch diff --git a/core/gcc/build b/core/gcc/build index e3efc3ea..ca6e649d 100755 --- a/core/gcc/build +++ b/core/gcc/build @@ -24,9 +24,15 @@ case $2 in "$gcc_version"*) bootstrap=--disable-bootstrap esac -export libat_cv_have_ifunc=no +# Mold fails to dynamically link GCC, static linking works fine and does not +# result in a large size increase (quite resonable). This will hopefully be +# fixed upstream soon. +case $CFLAGS$CXXFLAGS$(ld --version) in *mold*) + patch -p1 < static-bin.patch +esac ../gcc/configure \ + libat_cv_have_ifunc=no \ --prefix=/usr \ --libexecdir=/usr/lib \ --mandir=/usr/share/man \ diff --git a/core/gcc/checksums b/core/gcc/checksums index ef9db7be..aa386078 100644 --- a/core/gcc/checksums +++ b/core/gcc/checksums @@ -3,3 +3,4 @@ fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2 0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f 17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459 765614b3396d70bca3fa0ae4a813632486c6dca320e2bd13c8c39dca52be4a4c +8ed32145f35344c58f365fa337a1db2eac147a7647847093ab34a44ca4ccdc34 diff --git a/core/gcc/patches/static-bin.patch b/core/gcc/patches/static-bin.patch new file mode 100644 index 00000000..9bb57220 --- /dev/null +++ b/core/gcc/patches/static-bin.patch @@ -0,0 +1,22 @@ +diff --git a/gcc/gcc/Makefile.in b/gcc/gcc/Makefile.in +index 8a5fb3f..9b12f75 100644 +--- a/gcc/gcc/Makefile.in ++++ b/gcc/gcc/Makefile.in +@@ -1060,7 +1060,7 @@ ALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS) + ALL_COMPILERFLAGS = $(ALL_CXXFLAGS) + + # This is the variable to use when using $(LINKER). +-ALL_LINKERFLAGS = $(ALL_CXXFLAGS) ++ALL_LINKERFLAGS = $(ALL_CXXFLAGS) -static + + # Build and host support libraries. + +@@ -2967,7 +2967,7 @@ gengtype$(exeext) : gengtype.o gengtype-lex.o gengtype-parse.o \ + # Rule for the generator programs: + $(genprog:%=build/gen%$(build_exeext)): build/gen%$(build_exeext): build/gen%.o $(BUILD_LIBDEPS) + +$(LINKER_FOR_BUILD) $(BUILD_LINKERFLAGS) $(BUILD_LDFLAGS) -o $@ \ +- $(filter-out $(BUILD_LIBDEPS), $^) $(BUILD_LIBS) ++ $(filter-out $(BUILD_LIBDEPS), $^) $(BUILD_LIBS) -static + + omp-general.o: omp-device-properties.h + diff --git a/core/gcc/sources b/core/gcc/sources index 73217e3c..04381409 100644 --- a/core/gcc/sources +++ b/core/gcc/sources @@ -3,3 +3,4 @@ https://ftp.gnu.org/gnu/gmp/gmp-6.2.1.tar.xz gcc/gmp https://ftp.gnu.org/gnu/mpfr/mpfr-4.1.0.tar.xz gcc/mpfr https://ftp.gnu.org/gnu/mpc/mpc-1.2.1.tar.gz gcc/mpc files/c99 +patches/static-bin.patch