[Buildroot] [PATCH] package/micropython: fix segfault at exit() with gcc >= 14

Thomas Perale thomas.perale at mind.be
Thu Sep 11 19:27:17 UTC 2025


In reply of:
> 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>

Applied to 2025.02.x & 2025.05.x. Thanks

> ---
>  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 += \
> -- 
> 2.51.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot at buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot


More information about the buildroot mailing list