rustPlatform.cargoSetupHook: fix platform check (#260068)

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: 67a4f828b4 ("rust: hooks: fix cross compilation")
This commit is contained in:
Alyssa Ross 2023-10-11 21:36:56 +00:00 committed by GitHub
parent b8d473b6d2
commit 7262026f0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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" ]
'';