-
Notifications
You must be signed in to change notification settings - Fork 440
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
[Bug] Unused transitive dependencies got built #3001
Comments
This is caused by Cargo feature unification:
The working behavior you're seeing is because you're invoking cargo for just one of the packages.
Why is |
As for fixing your issue, I don't fully understand the context of what's going wrong, but if it's a matter of compiling for WASI vs not you may want to look into platform specific dependencies. |
Many thanks for your kindly explanation and helpful link, I think platform specific dependencies is exactly what I want. |
Mini reproducible repository: https://github.com/fa93hws/rules_rust_transitive_deps
Step to reproduce:
rustup target add wasm32-wasi
cd swc_plugin
cargo build-wasi
and it passesbazel build :wasm
, and it failed withStep to fix the error
fa93hws/rules_rust_transitive_deps#1 fixes the issue, by removing
miette = { version = "7.2.0", features = ["fancy", "syntect-highlighter"] }
from the closure.Where I think goes wrong
I'm pretty new to
rust
andrules_rust
so I maybe wrong. I'm not sure about the GCC tooling error but I think it's irrelevant here. The real problem is thatonig_sys
shouldn't be included in the build graph.If I run
cargo build-wasi
underswc_plugin
dir, the output looks like this, and there's noonig_sys
at all.But it's somehow built by
rules_rust
.For context,
onig_sys
is a tranistive deps ofmiette
withfeatures = ["fancy", "syntect-highlighter"]
. When there's onlyswc_plugin
in the workspace,miette
only hasin the lock file.
But when
miette = { version = "7.2.0", features = ["fancy", "syntect-highlighter"] }
is added to another project in the workspace (another_rust_project
),miette
's dependencies becomes:So I feel that the issue is that,
rules_rust
will take a look at the lock file, and build all transitive dependencies no matter whether they are actually needed or not? As a comparison,cargo build
builds the needed dependencies only.Other info:
Platform: MacOS 15.1 (24B83)
Rust version:
The text was updated successfully, but these errors were encountered: