Rebuild Binutils 2.38 using all modern features

- Rather than using part-by-part build of Binutils, use autogen and full
  ./configure, make build.
- Enable some other modern features, including the gold linker, threaded
  linking and 64-bit linking.
- This allows GCC 12 to build unhindered by binutils.
This commit is contained in:
fosslinux 2023-04-17 21:39:32 +10:00
parent 8ae911162a
commit ac4685e886
5 changed files with 145 additions and 3 deletions

View File

@ -1145,3 +1145,15 @@ every subdirectory, since we now have ``autogen`` available we are able to use
the top-level configure to build the project. We do not use GCC's bootstrap mode,
where GCC is recompiled with itself after being built, since we're just going
to use this GCC to compile GCC 12, it adds build time for little benefit.
binutils 2.38 (pass 2)
======================
We recompile Binutils with the full intended autogen top-level build system,
instead of the subdirectory build system used before. This creates a binutils
that functions completely correctly for the build of GCC 12 (eg, fixes the
mistaken plugin loading support). Other modern features are added, including;
* threaded linking
* 64-bit linking on 32-bit x86
* the modern, rewritten gold linker used by some distributions

View File

@ -24,6 +24,7 @@ c5807850a377e4bb9aa4121d9781d145bdd80327626a9419630a75ce2c8d9c71 automake-1.9.6
05bcb569640576e53e40c2bfbeea988fd4fc4e0b5b1311668eabd5cdaacd6657 bc-1.07.1_0.tar.bz2
7b8ea17311f22e987a39b814658c72b46201650c4dfbc707e8fd9eb42bf1ed28 binutils-2.30_0.tar.bz2
a21157791cb5e7ec941de09f275286d90efe1b463dc4302b238af9ba53fae49e binutils-2.38_0.tar.bz2
8c4cb7f5ec331d29e7307882ac7d8ffb3b834dd5505eb7c27c754b937e93f88b binutils-2.38_1.tar.bz2
2e2102a9a41f3ad35683e67f6f9cc09e4edad25b7acb1ae0ca3ad94e19fbbdaf bison-2.3_0.tar.bz2
df9539b52384757d927bca5a27b1b58325b6024b23b0470e557f135eb69bae30 bison-3.4.1_0.tar.bz2
fed9e13409f6378f97e8cef61e6faac992f3b767dfdac22f32453ff57cf29e7b bison-3.4.1_1.tar.bz2

View File

