From 7262026f0f4e4a5f3382e91b564fb27c1ec9dd9e Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 11 Oct 2023 21:36:56 +0000 Subject: [PATCH] rustPlatform.cargoSetupHook: fix platform check (#260068) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cargo will never need to link for the target platform — that'd be for the package being built to do at runtime. Cargo should know about the build and host linkers. This fixes e.g. pkgsCross.musl64.fd from x86_64-linux. Fixes: 67a4f828b46c ("rust: hooks: fix cross compilation") --- pkgs/build-support/rust/hooks/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/rust/hooks/default.nix b/pkgs/build-support/rust/hooks/default.nix index c73ec30082dc..205d085d3507 100644 --- a/pkgs/build-support/rust/hooks/default.nix +++ b/pkgs/build-support/rust/hooks/default.nix @@ -67,9 +67,9 @@ cargoConfig = '' [target."${rust.toRustTarget stdenv.buildPlatform}"] "linker" = "${rust.envVars.ccForBuild}" - ${lib.optionalString (stdenv.hostPlatform.config != stdenv.targetPlatform.config) '' - [target."${rust.toRustTarget stdenv.targetPlatform}"] - "linker" = "${rust.envVars.ccForTarget}" + ${lib.optionalString (stdenv.buildPlatform.config != stdenv.hostPlatform.config) '' + [target."${rust.toRustTarget stdenv.hostPlatform}"] + "linker" = "${rust.envVars.ccForHost}" ''} "rustflags" = [ "-C", "target-feature=${if stdenv.hostPlatform.isStatic then "+" else "-"}crt-static" ] '';