nixpkgs/pkgs/build-support/rust/hooks
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
..
cargo-build-hook.sh rust/hooks: ensure the build output ends up in the right place 2021-12-26 11:04:07 +03:00
cargo-check-hook.sh rustPlatform: add support for features 2021-10-27 08:08:03 -04:00
cargo-install-hook.sh cargo/hooks: allow hooks to be disabled 2021-03-08 19:17:03 +01:00
cargo-nextest-hook.sh rustPlatform.cargoNextestHook: init 2022-11-28 16:59:52 -05:00
cargo-setup-hook.sh Merge pull request #218472 from figsoda/cargo-setup 2023-03-03 19:40:55 -05:00
default.nix rust: fix overriding rust flags on musl 2023-03-16 02:29:46 +00:00
maturin-build-hook.sh maturin: 0.12.9 -> 0.13.0 2022-07-21 22:35:32 +02:00
rust-bindgen-hook.sh rustPlatform.bindgenHook: init 2022-02-22 19:37:07 +01:00