From a9db2cc382eb49be525ec3cb28c3987b20366f75 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mat=C3=ADas=20Fonzo?= Date: Mon, 22 Feb 2021 17:22:14 -0300 Subject: [PATCH] Enhance toolchain MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Matías Fonzo --- patches/binutils/binutils-export-demangle.h.patch | 33 +++++++++++ .../binutils/binutils-gold-warn-unsupported.patch | 66 ++++++++++++++++++++++ patches/binutils/binutils-no-config-h-check.patch | 28 +++++++++ patches/binutils/binutils-use-long-long.patch | 38 +++++++++++++ recipes/devel/binutils/recipe | 23 ++++---- recipes/devel/gcc/recipe | 6 +- recipes/devel/valgrind/recipe | 4 +- stages/0/01-binutils | 1 - stages/0/03-gcc-static | 1 + stages/0/05-gcc-final | 1 + stages/1/05-binutils | 9 ++- stages/1/06-gcc | 29 ++++------ 12 files changed, 204 insertions(+), 35 deletions(-) create mode 100644 patches/binutils/binutils-export-demangle.h.patch create mode 100644 patches/binutils/binutils-gold-warn-unsupported.patch create mode 100644 patches/binutils/binutils-no-config-h-check.patch create mode 100644 patches/binutils/binutils-use-long-long.patch diff --git a/patches/binutils/binutils-export-demangle.h.patch b/patches/binutils/binutils-export-demangle.h.patch new file mode 100644 index 00000000..6e47d7d9 --- /dev/null +++ b/patches/binutils/binutils-export-demangle.h.patch @@ -0,0 +1,33 @@ +diff -rup binutils.orig/bfd/Makefile.am binutils-2.32/bfd/Makefile.am +--- binutils.orig/bfd/Makefile.am 2019-02-08 12:22:51.395684251 +0000 ++++ binutils-2.32/bfd/Makefile.am 2019-02-08 12:22:53.970664973 +0000 +@@ -33,7 +33,7 @@ bfdlibdir = @bfdlibdir@ + bfdincludedir = @bfdincludedir@ + bfdlib_LTLIBRARIES = libbfd.la + bfdinclude_HEADERS = $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h \ +- bfd_stdint.h $(INCDIR)/diagnostics.h $(INCDIR)/bfdlink.h ++ bfd_stdint.h $(INCDIR)/diagnostics.h $(INCDIR)/bfdlink.h $(INCDIR)/demangle.h + else !INSTALL_LIBBFD + # Empty these so that the respective installation directories will not be created. + bfdlibdir = +diff -rup binutils.orig/bfd/Makefile.in binutils-2.32/bfd/Makefile.in +--- binutils.orig/bfd/Makefile.in 2019-02-08 12:21:35.291254044 +0000 ++++ binutils-2.32/bfd/Makefile.in 2019-02-08 12:22:10.163992947 +0000 +@@ -249,7 +249,7 @@ am__can_run_installinfo = \ + esac + am__bfdinclude_HEADERS_DIST = $(INCDIR)/plugin-api.h bfd.h \ + $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h bfd_stdint.h \ +- $(INCDIR)/diagnostics.h $(INCDIR)/bfdlink.h ++ $(INCDIR)/diagnostics.h $(INCDIR)/bfdlink.h $(INCDIR)/demangle.h + HEADERS = $(bfdinclude_HEADERS) + RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +@@ -468,7 +468,7 @@ libbfd_la_LDFLAGS = $(am__append_1) -rel + @INSTALL_LIBBFD_FALSE@bfdinclude_HEADERS = $(am__append_2) + @INSTALL_LIBBFD_TRUE@bfdinclude_HEADERS = $(BFD_H) \ + @INSTALL_LIBBFD_TRUE@ $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h \ +-@INSTALL_LIBBFD_TRUE@ bfd_stdint.h $(INCDIR)/diagnostics.h \ ++@INSTALL_LIBBFD_TRUE@ bfd_stdint.h $(INCDIR)/diagnostics.h $(INCDIR)/demangle.h \ + @INSTALL_LIBBFD_TRUE@ $(INCDIR)/bfdlink.h $(am__append_2) + @INSTALL_LIBBFD_FALSE@rpath_bfdlibdir = @bfdlibdir@ + @INSTALL_LIBBFD_FALSE@noinst_LTLIBRARIES = libbfd.la diff --git a/patches/binutils/binutils-gold-warn-unsupported.patch b/patches/binutils/binutils-gold-warn-unsupported.patch new file mode 100644 index 00000000..8e00aa3d --- /dev/null +++ b/patches/binutils/binutils-gold-warn-unsupported.patch @@ -0,0 +1,66 @@ +Only in binutils-2.34/gold: autom4te.cache +diff -rup binutils.orig/gold/configure binutils-2.34/gold/configure +--- binutils.orig/gold/configure 2020-04-20 12:35:13.048297305 +0100 ++++ binutils-2.34/gold/configure 2020-04-20 14:02:06.743725696 +0100 +@@ -5180,7 +5180,8 @@ for targ in $target $canon_targets; do + . ${srcdir}/configure.tgt + + if test "$targ_obj" = "UNKNOWN"; then +- as_fn_error $? "\"unsupported target $targ\"" "$LINENO" 5 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"unsupported target $targ\"" >&5 ++$as_echo "$as_me: WARNING: \"unsupported target $targ\"" >&2;} + else + targetobjs="$targetobjs ${targ_obj}.\$(OBJEXT)" + if test "$targ_extra_obj" != ""; then +diff -rup binutils.orig/gold/configure.ac binutils-2.34/gold/configure.ac +--- binutils.orig/gold/configure.ac 2020-04-20 12:35:13.050297291 +0100 ++++ binutils-2.34/gold/configure.ac 2020-04-20 14:01:46.435868770 +0100 +@@ -181,7 +181,7 @@ for targ in $target $canon_targets; do + . ${srcdir}/configure.tgt + + if test "$targ_obj" = "UNKNOWN"; then +- AC_MSG_ERROR("unsupported target $targ") ++ AC_MSG_WARN("unsupported target $targ") + else + targetobjs="$targetobjs ${targ_obj}.\$(OBJEXT)" + if test "$targ_extra_obj" != ""; then +--- binutils.orig/ld/configure.tgt 2020-04-20 12:35:12.465301359 +0100 ++++ binutils-2.34/ld/configure.tgt 2020-04-20 14:17:52.123066333 +0100 +@@ -220,7 +220,7 @@ bfin-*-linux-uclibc*) targ_emul=elf32bfi + targ_extra_emuls="elf32bfin" + targ_extra_libpath=$targ_extra_emuls + ;; +-bpf-*-*) targ_emul=elf64bpf ++bpf-* | bpf-*-*) targ_emul=elf64bpf + ;; + cr16-*-elf*) targ_emul=elf32cr16 + ;; +@@ -1026,7 +1026,7 @@ z8k-*-coff) targ_emul=z8002 + targ_extra_ofiles= + ;; + *) +- echo 2>&1 "*** ld does not support target ${targ}" ++ echo 2>&1 "*** ld does not support target '${targ}' NO REALLY" + echo 2>&1 "*** see ld/configure.tgt for supported targets" + exit 1 + +--- binutils.orig/bfd/config.bfd 2020-04-20 12:35:13.038297375 +0100 ++++ binutils-2.34/bfd/config.bfd 2020-04-20 14:25:26.452869193 +0100 +@@ -473,7 +473,7 @@ case "${targ}" in + ;; + + #ifdef BFD64 +- bpf-*-none) ++ bpf-*-none | bpf-*) + targ_defvec=bpf_elf64_le_vec + targ_selvecs=bpf_elf64_be_vec + targ_underscore=yes +@@ -1427,7 +1427,7 @@ case "${targ}" in + ;; + + *) +- echo 1>&2 "*** BFD does not support target ${targ}." ++ echo 1>&2 "*** BFD does not support target '${targ}'. Honest." + echo 1>&2 "*** Look in bfd/config.bfd for supported targets." + exit 1 + ;; diff --git a/patches/binutils/binutils-no-config-h-check.patch b/patches/binutils/binutils-no-config-h-check.patch new file mode 100644 index 00000000..c89195a5 --- /dev/null +++ b/patches/binutils/binutils-no-config-h-check.patch @@ -0,0 +1,28 @@ +--- a/bfd/bfd-in.h 2012-08-02 10:56:34.561769686 +0100 ++++ b/bfd/bfd-in.h 2012-08-02 11:13:27.134797755 +0100 +@@ -25,11 +25,6 @@ + #ifndef __BFD_H_SEEN__ + #define __BFD_H_SEEN__ + +-/* PR 14072: Ensure that config.h is included first. */ +-#if !defined PACKAGE && !defined PACKAGE_VERSION +-#error config.h must be included before this header +-#endif +- + #ifdef __cplusplus + extern "C" { + #endif +--- a/bfd/bfd-in2.h 2012-08-02 10:56:34.349769680 +0100 ++++ b/bfd/bfd-in2.h 2012-08-02 11:13:40.015798113 +0100 +@@ -32,11 +32,6 @@ + #ifndef __BFD_H_SEEN__ + #define __BFD_H_SEEN__ + +-/* PR 14072: Ensure that config.h is included first. */ +-#if !defined PACKAGE && !defined PACKAGE_VERSION +-#error config.h must be included before this header +-#endif +- + #ifdef __cplusplus + extern "C" { + #endif diff --git a/patches/binutils/binutils-use-long-long.patch b/patches/binutils/binutils-use-long-long.patch new file mode 100644 index 00000000..1ea74181 --- /dev/null +++ b/patches/binutils/binutils-use-long-long.patch @@ -0,0 +1,38 @@ +diff -up binutils-2.25.orig/bfd/configure.ac binutils-2.25/bfd/configure.ac +--- binutils-2.25.orig/bfd/configure.ac 2014-12-24 10:34:45.590491143 +0000 ++++ binutils-2.25/bfd/configure.ac 2014-12-24 10:36:12.997981992 +0000 +@@ -183,11 +183,13 @@ if test "x${ac_cv_sizeof_long}" = "x8"; + BFD_HOST_64BIT_LONG=1 + test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long" + test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long" +-elif test "x${ac_cv_sizeof_long_long}" = "x8"; then ++fi ++if test "x${ac_cv_sizeof_long_long}" = "x8"; then + BFD_HOST_64BIT_LONG_LONG=1 + test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long long" + test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long long" +- if test "x${ac_cv_sizeof_void_p}" = "x8"; then ++ if test "x${ac_cv_sizeof_void_p}" = "x8" \ ++ -a "x${ac_cv_sizeof_long}" != "x8"; then + BFD_HOSTPTR_T="unsigned long long" + fi + fi +diff -up ../binutils-2.20.51.0.7.original/bfd/configure ./bfd/configure +--- a/bfd/configure 2010-04-08 15:23:58.000000000 +0100 ++++ b/bfd/configure 2010-04-08 15:24:06.000000000 +0100 +@@ -12819,11 +12819,13 @@ + BFD_HOST_64BIT_LONG=1 + test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long" + test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long" +-elif test "x${ac_cv_sizeof_long_long}" = "x8"; then ++fi ++if test "x${ac_cv_sizeof_long_long}" = "x8"; then + BFD_HOST_64BIT_LONG_LONG=1 + test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long long" + test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long long" +- if test "x${ac_cv_sizeof_void_p}" = "x8"; then ++ if test "x${ac_cv_sizeof_void_p}" = "x8" \ ++ -a "x${ac_cv_sizeof_long}" != "x8"; then + BFD_HOSTPTR_T="unsigned long long" + fi + fi diff --git a/recipes/devel/binutils/recipe b/recipes/devel/binutils/recipe index 29a2ed9c..c78e0218 100644 --- a/recipes/devel/binutils/recipe +++ b/recipes/devel/binutils/recipe @@ -19,7 +19,7 @@ set -e program=binutils version=2.35.2 -release=1 +release=2 # Define a category for the output of the package name pkgcategory=devel @@ -55,6 +55,12 @@ build() # Set sane permissions chmod -R u+w,go-w,a+rX-s . + # Apply patches from Fedora (Nick Clifton) + patch -Np1 -i "${worktree}/patches/binutils/binutils-export-demangle.h.patch" + patch -Np1 -i "${worktree}/patches/binutils/binutils-no-config-h-check.patch" + patch -Np1 -i "${worktree}/patches/binutils/binutils-gold-warn-unsupported.patch" + patch -Np1 -i "${worktree}/patches/binutils/binutils-use-long-long.patch" + #patch -Np1 -i "${worktree}/patches/binutils/branch-updates.diff" # Create a separate build directory @@ -75,7 +81,8 @@ build() MACHINE="$(gcc -dumpmachine)" ../configure CPPFLAGS="$QICPPFLAGS" \ - CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \ + CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" \ + LDFLAGS="$(echo $QILDFLAGS | sed 's/-s//')" \ $configure_args \ $multilib_options \ --libdir=/usr/lib${libSuffix} \ @@ -94,9 +101,7 @@ build() --enable-plugins \ --enable-64-bit-bfd \ --enable-install-libiberty \ - --enable-initfini-array \ --disable-werror \ - --disable-separate-code \ --disable-compressed-debug-sections \ --with-system-zlib \ --build=$MACHINE \ @@ -107,14 +112,10 @@ build() #make -j${jobs} check make -j${jobs} tooldir=/usr/${MACHINE} DESTDIR="$destdir" install - # Strip remaining binaries and libraries find "$destdir" -type f -print0 | xargs -0 file | \ awk '/ELF/ && /executable/ || /shared object/' | \ - cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true - - find "$destdir" -type f -print0 | xargs -0 file | \ - awk '/current ar archive/' | \ - cut -f 1 -d : | xargs strip --strip-debug 2> /dev/null || true + cut -f 1 -d : | xargs -0 strip --remove-section=.comment \ + --remove-section=.note 2> /dev/null || true cd ../ @@ -151,6 +152,6 @@ build() # Copy documentation mkdir -p "${destdir}${docsdir}" - cp -p $docs "${destdir}${docsdir}/" + cp -p $docs "${destdir}${docsdir}" } diff --git a/recipes/devel/gcc/recipe b/recipes/devel/gcc/recipe index 376090b4..aff4e688 100644 --- a/recipes/devel/gcc/recipe +++ b/recipes/devel/gcc/recipe @@ -19,7 +19,7 @@ set -e program=gcc version=10-20210206 -release=1 +release=2 # Define a category for the output of the package name pkgcategory=devel @@ -99,9 +99,11 @@ build() --enable-clocale=generic \ --enable-threads=posix \ --enable-cet=auto \ + --enable-initfini-array \ --enable-tls \ --enable-nls \ --enable-lto \ + --enable-plugin \ --enable-objc-gc \ --enable-libstdcxx-time \ --enable-checking=release \ @@ -109,6 +111,7 @@ build() --enable-default-ssp \ --enable-default-pie \ --enable-libssp \ + --enable-initfini-array \ --disable-symvers \ --disable-libitm \ --disable-gnu-indirect-function \ @@ -116,6 +119,7 @@ build() --disable-libmudflap \ --disable-libsanitizer \ --disable-libcilkrts \ + --disable-install-libiberty \ --with-system-zlib \ --with-linker-hash-style=gnu \ --build=$MACHINE \ diff --git a/recipes/devel/valgrind/recipe b/recipes/devel/valgrind/recipe index 5ec30c3f..0b07b0f9 100644 --- a/recipes/devel/valgrind/recipe +++ b/recipes/devel/valgrind/recipe @@ -71,8 +71,10 @@ build() # We do not try to strip any debugging symbol as # suggested in README_PACKAGERS - ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="-no-pie -fno-PIE -fPIC" \ + ./configure CPPFLAGS="-D_FORTIFY_SOURCE=0" \ + CFLAGS="-no-pie -fno-PIE -fPIC" \ CXXFLAGS="-no-pie -fno-PIE -fPIC" \ + LDFLAGS="" \ $configure_args \ --libdir=/usr/lib${libSuffix} \ --infodir=$infodir \ diff --git a/stages/0/01-binutils b/stages/0/01-binutils index 13f6fade..e14958f8 100755 --- a/stages/0/01-binutils +++ b/stages/0/01-binutils @@ -37,7 +37,6 @@ CFLAGS="$BTCFLAGS" CXXFLAGS="$BTCXXFLAGS" LDFLAGS="$BTLDFLAGS" \ --host=$host \ --target=$target \ --enable-deterministic-archives \ - --disable-separate-code \ --disable-compressed-debug-sections \ --disable-werror \ --disable-nls \ diff --git a/stages/0/03-gcc-static b/stages/0/03-gcc-static index 7b13bbb3..3df8a3db 100755 --- a/stages/0/03-gcc-static +++ b/stages/0/03-gcc-static @@ -87,6 +87,7 @@ CFLAGS="$BTCFLAGS" CXXFLAGS="$BTCXXFLAGS" LDFLAGS="$BTLDFLAGS" \ --target=$target \ --enable-languages=c \ --enable-clocale=generic \ + --enable-initfini-array \ --disable-shared \ --disable-threads \ --disable-decimal-float \ diff --git a/stages/0/05-gcc-final b/stages/0/05-gcc-final index 6f50d6b0..59cedf16 100755 --- a/stages/0/05-gcc-final +++ b/stages/0/05-gcc-final @@ -85,6 +85,7 @@ option_list=" --target=$target \ --enable-languages=c,c++ \ --enable-clocale=generic \ + --enable-initfini-array \ --enable-tls \ --enable-libstdcxx-time \ --enable-checking=release \ diff --git a/stages/1/05-binutils b/stages/1/05-binutils index d44f825f..11838d57 100755 --- a/stages/1/05-binutils +++ b/stages/1/05-binutils @@ -23,6 +23,12 @@ unpack "${worktree}/sources/binutils-${version}.tar.lz" # Build instructions cd binutils-${version} +# Apply patches from Fedora (Nick Clifton) +patch -Np1 -i "${worktree}/patches/binutils/binutils-export-demangle.h.patch" +patch -Np1 -i "${worktree}/patches/binutils/binutils-no-config-h-check.patch" +patch -Np1 -i "${worktree}/patches/binutils/binutils-gold-warn-unsupported.patch" +patch -Np1 -i "${worktree}/patches/binutils/binutils-use-long-long.patch" + #patch -Np1 -i "${worktree}/patches/binutils/branch-updates.diff" # Build in a separate directory @@ -47,8 +53,7 @@ CFLAGS="$BTCFLAGS" CXXFLAGS="$BTCXXFLAGS" LDFLAGS="$BTLDFLAGS" \ --enable-threads=auto \ --enable-default-hash-style=gnu \ --enable-64-bit-bfd \ - --enable-initfini-array \ - --disable-separate-code \ + --enable-install-libiberty \ --disable-compressed-debug-sections \ --disable-nls \ --disable-werror \ diff --git a/stages/1/06-gcc b/stages/1/06-gcc index 19d03ff1..ec4e8833 100755 --- a/stages/1/06-gcc +++ b/stages/1/06-gcc @@ -55,25 +55,15 @@ patch -Np1 -i "${worktree}/patches/gcc/0008-Disable-ssp-on-nostdlib-nodefaultlib patch -Np1 -i "${worktree}/patches/gcc/0020-add-fortify-headers-paths.patch" patch -Np1 -i "${worktree}/patches/gcc/0022-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch" -# Hard code default paths to look in /tools -for file in \ - gcc/config/linux.h gcc/config/i386/linux.h gcc/config/i386/linux64.h \ - gcc/config/arm/linux-eabi.h gcc/config/arm/linux-elf.h \ - gcc/config/mips/linux.h \ - gcc/config/rs6000/linux64.h gcc/config/rs6000/sysv4.h \ - gcc/config/aarch64/aarch64-linux.h \ - gcc/config/microblaze/linux.h \ - gcc/config/sh/linux.h \ - gcc/config/riscv/linux.h ; \ +# Hard code default ld path to look at /tools + +find . -type f -name '*.h' -exec grep -l "/lib/ld-" {} + | while read -r file do - if test ! -f "$file" - then - echo "WARNING: ${0}: Non-existent file: $file" 1>&2 - continue; - fi - sed -i \ - -e 's@/lib\(64\)\{0,1\}\(32\)\{0,1\}/ld@/tools&@g' \ - -e 's@/usr@/tools@g' "$file" + test -f "$file" || continue; + cp -f "$file" "${file}.orig" + + sed -e 's@/lib\(64\)\{0,1\}\(32\)\{0,1\}/ld@/tools&@g' \ + -e 's@/usr@/tools@g' "${file}.orig" > "$file" echo ' #undef STANDARD_STARTFILE_PREFIX_1 #undef STANDARD_STARTFILE_PREFIX_2 @@ -129,9 +119,9 @@ CFLAGS="$BTCFLAGS" CXXFLAGS="$BTCXXFLAGS" LDFLAGS="$BTLDFLAGS" \ --enable-languages=c,c++ \ --enable-clocale=generic \ --enable-cet=auto \ + --enable-initfini-array \ --enable-tls \ --enable-libstdcxx-time \ - --enable-install-libiberty \ --enable-fully-dynamic-string \ --enable-default-ssp \ --enable-default-pie \ @@ -143,6 +133,7 @@ CFLAGS="$BTCFLAGS" CXXFLAGS="$BTCXXFLAGS" LDFLAGS="$BTLDFLAGS" \ --disable-libmudflap \ --disable-libsanitizer \ --disable-nls \ + --disable-install-libiberty \ --with-linker-hash-style=gnu \ --with-local-prefix=/tools \ --with-native-system-header-dir=/tools/include \ -- 2.11.4.GIT