package/python3: work around GCC bug 121567

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 <thomas.petazzoni@bootlin.com>
Signed-off-by: Julien Olivain <ju.o@free.fr>
This commit is contained in:
Thomas Petazzoni
2025-08-16 11:15:12 +02:00
committed by Julien Olivain
parent 1838d8e5ea
commit a68899d49e

View File

@@ -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