nixpkgs/pkgs/development/compilers/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
..
1_67.nix rustc: 1.67.0 -> 1.67.1 2023-02-10 06:55:18 +10:00
binary.nix rustc: don't strip bootstrap on darwin 2022-10-20 09:02:51 +10:00
bootstrap.nix
cargo-auditable-cargo-wrapper.nix cargo-auditable-cargo-wrapper: Use writeShellScriptBin instead of writeShellApplication 2023-01-19 13:50:01 +10:00
cargo-auditable.nix cargo-auditable: 0.6.0 -> 0.6.1 2023-03-06 21:27:01 -05:00
cargo.nix rust: fix overriding rust flags on musl 2023-03-16 02:29:46 +00:00
clippy.nix clippy: add rust team to maintainers 2023-02-20 01:19:56 -05:00
default.nix rustPlatform.buildRustPackage: fix cross compiling auditable packages 2023-01-12 12:22:59 -05:00
make-rust-platform.nix rustPlatform.buildRustPackage: fix cross compiling auditable packages 2023-01-12 12:22:59 -05:00
print-hashes.sh rust: add mips64el to list of bootstrap tarballs 2022-03-18 13:00:34 +10:00
rust-lib-src.nix rust-{lib-}src: deprecate phases 2022-02-25 22:57:59 +01:00
rust-src.nix rust-{lib-}src: deprecate phases 2022-02-25 22:57:59 +01:00
rustc.nix rust: fix overriding rust flags on musl 2023-03-16 02:29:46 +00:00
rustfmt.nix Revert "rustfmt: actually fix the failing test" 2022-04-17 18:20:37 +10:00
setup-hook.sh