It is currently not possible to specify rustflags
on a per-profile basis in Cargo.toml
.
The rustflags
property is, however, support under [build]
and [target...]
sections in .cargo/config
, but those apply to all profiles. Profiles also cannot selectively enable features, so rigging it with a [target.'cfg(feature="feat")']
also doesn’t work.
My use case for this feature is that I want to aggressively optimise release builds for size, which means I want to set rustflags = ['-C', 'link-arg=-s']
to strip symbols from the builds. However, these rustflags
are not desirable for debug builds, hence my desire to only apply them for release builds.