Set linker for cargo test
⚓ Rust 📅 2026-02-13 👤 surdeus 👁️ 1I've been toying around with the knus crate which triggers Linker dies when using knuffel. I switched to using ld_classic by creating a .cargo/config.toml containing:
[target.aarch64-apple-darwin]
rustflags = ["-C", "link-arg=-Wl,-ld_classic"]
[target.x86_64-apple-darwin]
rustflags = ["-C", "link-arg=-Wl,-ld_classic"]
This works for binary crates, but I added some knus extensions to a library crate and when I want to run their tests using cargo test I get the assertion from ld. I tried to move the .cargo/config.toml settings to my global ~/.cargo/config.toml, but it doesn't seem to pick those changes for cargo test. (I did run cargo clean between configuration changes, just in case).
Is cargo test supposed to respect the rustflags in .cargo/config.toml and ~/.cargo/config.toml? Or is there a differently named setting, sort of like dependencies vs dev-dependencies in Cargo.toml?
1 post - 1 participant
🏷️ Rust_feed