From 51c62063e366d14e4353c85f22adb085330b9684 Mon Sep 17 00:00:00 2001 From: Yureka Date: Sat, 13 Aug 2022 14:43:50 +0200 Subject: [PATCH] cargoSetupHook: set crt-static Tell rust if we want our binaries linked statically or dynamically. Otherwise the compiler will always produce statically linked binaries for musl targets, as this is the default. --- pkgs/build-support/rust/hooks/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/build-support/rust/hooks/default.nix b/pkgs/build-support/rust/hooks/default.nix index 430f758e9ab8..652b074c3020 100644 --- a/pkgs/build-support/rust/hooks/default.nix +++ b/pkgs/build-support/rust/hooks/default.nix @@ -76,6 +76,7 @@ in { [target."${shortTarget}"] "linker" = "${ccForHost}" ''} + "rustflags" = [ "-C", "target-feature=${if stdenv.hostPlatform.isStatic then "+" else "-"}crt-static" ] ''; }; } ./cargo-setup-hook.sh) {};