Skip to content

Commit 8325770

Browse files
authored
docs(guide): Cover feature-unification (#16108)
### What does this PR try to resolve? Incorporates the [cargo-workspace-hack](https://corrode.dev/blog/tips-for-faster-rust-compile-times/#improve-workspace-build-times-with-cargo-hakari) build performance strategy into our guide. ### How to test and review this PR?
2 parents e6cc50d + 8ceddf2 commit 8325770

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/doc/src/guide/build-performance.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,33 @@ Trade-offs:
110110
- ✅ Faster link times
111111
- ❌ Might not support all use-cases, in particular if you depend on C or C++ dependencies
112112

113+
### Resolve features for the whole workspace
114+
115+
Consider: adding to your project's `.cargo/config.toml`
116+
117+
```toml
118+
[resolver]
119+
feature-unification = "workspace"
120+
```
121+
122+
When invoking `cargo`,
123+
[features get activated][resolver-features] based on which workspace members you have selected.
124+
However, when contributing to an application,
125+
you may need to build and test various packages within the application,
126+
which can cause extraneous rebuilds because different sets of features may be activated for common dependencies.
127+
With [`feauture-unification`][feature-unification],
128+
you can reuse more dependency builds by ensuring the same set of dependency features are activated,
129+
independent of which package you are currently building and testing.
130+
131+
Trade-offs:
132+
- ✅ Fewer rebuilds when building different packages in a workspace
133+
-**Requires using nightly Rust and an [unstable Cargo feature][feature-unification]**
134+
- ❌ A package activating a feature can mask bugs in other packages that should activate it but don't
135+
- ❌ If the feature unification from `--workspace` doesn't work for you, then this won't either
136+
137+
[resolver-features]: ../reference/resolver.md#features
138+
[feature-unification]: ../reference/unstable.md#feature-unification
139+
113140
## Reducing built code
114141

115142
### Removing unused dependencies

0 commit comments

Comments
 (0)