python3Packages.cryptography: fix invalid platform for Rust on cross-…#208401
python3Packages.cryptography: fix invalid platform for Rust on cross-…#208401Cynerd wants to merge 1 commit intoNixOS:masterfrom
Conversation
…compile The Rust library was being built for the build platform and not for the host platform when cross-compiling.
| CARGO_BUILD_TARGET = "${rust.toRustTargetSpec stdenv.hostPlatform}"; | ||
| PYO3_CROSS_LIB_DIR = "${python}/lib/${python.libPrefix}"; | ||
| "CARGO_TARGET_${lib.toUpper (builtins.replaceStrings ["-"] ["_"] (rust.toRustTarget stdenv.hostPlatform))}_LINKER" = | ||
| "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"; |
There was a problem hiding this comment.
i recommend adding a setup hook to setuptools-rust that does these
CARGO_BUILD_TARGET_TARGET = "${rust.toRustTargetSpec targetPackages.stdenv.hostPlatform}";
PYO3_CROSS_LIB_DIR_TARGET = "${targetPackages.python}/lib/${targetPackages.python.libPrefix}";
CARGO_LINKER_VAR = "CARGO_TARGET_${lib.toUpper (builtins.replaceStrings ["-"] ["_"] (rust.toRustTarget targetPackages.stdenv.hostPlatform))}_LINKER"
TARGET_LINKER = "${targetPackages.stdenv.cc}/bin/${targetPackages.stdenv.cc.targetPrefix}cc";add the above to the setuptools-rust and a setup hook that exports them
export CARGO_BUILD_TARGET_TARGET=@CARGO_BUILD_TARGET@
export PYO3_CROSS_LIB_DIR_TARGET=@PYO3_CROSS_LIB_DIR@
export @CARGO_LINKER_VAR@=@TARGET_LINKER@| CARGO_BUILD_TARGET = "${rust.toRustTargetSpec stdenv.hostPlatform}"; | ||
| PYO3_CROSS_LIB_DIR = "${python}/lib/${python.libPrefix}"; | ||
| "CARGO_TARGET_${lib.toUpper (builtins.replaceStrings ["-"] ["_"] (rust.toRustTarget stdenv.hostPlatform))}_LINKER" = | ||
| "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"; |
There was a problem hiding this comment.
| CARGO_BUILD_TARGET = "${rust.toRustTargetSpec stdenv.hostPlatform}"; | |
| PYO3_CROSS_LIB_DIR = "${python}/lib/${python.libPrefix}"; | |
| "CARGO_TARGET_${lib.toUpper (builtins.replaceStrings ["-"] ["_"] (rust.toRustTarget stdenv.hostPlatform))}_LINKER" = | |
| "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"; | |
| CARGO_BUILD_TARGET = rust.toRustTargetSpec stdenv.hostPlatform; | |
| PYO3_CROSS_LIB_DIR = "${python}/lib/${python.libPrefix}"; | |
| "CARGO_TARGET_${lib.toUpper (builtins.replaceStrings ["-"] ["_"] (rust.toRustTarget stdenv.hostPlatform))}_LINKER" = | |
| "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"; |
Are those generic variables we want to set?
If so we should move them to a setup-hook like maturin or setuptools-rust
There was a problem hiding this comment.
That is the question... I took those variables from here https://github.com/PyO3/setuptools-rust/blob/main/.github/workflows/ci.yml#L270 and here PyO3/setuptools-rust#294 (comment). The CARGO_BUILD_TARGET and PYO3_CROSS_LIB_DIR seem reasonable, but I am not sure about CARGO_TARGET_*. It is kind of weird to have to specify the linker. No other package except of crosvm has to do this (that is where I took it from anyway).
There was a problem hiding this comment.
It is kind of weird to have to specify the linker.
Especially weird given that we already do this:
nixpkgs/pkgs/build-support/rust/hooks/default.nix
Lines 98 to 110 in 06542b2
| rustPlatform.cargoSetupHook | ||
| rustc | ||
| cargo |
There was a problem hiding this comment.
Can we assert/check in a setup hook this somewhere to make sure this is correct?
There was a problem hiding this comment.
Or should this be propagated inputs for setuptools-rust?
|
@ofborg eval |
|
Superseded by #212795. |
Description of changes
The Rust library was being built for the build platform and not for the host platform when cross-compiling. This sets build so it builds it for the correct platform.
The issue was reported and investigated in #205807
I was looking also into other packages that use
setuptools-rust, and it seems that the same modifications are required there as well.Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)nixos/doc/manual/md-to-db.shto update generated release notes