Skip to content

Commit

Permalink
rustPlatform.cargoSetupHook: fix platform check (#260068)
Browse files Browse the repository at this point in the history
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: 67a4f82 ("rust: hooks: fix cross compilation")
  • Loading branch information
alyssais authored Oct 11, 2023
1 parent b8d473b commit 7262026
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkgs/build-support/rust/hooks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
'';
Expand Down

0 comments on commit 7262026

Please sign in to comment.