@ -14,15 +14,22 @@ src_prepare() {
rm zlib/aclocal.m4 zlib/configure
# Regenerate files
# Regenerate autoconf
for dir in bfd binutils gas gold gprof intl ld libctf libiberty opcodes; do
cd $dir
AUTOPOINT=true ACLOCAL=aclocal-1.15 AUTOMAKE=automake-1.15 autoreconf-2.69 -fi
cd ..
done
ACLOCAL=aclocal-1.15 autoreconf-2.69 -fi
# Regenerate directories with Makefile.am only
pushd gold
automake-1.15 -fai testsuite/Makefile
popd
pushd bfd
automake-1.15 -fai doc/Makefile
popd
# Rebuild bison files
touch -- */*.y
rm binutils/arparse.c binutils/arparse.h

120
sysc/binutils-2.38/pass2.sh Executable file
View File

@ -0,0 +1,120 @@
# SPDX-FileCopyrightText: 2022 Dor Askayo <dor.askayo@gmail.com>
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-FileCopyrightText: 2021 Paul Dersey <pdersey@gmail.com>
# SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
#
# SPDX-License-Identifier: GPL-3.0-or-later
src_prepare() {
default
# Remove unused generated files
rm etc/Makefile.in etc/configure
rm zlib/aclocal.m4 zlib/configure
# Regenerate top-level (autogen + autotools)
autogen Makefile.def
ACLOCAL=aclocal-1.15 autoreconf-2.69 -fi
# Regenerate autoconf
for dir in bfd binutils gas gold gprof intl ld libctf libiberty opcodes; do
cd $dir
ACLOCAL=aclocal-1.15 AUTOMAKE=automake-1.15 autoreconf-2.69 -fi
cd ..
done
# Regenerate directories with Makefile.am only
pushd gold
automake-1.15 -fai testsuite/Makefile
popd
pushd bfd
automake-1.15 -fai doc/Makefile
popd
# intl/ Makefile is a bit broken because of new gettext
sed -i 's/@USE_INCLUDED_LIBINTL@/no/' intl/Makefile.in
# There is no way to add -all-static to libtool LDFLAGS (such a thing doesn't exist)
# -all-static is required for static binaries with libtool
sed -i 's:\(--mode=link $(CCLD)\):\1 -all-static:' {bfd,binutils,opcodes,ld,libctf,gas,gprof}/Makefile.in
# Rebuild bison files
touch -- */*.y
rm binutils/arparse.c binutils/arparse.h
rm binutils/defparse.c binutils/defparse.h
rm binutils/mcparse.c binutils/mcparse.h
rm binutils/rcparse.c binutils/rcparse.h
rm binutils/sysinfo.c binutils/sysinfo.h
rm gas/config/bfin-parse.c gas/config/bfin-parse.h
rm gas/config/loongarch-parse.c gas/config/loongarch-parse.h
rm gas/config/m68k-parse.c gas/config/rl78-parse.c
rm gas/config/rl78-parse.h gas/config/rx-parse.c
rm gas/config/rx-parse.h gas/itbl-parse.c
rm gas/itbl-parse.h gold/yyscript.c
rm gold/yyscript.h intl/plural.c
rm ld/deffilep.c ld/deffilep.h
rm ld/ldgram.c ld/ldgram.h
# Rebuild flex generated files
touch -- */*.l */*/*.l
rm binutils/arlex.c binutils/deflex.c binutils/syslex.c
rm gas/config/bfin-lex.c gas/config/loongarch-lex.c gas/itbl-lex.c
rm ld/ldlex.c
# Remove prebuilt texinfo files
find . -type f -name '*.info*' \
-not -wholename './binutils/sysroff.info' \
-delete
# Remove pregenerated opcodes files
rm opcodes/i386-init.h opcodes/i386-tbl.h
rm opcodes/ia64-asmtab.c
rm opcodes/z8k-opc.h
rm opcodes/aarch64-asm-2.c opcodes/aarch64-opc-2.c opcodes/aarch64-dis-2.c
rm $(grep -l 'MACHINE GENERATED' opcodes/*.c opcodes/*.h)
# Regenerate MeP sections
./bfd/mep-relocs.pl
# Manpages
find . -type f -name '*.1' -or -name '*.man' -delete
}
src_configure() {
mkdir build
cd build
# -rdynamic is required for plugin support in a static ld
LDFLAGS="-static" \
../configure \
--prefix="${PREFIX}" \
--libdir="${LIBDIR}" \
--build=i386-unknown-linux-musl \
--host=i386-unknown-linux-musl \
--target=i386-unknown-linux-musl \
--enable-static \
--disable-nls \
--disable-multilib \
--disable-plugins \
--enable-threads \
--enable-64-bit-bfd \
--enable-gold \
--enable-ld=default \
--enable-install-libiberty \
--enable-deterministic-archives \
--with-system-zlib \
--program-prefix="" \
--with-sysroot= \
--srcdir=..
}
src_install() {
default
# Create triplet symlinks
pushd "${DESTDIR}${PREFIX}/bin"
for f in *; do
ln -s "${PREFIX}/bin/${f}" "i386-unknown-linux-musl-${f}"
done
popd
}

View File

@ -74,7 +74,7 @@ build texinfo-6.7
build gcc-4.7.4
build binutils-2.38
build binutils-2.38 pass1.sh
build gperf-3.1
@ -122,6 +122,8 @@ build python-3.11.1
build gcc-10.4.0
build binutils-2.38 pass2.sh
if [ "$FORCE_TIMESTAMPS" = True ] ; then
echo 'Forcing all files timestamps to be 0 unix time.'
canonicalise_all_files_timestamp