mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-04-11 16:37:45 -04:00
toolchains: Ensure toolchain builds with C23 compilers
* binutils (mips) uses its own 'static_assert' * linux (mips) uses constexpr when generating headers With these patches, all toolchains build successfully under GCC15 (These patches are still needed with the pending GCC9.5 bump) Change-Id: Id2f8cca414d2907b6aa29612ae4fb0e8b5f79f79
This commit is contained in:
parent
9159fc0159
commit
6b063acaae
3 changed files with 110 additions and 23 deletions
|
|
@ -536,24 +536,18 @@ build() {
|
|||
}
|
||||
|
||||
# build a cross compiler toolchain for linux
|
||||
# $1=target
|
||||
# $2=binutils version
|
||||
# $3=binutils configure extra options
|
||||
# $4=gcc version
|
||||
# $5=gcc configure extra options
|
||||
# $6=linux version
|
||||
# $7=glibc version
|
||||
# $8=glibc configure extra options
|
||||
build_linux_toolchain () {
|
||||
target="$1"
|
||||
binutils_ver="$2"
|
||||
binutils_opts="$3"
|
||||
gcc_ver="$4"
|
||||
gcc_opts="$5"
|
||||
linux_ver="$6"
|
||||
glibc_ver="$7"
|
||||
glibc_opts="$8"
|
||||
glibc_patches="$9"
|
||||
binutils_patches="$4"
|
||||
gcc_ver="$5"
|
||||
gcc_opts="$6"
|
||||
linux_ver="$7"
|
||||
linux_patches="$8"
|
||||
glibc_ver="$9"
|
||||
glibc_opts="${10}"
|
||||
glibc_patches="${11}"
|
||||
|
||||
# where to put the sysroot
|
||||
sysroot="$prefix/$target/sysroot"
|
||||
|
|
@ -596,7 +590,17 @@ build_linux_toolchain () {
|
|||
extract "linux-$linux_ver"
|
||||
extract "glibc-$glibc_ver"
|
||||
|
||||
# do we have a patch?
|
||||
# do we have any patches?
|
||||
for p in $binutils_patches; do
|
||||
echo "ROCKBOXDEV: applying patch $p"
|
||||
(cd $builddir/binutils-$binutils_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
|
||||
for p in $glibc_patches; do
|
||||
echo "ROCKBOXDEV: applying patch $p"
|
||||
(cd $builddir/glibc-$glibc_ver ; patch -p1 < "$patch_dir/$p")
|
||||
|
|
@ -607,13 +611,22 @@ build_linux_toolchain () {
|
|||
exit
|
||||
fi
|
||||
done
|
||||
for p in $linux_patches; do
|
||||
echo "ROCKBOXDEV: applying patch $p"
|
||||
(cd $builddir/linux-$linux_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)
|
||||
|
||||
# install binutils, with support for sysroot
|
||||
buildtool "binutils" "$binutils_ver" "--target=$target --disable-werror \
|
||||
buildtool "binutils" "$binutils_ver" "$binutils_opts --target=$target --disable-werror \
|
||||
--with-sysroot=$sysroot --disable-nls" "" ""
|
||||
# build stage 1 compiler: disable headers, disable threading so that
|
||||
# pthread headers are not included, pretend we use newlib so that libgcc
|
||||
|
|
@ -784,7 +797,7 @@ do
|
|||
echo ""
|
||||
case $arch in
|
||||
[Ii])
|
||||
build "binutils" "mipsel-elf" "2.26.1" "" "--disable-werror" "gmp isl"
|
||||
build "binutils" "mipsel-elf" "2.26.1" "binutils-c23.patch" "--disable-werror" "gmp isl"
|
||||
build "gcc" "mipsel-elf" "4.9.4" "" "" "gmp mpfr mpc isl"
|
||||
;;
|
||||
|
||||
|
|
@ -823,7 +836,7 @@ do
|
|||
# Sony NWZ:
|
||||
# gcc: 4.9.4 is the latest 4.9.x stable branch, also the only one that
|
||||
# compiles with GCC >6
|
||||
# kernel: 2.6.32.68 is the latest 2.6.x stable kernel, the device
|
||||
# kernel: 2.6.32.71 is the latest 2.6.x stable kernel, the device
|
||||
# runs kernel 2.6.23 or 2.6.35 or 3.x for the most recent
|
||||
# glibc: 2.19 is the latest version that supports kernel 2.6.23 which
|
||||
# is used on many Sony players, but we need to support ABI 2.7
|
||||
|
|
@ -834,8 +847,8 @@ do
|
|||
# We use a recent 2.26.1 binutils to avoid any build problems and
|
||||
# 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" "glibc-220-make44.patch"
|
||||
build_linux_toolchain "arm-rockbox-linux-gnueabi" "2.26.1" "" "" "4.9.4" \
|
||||
"$gccopts" "2.6.32.71" "" "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
|
||||
|
|
@ -863,15 +876,15 @@ do
|
|||
# glibc: 2.16
|
||||
# alsa: 1.0.26
|
||||
#
|
||||
# To maximize compatibility, we use kernel 3.2.85 which is the lastest
|
||||
# To maximize compatibility, we use kernel 3.2.89 which is the latest
|
||||
# longterm 3.2 kernel and is supported by the latest glibc, and we
|
||||
# require support for up to glibc 2.16
|
||||
# We use a recent 2.26.1 binutils to avoid any build problems and
|
||||
# avoid patches/bugs.
|
||||
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" "glibc-225-make44.patch"
|
||||
build_linux_toolchain "mipsel-rockbox-linux-gnu" "2.26.1" "" "binutils-c23.patch" "4.9.4" \
|
||||
"$gccopts" "3.2.89" "linux-c23.patch" "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
|
||||
|
|
|
|||
30
tools/toolchain-patches/binutils-c23.patch
Normal file
30
tools/toolchain-patches/binutils-c23.patch
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
diff -ur binutils-2.26.X/opcodes/mips-formats.h binutils-2.26.1/opcodes/mips-formats.h
|
||||
--- binutils-2.26.X/opcodes/mips-formats.h 2015-11-13 03:27:42.000000000 -0500
|
||||
+++ binutils-2.26.1/opcodes/mips-formats.h 2025-04-28 14:04:50.949355647 -0400
|
||||
@@ -46,7 +46,7 @@
|
||||
#define MAPPED_INT(SIZE, LSB, MAP, PRINT_HEX) \
|
||||
{ \
|
||||
typedef char ATTRIBUTE_UNUSED \
|
||||
- static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
|
||||
+ static_assert_3[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
|
||||
static const struct mips_mapped_int_operand op = { \
|
||||
{ OP_MAPPED_INT, SIZE, LSB }, MAP, PRINT_HEX \
|
||||
}; \
|
||||
@@ -80,7 +80,7 @@
|
||||
#define MAPPED_REG(SIZE, LSB, BANK, MAP) \
|
||||
{ \
|
||||
typedef char ATTRIBUTE_UNUSED \
|
||||
- static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
|
||||
+ static_assert_4[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
|
||||
static const struct mips_reg_operand op = { \
|
||||
{ OP_REG, SIZE, LSB }, OP_REG_##BANK, MAP \
|
||||
}; \
|
||||
@@ -90,7 +90,7 @@
|
||||
#define OPTIONAL_MAPPED_REG(SIZE, LSB, BANK, MAP) \
|
||||
{ \
|
||||
typedef char ATTRIBUTE_UNUSED \
|
||||
- static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
|
||||
+ static_assert_5[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \
|
||||
static const struct mips_reg_operand op = { \
|
||||
{ OP_OPTIONAL_REG, SIZE, LSB }, OP_REG_##BANK, MAP \
|
||||
}; \
|
||||
44
tools/toolchain-patches/linux-c23.patch
Normal file
44
tools/toolchain-patches/linux-c23.patch
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
diff --git a/scripts/unifdef.c b/scripts/unifdef.c
|
||||
index db00e3e30a59..1cc31448fd10 100644
|
||||
--- a/scripts/unifdef.c
|
||||
+++ b/scripts/unifdef.c
|
||||
@@ -203,7 +203,7 @@ static int depth; /* current #if nesting */
|
||||
static int delcount; /* count of deleted lines */
|
||||
static unsigned blankcount; /* count of blank lines */
|
||||
static unsigned blankmax; /* maximum recent blankcount */
|
||||
-static bool constexpr; /* constant #if expression */
|
||||
+static bool constexpression; /* constant #if expression */
|
||||
static bool zerosyms = true; /* to format symdepth output */
|
||||
static bool firstsym; /* ditto */
|
||||
|
||||
@@ -877,7 +877,7 @@ eval_unary(const struct ops *ops, int *valp, const char **cpp)
|
||||
cp = skipcomment(cp);
|
||||
if (defparen && *cp++ != ')')
|
||||
return (LT_ERROR);
|
||||
- constexpr = false;
|
||||
+ constexpression = false;
|
||||
} else if (!endsym(*cp)) {
|
||||
debug("eval%d symbol", ops - eval_ops);
|
||||
sym = findsym(cp);
|
||||
@@ -895,7 +895,7 @@ eval_unary(const struct ops *ops, int *valp, const char **cpp)
|
||||
lt = *valp ? LT_TRUE : LT_FALSE;
|
||||
cp = skipargs(cp);
|
||||
}
|
||||
- constexpr = false;
|
||||
+ constexpression = false;
|
||||
} else {
|
||||
debug("eval%d bad expr", ops - eval_ops);
|
||||
return (LT_ERROR);
|
||||
@@ -955,10 +955,10 @@ ifeval(const char **cpp)
|
||||
int val = 0;
|
||||
|
||||
debug("eval %s", *cpp);
|
||||
- constexpr = killconsts ? false : true;
|
||||
+ constexpression = killconsts ? false : true;
|
||||
ret = eval_table(eval_ops, &val, cpp);
|
||||
debug("eval = %d", val);
|
||||
- return (constexpr ? LT_IF : ret == LT_ERROR ? LT_IF : ret);
|
||||
+ return (constexpression ? LT_IF : ret == LT_ERROR ? LT_IF : ret);
|
||||
}
|
||||
|
||||
/*
|
||||
Loading…
Add table
Add a link
Reference in a new issue