bazelbuild / bazelbuild/rules_rust
Pipelined compilation relies on crates building reproducibly
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
I've encountered an issue when enabling `pipelined_compilation`: if a crate doesn't build reproducibly, then the .rmeta and .rlib end up with different hashes, and you get weird errors when trying to use that crate like this:
```
error[E0460]: found possibly newer version of crate `prost_build` which `` depends on
--> /build.rs:14:5
|
14 | ::compile_protos(&proto_files, &["../../proto"], |config| {
| ^^^^^^^^^^^^^^
|
= note: perhaps that crate needs to be recompiled?
= note: the following crate versions were found:
crate `prost_build`: /home/brian/.cache/bazel/_bazel_brian/b648ee8a4cf3ea5f702d496242c79348/execroot/com_matician/bazel-out/k8-opt-exec-589A3AC8/bin/external/raze__prost_build__0_10_4/libprost_build-705194240.rlib
crate ``: /home/brian/.cache/bazel/_bazel_brian/b648ee8a4cf3ea5f702d496242c79348/execroot/com_matician/bazel-out/k8-opt-exec-589A3AC8/bin/rust//lib-2814067294.rlib
```
This particular case is because `prost-build` embeds absolute paths from environment variables (at https://github.com/tokio-rs/prost/blob/c2d70d962a701131cacdd45da31a8ed5348d43a6/prost-build/src/lib.rs#L1192), but there are other ways to have the same problem.
Setting `disable_pipelining = True` for crates that do this is a usable workaround. I'm not sure if rules_rust can do anything automatically here, or if this just needs to be documented.
(I do plan to fix this so my builds are reproducible eventually, but some people might not care about that, also it was really hard to figure out what the problem was.)
Contributor guide
Assessment
This issue has not been assessed yet.