Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features from build dependencies aren't propagated to normal dependencies #2946

Open
alexkirsz opened this issue Oct 18, 2024 · 2 comments
Open

Comments

@alexkirsz
Copy link
Contributor

After #2877 (350d249) 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.
@alexkirsz alexkirsz changed the title Features from build-dependencies aren't properly propagated to normal dependencies Features from build dependencies aren't propagated to normal dependencies Oct 18, 2024
@sthornington
Copy link
Contributor

I believe we are seeing this as well. I've been hacking away on a little fix for #2938 and noticed that, e.g., building something with a crate dependency on tokio was failing for lack of parking_lot, so it seems like the feature propagation might not be working not only for build scripts but also general dependencies?

@sthornington
Copy link
Contributor

In my case I was able to fix the problem by changing a dependency on tokio to use the "full" feature set, but I am not sure why it was trying to build parts of it that needed parking_lot if that feature was not present ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants