From 50bc5aa17b320d91809048d5ef6a110f8c0b9157 Mon Sep 17 00:00:00 2001 From: Romain Naour Date: Sun, 7 Sep 2025 11:57:17 +0200 Subject: [PATCH] package/micropython: fix segfault at exit() with gcc >= 14 Since Buildroot commit [1] "update to Bootlin toolchains 2025.08-1", the TestMicroPython segfault when testing if micropython can return a non-zero exit code. micropython -c "import sys ; sys.exit(123)" This issue is related to the gcc version used to build micropython (gcc 14 or newer). Using gcc 13 (like Bootlin toolchain 2024.05-1 previously used) micropython run without issue. The issue has been reported upstream [2] and fixed in newer micropython releases [3]. For now, apply a temporary workaround (suggested in the bug report) using -DMICROPY_NLR_SETJMP=1 only for gcc 14 or newer. MICROPY_NLR_SETJMP avoid the architecture specific implementation of nlr_push. Fixes: https://gitlab.com/buildroot.org/buildroot/-/jobs/11176774762 (TestMicroPython) [1] https://gitlab.com/buildroot.org/buildroot/-/commit/947dbc92a20c5acea7882166cae7893e6ea661e1 [2] https://github.com/micropython/micropython/issues/14115 [3] https://github.com/micropython/micropython/commit/35f3f0a87db2580041dd0f7dfd4361df48887796 Signed-off-by: Romain Naour Signed-off-by: Julien Olivain --- package/micropython/micropython.mk | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/package/micropython/micropython.mk b/package/micropython/micropython.mk index 949abe3b0b..32b361db16 100644 --- a/package/micropython/micropython.mk +++ b/package/micropython/micropython.mk @@ -29,6 +29,13 @@ ifeq ($(BR2_xtensa),y) MICROPYTHON_CFLAGS = -DMICROPY_NLR_SETJMP=1 endif +# https://github.com/micropython/micropython/issues/14115 +# Temporary fix for GCC 14 compatibility, should be removed after updating to +# 1.23.0 or later. +ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_14),y) +MICROPYTHON_CFLAGS += -DMICROPY_NLR_SETJMP=1 +endif + # When building from a tarball we don't have some of the dependencies that are in # the git repository as submodules MICROPYTHON_MAKE_OPTS += \