Skip to contentSkip to conversation

package/python3: fix non-NPTL build

PATCH In review Bernd Kuhls 2 participants 2 messages Oct 29 – Nov 16

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/python3: fix non-NPTL build

Upstream commit
https://github.com/python/cpython/commit/1bcc0d165ae66f5d88db5c5bcab82908d9a49537
first included in version 3.14.10 added the usage of __builtin_thread_pointer which is only available with NPTL and causes build error with linuxthreads:

./Include/internal/mimalloc/mimalloc/prim.h: In function '_mi_prim_thread_id':
./Include/internal/mimalloc/mimalloc/prim.h:312:21: error: implicit
declaration of function '__builtin_thread_pointer'; did you mean '__builtin_extend_pointer'? [-Wimplicit-function-declaration]

Buildroot commit 3736eda341337a2ddd824111a5f065c84d44c584 bumped the package to 3.14.10.

Upstream offers an user override
https://github.com/python/cpython/blob/v3.14.10/Include/internal/mimalloc/mimalloc/prim.h#L270
with the define MI_USE_BUILTIN_THREAD_POINTER. To fix the problem we disable MI_USE_BUILTIN_THREAD_POINTER when NPTL is not available.

Fixes:
https://autobuild.buildroot.net/results/ca6/ca64f93e85191779d0ef4daf44f1519ad75be6db/

Fixes 3736eda341337a2ddd824111a5f065c84d44c584
---
 package/python3/python3.mk | 4 ++++
 1 file changed, 4 insertions(+)
package/python3/python3.mk +4 -0
index c24020af9b..a892cdad3b 100644
@@ -186,6 +186,10 @@ ifeq ($(BR2_TOOLCHAIN_HAS_GCC_BUG_81426),y)
 PYTHON3_CFLAGS += -O0
 endif
 
+ifeq ($(BR2_TOOLCHAIN_HAS_THREADS_NPTL),)
+PYTHON3_CFLAGS += -DMI_USE_BUILTIN_THREAD_POINTER=0
+endif
+
 PYTHON3_CONF_ENV += \
 	CFLAGS="$(PYTHON3_CFLAGS)"
 
Signature · 6 lines
2.47.3

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Re: [Buildroot] [External] - [PATCH 1/1] package/python3: fix non-NPTL build

All,

Quoted 9 lines

-----Original Message-----
From: buildroot <[email protected]> On Behalf Of Bernd Kuhls
Sent: Thursday, October 29, 2026 12:33 PM
To: [email protected]
Cc: James Hilliard <[email protected]>; Thomas Petazzoni <[email protected]>
Subject: [External] - [Buildroot] [PATCH 1/1] package/python3: fix non-NPTL build

Quoted 6 lines

Upstream commit
https://github.com/python/cpython/commit/1bcc0d165ae66f5d88db5c5bcab82
908d9a49537
first included in version 3.14.10 added the usage of __builtin_thread_pointer which is only available with NPTL and causes build error with linuxthreads:

I noticed this when testing 3.15 as well.

mimalloc is not the default allocator for Python unless you're using a GIL-less build, which we don't support (yet).

I think we have a few options:

1. Squelch the error by configuring --without-mimalloc since the allocator isn't used by default

2. Patch the included mimalloc to guard with __UCLIBC_HAS_TLS__. My guess is running with PYTHONMALLOC=mimalloc [0] as is would lead to failures even with this fix due to use of offset registers [1] since uClibc exports __GLIBC__. If we patch in a __UCLIBC_HAS_TLS__ guard it could fall back to a non-TLS solution.

3. Require BR2_TOOLCHAIN_HAS_THREADS_NPTL for Python builds. I tried running the Python unit tests (python -m test) on a build with linuxthreads and got a number of errors [2], so I'm not sure if we can really expect Python to work with linuxthreads or without thread support at all. I'm sure people's use cases differ (maybe they don't need certain aspects for their specific build)

Open to ideas and input from maintainers and people that use Python on uclibc.

[0]: https://docs.python.org/3/using/cmdline.html#envvar-PYTHONMALLOC
[1]: https://github.com/python/cpython/blob/3.14/Include/internal/mimalloc/mimalloc/prim.h#L151
[2]: https://gitlab.com/buildroot.org/buildroot/-/work_items/193#note_4232557339

-Vincent

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot