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

Building with --@rules_rust//:error_format flag invalidates Bazel cache #1531

Open
alexpusch opened this issue Aug 27, 2022 · 2 comments
Open

Comments

@alexpusch
Copy link

Running bazel build <target> followed by bazel build --error-format=json <target> will discard analysis cache and action cache:

(from build command log)

INFO: Build option --@rules_rust//:error_format has changed, discarding analysis cache.

(From bazel explain log)

Executing action 'Compiling Rust (without process_wrapper) rlib tinyjson (4 files)': action command has changed.
New action: Compiling Rust (without process_wrapper) rlib tinyjson (4 files)

A consecutive bazel build <target> will run without action cache as well.

This behavior isn't really surprising, as described in several Bazel tickets - i.e bazelbuild/bazel#13591
but as Cargo manages to re emit errors in json format without recompiling the project, I seek your advice.

In our use case we setup Rust analyzer to run a custom cargo check command that uses the --error-format=json flag. This results in consecutive builds with and without this flag. We edit code, Rust analyzer runs bazel build --error-format=json, than we run the tests without the --error-format=json flag. This results in a very cache inefficient workflow

@googleson78
Copy link
Contributor

I think my PR might be of interest to you - #1657

In there, if you always run with the "save output" flag, you can reuse your cache and also get normal human readable error messages. I'd hope saving the output from rustc is not heavyweight enough to affect compilation times.

It's still not ready to be used yet though, as I described in the PR.

@zapkub
Copy link

zapkub commented Mar 27, 2023

I am unable to make #1657 works so I made a temporary modification until this feature support by always emit json output from rustc zapkub@6622d81

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants