From e5da99075b0a39e2c0e8fcf09a3db755d2c2b51f Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 14 May 2025 09:30:14 +0200 Subject: [PATCH] build-support/meson: set crt-static for rustc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just like we do in the Cargo setup hook, to have musl/static builds work properly we need to explicitly set whether we want static builds or not. Rust's built-in target definitions are inconsistent — some musl architectures default to static, and others don't. Unfortunately it doesn't seem to be valid to break this list onto multiple lines. --- pkgs/build-support/lib/meson.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/lib/meson.nix b/pkgs/build-support/lib/meson.nix index 501d4315fdff..76f458cdd9c8 100644 --- a/pkgs/build-support/lib/meson.nix +++ b/pkgs/build-support/lib/meson.nix @@ -27,7 +27,9 @@ let [binaries] llvm-config = 'llvm-config-native' - rust = ['rustc', '--target', '${stdenv.targetPlatform.rust.rustcTargetSpec}'] + rust = ['rustc', '-C', 'target-feature=${ + if stdenv.targetPlatform.isStatic then "+" else "-" + }crt-static', '--target', '${stdenv.targetPlatform.rust.rustcTargetSpec}'] # Meson refuses to consider any CMake binary during cross compilation if it's # not explicitly specified here, in the cross file. # https://github.com/mesonbuild/meson/blob/0ed78cf6fa6d87c0738f67ae43525e661b50a8a2/mesonbuild/cmake/executor.py#L72