-
Notifications
You must be signed in to change notification settings - Fork 435
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
Comments
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? |
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 ... |
After a bit of investigation, I believe #2877 is doing the right thing but now showcase something missing in I had a look at the rust_library(
name = "mime_guess",
deps = [
"@crates__mime_guess-2.0.5//:build_script_build",
# ...
],
crate_features = select({
"@rules_rust//rust/platform:aarch64-apple-darwin": [
"rev-mappings", # aarch64-apple-darwin
],
"//conditions:default": [],
}),
target_compatible_with = select({
"@rules_rust//rust/platform:aarch64-apple-darwin": [],
"@rules_rust//rust/platform:aarch64-apple-ios": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
# ...
)
cargo_build_script(
name = "_bs",
crate_features = select({
"@rules_rust//rust/platform:aarch64-apple-darwin": [
"rev-mappings", # aarch64-apple-darwin
],
"//conditions:default": [],
}),
# ...
)
alias(
name = "build_script_build",
actual = ":_bs",
tags = ["manual"],
) The The rules_rust/cargo/private/cargo_build_script.bzl Lines 95 to 106 in 7890b42
So when building the One idea would be to have cc @UebelAndre, if the explanation makes sense and the potential fix acceptable, I can try working on a PR following your guidance (unless it's an easy fix on your side 🙂). |
We added fake resolve roots in #2749 for proc macros so that they would get resolved for each platform we may run on. We could do something similar for deps which have build scripts. That said, your proposal to have separate targets for "exec-like" features and "target-like" features feels like it would be an improvement. A hazard here is that I believe, because of the possibility of cross-compiling, we'd need to be careful around the platform-specific-ness of these things... |
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 buildsmime_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 ofmime_guess
with the "rev-mappings" feature enabled, but on the target platform, it buildsmime_guess
without the feature, resulting in a compilation error.Instead, it should either:
The text was updated successfully, but these errors were encountered: