diff mbox series

[2/2] package/python3: do build-time detection of non-working uClibc-ng aarch64 toolchains

Message ID 20250913173311.2624001-2-romain.naour@smile.fr
State Superseded
Headers show
Series [1/2] support/testing: remove TestZfsUclibc | expand

Commit Message

Romain Naour Sept. 13, 2025, 5:33 p.m. UTC
As reported on the mailing list [1] while investigating the
TestZfsUclibc Gitlab-CI failure, the python 3.13 interpreter itsef
segfault at runtime:

  Fatal Python error: _PyThreadState_Attach: non-NULL old thread state
  Python runtime state: preinitialized
  Thread 0xSegmentation fault

This issue is related to the python 3.13 version bump [2] were several
internal changes were added [3] to support PEP 703 [4].
PEP 793 is about CPython’s global interpreter lock (“GIL”) removal
for multi-threads support that requires a working C11 "thread_local"
for thread-local storage [5].

Since it's only failing on uClibc-ng on aarch64 targets, do build-time
detection of non-working uClibc-ng aarch64 toolchains. Another solution
would be to completely disable uClibc-ng on aarch64 targets.

[1] https://lore.kernel.org/buildroot/7a4d245d-1556-43c9-8997-6b1f791afbfe@gmail.com/ (TestZfsUclibc)
[2] d63e207eb869063f82c867658676c2903beb08cb
[3] https://github.com/python/cpython/commit/6e97a9647ae028facb392d12fc24973503693bd6
[4] https://peps.python.org/pep-0703/
[5] https://gcc.gnu.org/onlinedocs/gcc-15.1.0/gcc/Thread-Local.html

Cc: Waldemar Brodkorb <wbx@openadk.org>
Signed-off-by: Romain Naour <romain.naour@smile.fr>
---
 package/python3/python3.mk | 9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox series

Patch

diff --git a/package/python3/python3.mk b/package/python3/python3.mk
index 1546915f08..60364421f3 100644
--- a/package/python3/python3.mk
+++ b/package/python3/python3.mk
@@ -323,3 +323,12 @@  PYTHON3_TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_OPTIMIZED_PYC_FILES
 ifeq ($(BR_BUILDING)$(BR2_PACKAGE_PYTHON3)$(BR2_TOOLCHAIN_USES_UCLIBC)-$(BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_1),yyy-)
 $(error Python3 doesn't work with uClibc and kernel headers < 5.1. Please use a different toolchain or unselect Python3.)
 endif
+
+# Since python 3.13.x, uClibc-ng toolchain for aarch64 targets causes a
+# segfault at runtime. Encoding this as a dependency in
+# Config.in causes too many problems for propagating reverse
+# dependencies. Therefore instead we do a build time check.
+# https://lore.kernel.org/buildroot/7a4d245d-1556-43c9-8997-6b1f791afbfe@gmail.com/
+ifeq ($(BR_BUILDING)$(BR2_PACKAGE_PYTHON3)$(BR2_TOOLCHAIN_USES_UCLIBC)$(BR2_aarch64)$(BR2_aarch64_be),yyyy)
+$(error Python3 doesn't work with uClibc on aarch64. Please use a different toolchain or unselect Python3.)
+endif