I'm not sure if there's a better place to ask, but happy to re-ask there if there's a better place. I'm attempting to use cargo to do something like
RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo +nightly build --verbose --target wasm32-unknown-unknown
A dependency of mine must be compiled with the
procmacro2_semver_exempt flag. However, if I run the above, that flag gets lost.
If I run
RUSTFLAGS='--cfg procmacro2_semver_exempt --target wasm32-unknown-unknown' cargo +nightly build --verbose
It complains that
error: failed to run `rustc` to learn about target-specific information Caused by: process didn't exit successfully: `rustc - --crate-name ___ --print=file-names --cfg procmacro2_semver_exempt --target wasm32-unknown-unknown --target x86_64-apple-darwin --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro` (exit code: 101) --- stderr error: Option 'target' given more than once
Is there any way pass the RUSTFLAGS and also specify a target? Any help is appreciated!
Edit: From the cargo book, it seems like using RUSTFLAGS the way I did should work:
RUSTFLAGS — A space-separated list of custom flags to pass to all compiler invocations that Cargo performs. In contrast with cargo rustc, this is useful for passing a flag to all compiler instances.
Edit2: This also doesn't appear to work with .cargo/config