In this PR, I introduce put proc macro code behind a feature gate:
if !cfg!(zerocopy_derive_union_into_bytes) {
...
}
Our CI tests assume that this --cfg
is passed. We have a custom cargo
wrapper that sets various --cfg
s, and I update that wrapper to pass this --cfg
.
Bizarrely, this works and all of the tests pass except when cross-compiling. When cross-compiling, even just via cargo check
, somehow the --cfg
doesn't make its way to the proc macro during compilation.
My question is: why might cross-compilation cause --cfg
arguments not to be propagated when compiling a proc macro?
Steps to reproduce:
- Take a look at this PR
- Check out the PR by checking out this branch
- Run
./cargo.sh +nightly check --tests --package zerocopy-derive
(this should succeed) - Run
./cargo.sh +nightly check --tests --package zerocopy-derive --target i686-unknown-linux-gnu
(this should fail)
Note: The same failure mode is observed with vanilla Cargo; you can also replace steps (3) and (4) with:
RUSTFLAGS='--cfg zerocopy_derive_union_into_bytes' cargo +$(./cargo.sh --version nightly) check --tests --package zerocopy-derive
RUSTFLAGS='--cfg zerocopy_derive_union_into_bytes' cargo +$(./cargo.sh --version nightly) check --tests --package zerocopy-derive --target i686-unknown-linux-gnu