build-support/meson: set crt-static for rustc

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.
This commit is contained in:
Alyssa Ross
2025-05-14 09:30:14 +02:00
parent fcf1db5572
commit e5da99075b

View File

@@ -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