[Buildroot] [git commit branch/2025.05.x] package/python3: do build-time detection of non-working toolchain
Thomas Perale
thomas.perale at mind.be
Thu Sep 11 16:01:51 UTC 2025
commit: https://git.buildroot.net/buildroot/commit/?id=02f4d62bbf95ae12eb0cc2cbf7ecbcdb1ab8c9fe
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/2025.05.x
Since the bump to Python 3.13.2 in commit
d63e207eb869063f82c867658676c2903beb08cb, there is a runtime assertion
in Python when the toolchain doesn't support time64 [1]. The only such
toolchain is one with uClibc and linux headers < 5.1.
Encoding this dependency in Config.in was deemed to complicated (cfr.
commit ffd00280315e60908d0d317b1dfb4c714590a03e).
Instead, do a build-time check of the same condition. The check itself
is a bit complicated, but it is localized to python3.mk and doesn't need
to be propagated to all reverse dependencies.
Testing such a corner case toolchain is a bit complicated. It can be
done with the following configuration.
BR2_arm=y
BR2_cortex_a9=y
BR2_ARM_ENABLE_VFP=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
BR2_TOOLCHAIN_EXTERNAL_URL="http://toolchains.bootlin.com/downloads/releases/toolchains/armv7-eabihf/tarballs/armv7-eabihf--uclibc--stable-2018.02-1.tar.bz2"
BR2_TOOLCHAIN_EXTERNAL_GCC_6=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_1=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_PACKAGE_PYTHON3=y
It needs to be built in an environment that has libmpfr.so.4 installed
as the pre-built toolchain from that era did not include it. An easy
way to achieve this is to build this configuration under an old
Buildroot Docker container:
IMAGE=buildroot/base:20180205.0730 ./utils/docker-run make python3
With a build-time check, the autobuilders could get build failures when
generating such a config. However, the autobuilders cannot use a
toolchain with this configuration (they only use more recent
toolchains). Therefore, no update to genrandconfig is needed.
[1] https://gitlab.com/buildroot.org/buildroot/-/issues/95#note_2348479811
Cc: Vincent Fazio <vfazio at xes-inc.com>
Cc: James Hilliard <james.hilliard1 at gmail.com>
Signed-off-by: Arnout Vandecappelle <arnout at rnout.be>
Signed-off-by: Julien Olivain <ju.o at free.fr>
(cherry picked from commit b45400dad416d174459ccafc1ec223b984434a5b)
Signed-off-by: Thomas Perale <thomas.perale at mind.be>
---
package/python3/python3.mk | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/package/python3/python3.mk b/package/python3/python3.mk
index 082dd69bf1..a54170b8ec 100644
--- a/package/python3/python3.mk
+++ b/package/python3/python3.mk
@@ -318,3 +318,11 @@ define PYTHON3_REMOVE_OPTIMIZED_PYC_FILES
xargs -0 --no-run-if-empty rm -f
endef
PYTHON3_TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_OPTIMIZED_PYC_FILES
+
+# uClibc without time64 support (i.e. when linux headers < 5.1) causes
+# a runtime assertion in Python. Encoding this as a dependency in Config.in
+# causes too many problems for propagating reverse dependencies. Therefore
+# instead we do a build time check.
+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
More information about the buildroot
mailing list