I have a project that builds multiple binaries using separate sources in src/ folder.
In this configuration, I want to pass custom rustflag to build one of these binaries using custom linker script (-Tlink.x, along with custom build.rs). How can I accomplish this?
I tried various ways to set rustflags, but all broke build of other binaries or depending libraries.
- Running cargo with RUSTFLAGS="..." cargo build ... caused other builds to fail, as all rustc invocation got this arg passed.
- Setting rustflags=... in [build] or [target.triplet] section of .cargo/config also failed, as rustflags applied to all other compilation/linking as well.
While it does not work, what I essentially want is to write following:
in .cargo/config
[build.foobinary]
rustflags = ...
or
in Cargo.toml
[[bin]]
name = foobinary
rustflags = ...
Is there any way to do something equivalent?