Skip to contentSkip to conversation

toolchain: add BR2_TOOLCHAIN_HAS_GCC_BUG_127142

PATCH New Yegor Yefremov 1 participant 2 messages Nov 6

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 toolchain: add BR2_TOOLCHAIN_HAS_GCC_BUG_127142

GCC 16 switched hppa from reload to LRA by default (upstream commit 389a023fd416 "hppa: Enable LRA as default"). LRA is unable to handle overlapping live ranges of the %r1 register, used by addil to load the high part of symbolic operands in non-PIC code, and fails with:

error: unable to find a register to spill

This is GCC PR rtl-optimization/127142. It is still open: the first fix was partially reverted as GNU ld cannot fix up the replacement ldil/addl sequence, and the subsequent proposals were abandoned.

Going back to reload with -mno-lra is not an option, as reload is no longer working on hppa with GCC 16 (e.g. glibc fails with "internal compiler error: in gen_reg_rtx, at emit-rtl.cc:1193").

This issue has been present since commit 1b290781cf37 ("package/gcc:
add version 16.1.0"), as GCC 16 was the first version to use LRA by default on hppa. It therefore affects 2026.08 and later.

Fixes 1b290781cf3782576091dbeacdd7d1a30b051856 ("package/gcc: add version 16.1.0")
Assisted-by Claude:claude-opus-5-5
---
 toolchain/Config.in | 9 +++++++++
 1 file changed, 9 insertions(+)
toolchain/Config.in +9 -0
index 5f4c5f5fb7..a966a473e3 100644
@@ -249,6 +249,15 @@ config BR2_TOOLCHAIN_HAS_GCC_BUG_111001
 		   BR2_OPTIMIZE_2 || \
 		   BR2_OPTIMIZE_3
 
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127142
+# ICE: on hppa: unable to find a register to spill, since LRA is
+# the default register allocator on hppa (gcc >= 16).
+# This bug still exists in gcc = 16.2.0
+config BR2_TOOLCHAIN_HAS_GCC_BUG_127142
+	bool
+	default y if BR2_hppa
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_16
+
 config BR2_TOOLCHAIN_HAS_NATIVE_RPC
 	bool
 
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH 2/2 package/xz: work around GCC bug 127142

With GCC 16 on hppa, building xz fails with an internal compiler error in the LRA register allocator:

coder.c: In function 'coder_run':
coder.c:1456:1: error: unable to find a register to spill coder.c:1456:1: error: this is the insn:
(insn 673 2069 679 91 (set (mem/f/c:SI (reg/f:SI 823) [11 strm.next_out+0 S4 A64])

          (reg/f:SI 824)) "coder.c":1189:16 42 {*pa.md:2195}

The failure happens with non-PIE code at -O2, -O3 and -Ofast. As there is no fix available upstream yet, build xz with -O0 when BR2_TOOLCHAIN_HAS_GCC_BUG_127142 is set, as is done for other GCC bugs.

This issue has been present since commit 1b290781cf37 ("package/gcc:
add version 16.1.0"), as GCC 16 was the first version to use LRA by default on hppa. It therefore affects 2026.08 and later.

Fixes:
https://autobuild.buildroot.org/results/d543e6c0456a491ddefa44f1ad613bc70c120b26

Fixes 1b290781cf3782576091dbeacdd7d1a30b051856 ("package/gcc: add version 16.1.0")
Assisted-by Claude:claude-opus-5-5
---
 package/xz/xz.mk | 4 ++++
 1 file changed, 4 insertions(+)
package/xz/xz.mk +4 -0
index c3232966ee..37262b75f7 100644
@@ -18,6 +18,10 @@ XZ_AUTORECONF = YES
 # The package is a dependency to ccache so ccache cannot be a dependency
 HOST_XZ_ADD_CCACHE_DEPENDENCY = NO
 
+ifeq ($(BR2_TOOLCHAIN_HAS_GCC_BUG_127142),y)
+XZ_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -O0"
+endif
+
 XZ_CONF_OPTS = \
 	--enable-encoders=lzma1,lzma2,delta,x86,powerpc,ia64,arm,armthumb,arm64,sparc,riscv \
 	--enable-decoders=lzma1,lzma2,delta,x86,powerpc,ia64,arm,armthumb,arm64,sparc,riscv \
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot