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

universally directly depend on serde_derive instead of accessing it through serde. #135647

Open
lolbinarycat opened this issue Jan 17, 2025 · 3 comments
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged.

Comments

@lolbinarycat
Copy link
Contributor

bootstrap does this in order to flatten its dependencies and improve build times, but since other crates (like compiletest and rustdoc) use the derive feature flag, i believe this means serde has to be built twice to use any of these programs.

wouldn't it be best to always use the same set of feature flags to serde?

@lolbinarycat lolbinarycat added the C-cleanup Category: PRs that clean code up or issues documenting cleanup. label Jan 17, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 17, 2025
@lolbinarycat
Copy link
Contributor Author

this of course would require that the derive feature is never used in the dependency tree, but looking at the output of cargo tree -e features, it doesn't seem to be, at least not for compiletest.

@workingjubilee
Copy link
Member

isn't this what cargo's feature unification is for?

@hanna-kruppe
Copy link
Contributor

Feature unification is currently always done w.r.t. the set of build-targets in any given Cargo invocation (modulo host-target distinctions that I'll ignore for simplicity):

  • If cargo build -p bootstrap does not build anything that enables serde/derive, then serde will be built without that feature.
  • If a subsequent cargo build does build something that enables serde/derive then serde itself will have to be built a second time. Anything that transitively depends on serde also has to be rebuilt as a consequence.
  • (Both variants of serde and its reverse dependencies can co-exist in the build cache, so there's no thrashing when you switch back and forth between the two kinds of builds.)

Once rust-lang/cargo#14774 is implemented it'll be possible to change this behavior. It's not clear to me if this would be desirable -- it negates any benefit that bootstrap may derive from directly depending on serde_derive because serde/derive would always be enabled.

All of the above assumes that bootstrap itself and the rest of the repository are a single Cargo workspace or at least share a build cache (target/ directory). I don't know if that's the case today, so serde and other shared dependencies may have to be built twice in any case. However, depending directly on serde_derive may still be useful for faster builds of rustdoc, compiletest, etc. regardless of what bootstrap itself depends on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged.
Projects
None yet
Development

No branches or pull requests

4 participants