bazelbuild / bazelbuild/rules_rust
bug(?): `process_wrapper` fails on non-JSON output, breaking pipelined compilation
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
When pipelined compilation is enabled, the process wrapper parses the output from `stderr` as JSON to listen for when `rmetadata` has been produced and thus it can kill the action.
Thus, if a proc-macro prints to `stderr` it will break the build. For example, I'm running into this now via `num_enum` -> `num_enum_derive` -> `proc-macro-crate` which prints the following warning:
```
Warning: `CARGO` env variable not set.
=> defaulting to `num_enum`
Warning: `CARGO` env variable not set.
=> defaulting to `num_enum`
Warning: `CARGO` env variable not set.
=> defaulting to `num_enum`
```
Maybe we can set the `CARGO` env variable to fix this case specifically, but in general it would be nice if the `process_wrapper` could tolerate non-JSON output. Probably we can just skip non-JSON lines and expect `rustc` to do the right thing.
If someone is interested in picking this up, I believe the change needs to be made in these [two functions](https://github.com/bazelbuild/rules_rust/blob/main/util/process_wrapper/rustc.rs#L64-L106). If we fail to parse a line as JSON then I think we want to return `LineResult::Skip`. Optionally we probably want to make this configurable, e.g. allow users to specify an option like `parse_rustc_output=strict` which will retain the current behavior and fail if the output isn't JSON.
Contributor guide
Assessment
This issue has not been assessed yet.