Description
Example .cargo/config
:
[target.'cfg(any(target_arch="arm", target_arch="aarch64"))']
rustflags = ["-C", "target-feature=+neon"]
[build]
rustflags = ["-W", "unused-extern-crates"]
When running for example cargo build --target armv7-linux-androideabi
I’d expect both sets of flags to be passed to rustc, but only the former is.
When running RUSTFLAGS="-C link-args=-fuse-ld=gold" cargo build --target armv7-linux-androideabi
I’d expect all three sets of flags, but only the environment variable one is used and both configs are ignored.
The intra-config-file case can be worked around by duplicating some config, but the environment variable is still useful for wrapper scripts like Servo’s mach
to dynamically choose to use some flags or not. (In this case depending on testing the presence of a ld.gold
executable.) Setting some flags through a config file is useful when cargo build
is used directly without going through the wrapper script. (CC https://www.mail-archive.com/dev-servo@lists.mozilla.org/msg02703.html.)