bazelbuild / bazelbuild/rules_rust
Features from build dependencies aren't propagated to normal dependencies
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
After https://github.com/bazelbuild/rules_rust/pull/2877 (https://github.com/bazelbuild/rules_rust/commit/350d249ca2c976f92c96d63e4f89f9cf00965188) was merged, we've started seeing an error in our compilation pipeline where a crate's build script would be built with a feature, but the crate itself wouldn't.
Here's a minimal repro case: https://github.com/alexkirsz/rules_rust_build_dep_repro
If you run `cargo build --target=aarch64-apple-ios --verbose`, you'll see that cargo builds `mime_guess` on both the host platform (aarch64-apple-darwin in my case) and the target platform (aarch64-apple-ios) with the "rev-mappings" feature enabled, even though it is theoretically only needed at compile-time on the host platform.
If you run `bazel build -s --platforms=//:ios_arm64 //:mime_guess_test --keep_going`, you'll see that rules_rust builds the build script of `mime_guess` with the "rev-mappings" feature enabled, but on the target platform, it builds `mime_guess` without the feature, resulting in a compilation error.
Instead, it should either:
1. Copy Cargo's behavior and always build with the complete set of features from normal and build deps; or
2. Build the build script twice for the host platform, once with the feature, and once without.
Contributor guide
Assessment
This issue has not been assessed yet.