bazelbuild / bazelbuild/rules_rust
`tags` and `build_script_tags` crate annotations
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
The `cc` library compiles C/C++/assembly into a Rust library/application. The `cc` library supports parallel compilation and, when enabled, will limit parallelism to `NUM_JOBS`, where `NUM_JOBS` is supplied by `cargo`.
Commit https://github.com/bazelbuild/rules_rust/commit/8df4517d370b0c543a01ba38b63e1d5a4104b035 fixes `NUM_JOBS` to `1` in `rules_rust`. There is currently no mechanism to change that, leading to longer build time compared to `cargo`
Conversing with @UebelAndre led to the following strategy
- Update `cargo_build_script` to support parsing `cpu:#` from `tags` and using that as the value for `NUM_JOBS`
- Update `crate_universe` to support `tags` and `build_script_tags` in `crate.annotation`
After the proposed changes are implemented, one could write
```
crates_repository(
annotations = {"foobar-sys": [crate.annotation(
build_script_tags = ["cpu:4"],
)]},
...
)
```
to build the `foobar-sys` crate using `4` CPUs. Bazel and the build script would agree on how many resources the action takes to not over-schedule the machine.
Relevant issues:
- https://github.com/bazelbuild/rules_foreign_cc/issues/329
- https://github.com/bazelbuild/bazel/issues/6477
- https://github.com/bazelbuild/bazel/issues/10443
Contributor guide
Assessment
This issue has not been assessed yet.