build: Fix problems compiling old glibc with gmake >= 4.4

Three separate problems:

1) Make 4.4 defaults to a named pipe for jobserver control, this
   was incompatible with how glibc did recursive makes
2) Make 4.4 passed long arguments ( --foo ) into MAKEFLAGS and this
   broke stuff that wasn't expecting it
3) Circular dependency in a header generation due do make 4.4 being
   stricter/more consistent in how it orders rules vs which makefiles
   they came from.  This one was the real !@#!@ to deal with.

This patch set fixes the hosted arm (glibc 2.19) and mips (glibc 2.25)
toolchains.

Change-Id: Ie6d6a0ab7e1b36f24c43e524fee4afc0bd3a14d6
This commit is contained in:
Solomon Peachy 2023-05-23 14:58:54 -04:00
parent 56fe1129da
commit 3acd5f86e5
3 changed files with 484 additions and 6 deletions

View file

@ -29,8 +29,12 @@ else
make="make"
fi
# record version
makever=`$make -v |sed -n '1p' | sed -e 's/.* \([0-9]*\)\.\([0-9]*\).*/\1\2/'`
# This is the absolute path to where the script resides.
rockboxdevdir="$( readlink -f "$( dirname "${BASH_SOURCE[0]}" )" )"
patch_dir="$rockboxdevdir/toolchain-patches"
if [ `uname -s` = "Darwin" ]; then
parallel=`sysctl -n hw.physicalcpu`
@ -51,7 +55,7 @@ if [ -z $LINUX_MIRROR ] ; then
fi
# These are the tools this script requires and depends upon.
reqtools="gcc g++ xz bzip2 gzip make patch makeinfo automake libtool autoconf flex bison"
reqtools="gcc g++ xz bzip2 gzip $make patch makeinfo automake libtool autoconf flex bison"
##############################################################################
# Functions:
@ -427,8 +431,6 @@ build() {
mkdir -p $builddir
fi
patch_dir="$rockboxdevdir/toolchain-patches"
# download source tarball
gettool "$toolname" "$version"
file="$toolname-$version"
@ -530,6 +532,8 @@ build_linux_toolchain () {
linux_ver="$6"
glibc_ver="$7"
glibc_opts="$8"
glibc_patches="$9"
# where to put the sysroot
sysroot="$prefix/$target/sysroot"
# extract arch from target
@ -553,6 +557,11 @@ build_linux_toolchain () {
mkdir -p $builddir
fi
if [ "$makever" -gt 43 ] ; then
glibc_make_opts="--jobserver-style=pipe --shuffle=none"
# MAKEFLAGS="--jobserver-style=pipe --shuffle=none"
fi
# download all tools
gettool "binutils" "$binutils_ver"
gettool "gcc" "$gcc_ver"
@ -566,6 +575,18 @@ build_linux_toolchain () {
extract "linux-$linux_ver"
extract "glibc-$glibc_ver"
# do we have a patch?
for p in $glibc_patches; do
echo "ROCKBOXDEV: applying patch $p"
(cd $builddir/glibc-$glibc_ver ; patch -p1 < "$patch_dir/$p")
# check if the patch applied cleanly
if [ $? -gt 0 ]; then
echo "ROCKBOXDEV: failed to apply patch $p"
exit
fi
done
# we make it possible to restart a build on error by using the RBDEV_RESTART
# variable, the format is RBDEV_RESTART="tool" where tool is the toolname at which
# to restart (binutils, gcc)
@ -600,7 +621,7 @@ build_linux_toolchain () {
prefix="/usr" \
buildtool "glibc" "$glibc_ver" "--target=$target --host=$target --build=$MACHTYPE \
--with-__thread --with-headers=$sysroot/usr/include $glibc_opts" \
"" "install install_root=$sysroot"
"$glibc_make_opts" "install install_root=$sysroot"
# build stage 2 compiler
RESTART_STEP="gcc-stage2" \
buildtool "gcc" "$gcc_ver" "$gcc_opts --enable-languages=c,c++ --target=$target \
@ -674,6 +695,11 @@ if [ -n "$missingtools" ]; then
exit 1
fi
if ! $make -v | grep -q GNU ; then
echo "ROCKBOXDEV: Building the rockbox toolchains requires GNU Make."
exit 1
fi
dlwhere=$(readlink -f "$dlwhere")
prefix=$(readlink -f "$prefix")
builddir=$(readlink -f "$builddir")
@ -789,7 +815,7 @@ do
# avoid patches/bugs.
glibcopts="--enable-kernel=2.6.23 --enable-oldest-abi=2.4"
build_linux_toolchain "arm-rockbox-linux-gnueabi" "2.26.1" "" "4.9.4" \
"$gccopts" "2.6.32.68" "2.19" "$glibcopts"
"$gccopts" "2.6.32.68" "2.19" "$glibcopts" "glibc-220-make44.patch"
# build alsa-lib
# we need to set the prefix to how it is on device (/usr) and then
# tweak install dir at make install step
@ -825,7 +851,7 @@ do
glibcopts="--enable-kernel=3.2 --enable-oldest-abi=2.16"
# FIXME: maybe add -mhard-float
build_linux_toolchain "mipsel-rockbox-linux-gnu" "2.26.1" "" "4.9.4" \
"$gccopts" "3.2.85" "2.25" "$glibcopts"
"$gccopts" "3.2.85" "2.25" "$glibcopts" "glibc-225-make44.patch"
# build alsa-lib
# we need to set the prefix to how it is on device (/usr) and then
# tweak install dir at make install step