python3Packages.librt: fix cross compilation

Signed-off-by: FlashOnFire_ <flashonfire.dev@gmail.com>
This commit is contained in:
FlashOnFire_ 2026-04-12 19:12:27 +02:00
commit 0ddb2c508c
No known key found for this signature in database

View file

@ -6,6 +6,7 @@
mypy-extensions,
python,
pytest,
stdenv,
}:
buildPythonPackage rec {
@ -23,6 +24,18 @@ buildPythonPackage rec {
# https://github.com/mypyc/librt/blob/v0.7.8/.github/workflows/buildwheels.yml#L90-L93
postPatch = ''
cp -rv lib-rt/* .
# build_setup.py patches CCompiler.spawn to inject architecture-specific
# SIMD flags based on platform.machine() (which returns the build arch instead
# of the target arch). When cross-compiling, this causes the compiler to abort
# with "unrecognized command-line option" errors.
#
# The patch below forces the use of the target architecture, in order
# to keep SIMD flags for x86_64 targets while avoiding them elsewhere.
substituteInPlace build_setup.py \
--replace-fail \
'X86_64 = platform.machine() in ("x86_64", "AMD64", "amd64")' \
'X86_64 = ${if stdenv.hostPlatform.isx86_64 then "True" else "False"}'
'';
build-system = [