[Buildroot] [git commit branch/2025.02.x] package/micropython: fix segfault at exit() with gcc >= 14

Thomas Perale thomas.perale at mind.be
Thu Sep 11 15:51:19 UTC 2025


commit: https://git.buildroot.net/buildroot/commit/?id=9cabd336ed18b29ea08e5bb2ed2453cdb6454215
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/2025.02.x

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 <romain.naour at smile.fr>
Signed-off-by: Julien Olivain <ju.o at free.fr>
(cherry picked from commit 50bc5aa17b320d91809048d5ef6a110f8c0b9157)
Signed-off-by: Thomas Perale <thomas.perale at mind.be>
---
 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 += \


More information about the buildroot mailing list