From 0ddb2c508c423ce9df7a073fbe1db2deb84b41ba Mon Sep 17 00:00:00 2001 From: FlashOnFire_ Date: Sun, 12 Apr 2026 19:12:27 +0200 Subject: [PATCH] python3Packages.librt: fix cross compilation Signed-off-by: FlashOnFire_ --- pkgs/development/python-modules/librt/default.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkgs/development/python-modules/librt/default.nix b/pkgs/development/python-modules/librt/default.nix index 044a9c742517..c1531eed6054 100644 --- a/pkgs/development/python-modules/librt/default.nix +++ b/pkgs/development/python-modules/librt/default.nix @@ -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 = [