From a68899d49ec4c7f97dea0dcb9995e6a5d7b282c9 Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Sat, 16 Aug 2025 11:15:12 +0200 Subject: [PATCH] package/python3: work around GCC bug 121567 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When Python 3 is built with -O2 or -O3 on SuperH, the build fails with: Objects/obmalloc.c:503:1: error: unable to find a register to spill in class ‘R0_REGS’ 503 | } | ^ Objects/obmalloc.c:503:1: error: this is the insn: (insn 18 243 23 2 (parallel [ (set (subreg:SI (reg:QI 176) 0) (unspec_volatile:SI [ (mem/v:QI (reg:SI 4 r4 [175]) [-1 S1 A32]) (reg:QI 7 r7 [178]) (reg:QI 6 r6 [180]) ] UNSPECV_CMPXCHG_1)) (set (mem/v:QI (reg:SI 4 r4 [175]) [-1 S1 A32]) (unspec_volatile:QI [ (const_int 0 [0]) ] UNSPECV_CMPXCHG_2)) (set (reg:SI 147 t) (unspec_volatile:SI [ (const_int 0 [0]) ] UNSPECV_CMPXCHG_3)) (clobber (scratch:SI)) (clobber (reg:SI 0 r0)) (clobber (reg:SI 1 r1)) ]) "./Include/cpython/pyatomic_gcc.h":105:10 407 {atomic_compare_and_swapqi_soft_gusa} (expr_list:REG_DEAD (reg:QI 6 r6 [180]) (expr_list:REG_DEAD (reg:QI 7 r7 [178]) (expr_list:REG_UNUSED (reg:QI 176) (expr_list:REG_UNUSED (reg:SI 1 r1) (expr_list:REG_UNUSED (reg:SI 0 r0) (nil))))))) Objects/obmalloc.c:503: confused by earlier errors, bailing out THe bug has been reported upstream, but until it gets fixed, let's work it around by using -O1 instead. Note that BR2_TOOLCHAIN_HAS_GCC_BUG_121567 is only set when -O2 or -O3 is configured, so there's no need to check again. Fixes: https://autobuild.buildroot.net/results/cac123ee9f3a6df6263b69dce3ac0d535518ec3f/ Signed-off-by: Thomas Petazzoni Signed-off-by: Julien Olivain --- package/python3/python3.mk | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/package/python3/python3.mk b/package/python3/python3.mk index 012a46edcb..ef0658262a 100644 --- a/package/python3/python3.mk +++ b/package/python3/python3.mk @@ -189,6 +189,15 @@ else PYTHON3_CONF_ENV += ac_cv_big_endian_double=yes endif +PYTHON3_CFLAGS = $(TARGET_CFLAGS) + +ifeq ($(BR2_TOOLCHAIN_HAS_GCC_BUG_121567),y) +PYTHON3_CFLAGS += -O1 +endif + +PYTHON3_CONF_ENV += \ + CFLAGS="$(PYTHON3_CFLAGS)" + ifeq ($(BR2_PACKAGE_GETTEXT_PROVIDES_LIBINTL),y) PYTHON3_DEPENDENCIES += gettext endif