nixpkgs/pkgs/build-support/rust
Alyssa Ross 470e6130b3
rust: fix overriding rust flags on musl
If RUSTFLAGS is set in the environment, Cargo will ignore rustflags
settings in its TOML configuration.  So setting RUSTFLAGS=-g (like
separateDebugInfo does) to generate debug info breaks
dynamically-linked Rust packages on musl.  This breakage is visible
for any packages that call into C dynamic libraries.  If the binary is
linked directly to a C dynamic library, it will fail to build, and if
it depends on a Rust library which links a C dynamic library, it will
segfault at runtime when it tries to call a function from the C
library.  I noticed this because pkgsMusl.crosvm is broken for this
reason, since it sets separateDebugInfo = true.

It shouldn't be possible to end up with broken binaries just by using
RUSTFLAGS to do something innocuous like enable debug info, so I think
that, even though we liked the approach of modiyfing .cargo/config
better at the time, it's become clear that it's too brittle, and we
should bite the bullet and patch the compiler instead when targetting
musl.  It does not appear to be necessary to modify the compiler at
all when cross-compiling /from/ dynamically-linked Musl to another
target, so I'm only checking whether the target system is
dynamically-linked Musl when deciding whether to make the modification
to the compiler.

This reverts commit c2eaaae50d
("cargoSetupHook: pass host config flags"), and implements the
compiler patching approach instead.
2023-03-16 02:29:46 +00:00
..
build-rust-crate buildRustCrate: add libiconv to nativeBuildInputs on darwin 2023-03-08 14:39:25 -06:00
build-rust-package buildRustPackage: don't passthru cargoDeps 2023-03-02 10:20:15 +10:00
fetch-cargo-tarball cargo: move cert info to fetch-cargo-tarball 2023-02-01 06:53:43 +10:00
hooks rust: fix overriding rust flags on musl 2023-03-16 02:29:46 +00:00
lib build-support/rust/lib: Add toTargetVendor 2023-02-15 20:37:45 -05:00
sysroot
test/import-cargo-lock rustPlatform.importCargoLock: add support for v1 lock files 2023-02-26 00:45:40 -05:00
default-crate-overrides.nix default-crate-overrides.nix: add graphene-sys 2023-01-13 16:43:39 +00:00
fetchcargo-default-config.toml
fetchcrate.nix fetchCrate: rewrite in terms of fetchzip 2022-11-03 12:33:27 -04:00
import-cargo-lock.nix rustPlatform.importCargoLock: passthru lockFile 2023-02-26 00:46:36 -05:00