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

bug(?): process_wrapper fails on non-JSON output, breaking pipelined compilation #3253

Open
ParkMyCar opened this issue Feb 10, 2025 · 3 comments

Comments

@ParkMyCar
Copy link
Contributor

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. 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.

@havasd
Copy link
Contributor

havasd commented Feb 10, 2025

the lack of CARGO env var is a complicated problem but as a workaround I have this:

--- BUILD.bazel
+++ BUILD.bazel
@@ -33,10 +33,7 @@ rust_proc_macro(
             "WORKSPACE.bazel",
         ],
     ),
-    crate_features = [
-        "proc-macro-crate",
-        "std",
-    ],
+    crate_features = [],
     crate_root = "src/lib.rs",
     edition = "2021",
     rustc_flags = [

in MODULE.bazel:

crate.annotation(
  crate = "num_enum_derive",
  version = "0.7.3",
  patches = ["scripts/bazel/num_enum_derive.patch"],
)

@ParkMyCar
Copy link
Contributor Author

Ohhh good thinking on using patch! My fix was to disable default features for num_enum which removes the dep on proc-macro-crate

@havasd
Copy link
Contributor

havasd commented Feb 10, 2025

In my case I had to use patch because it was a transitive dependency and I couldn't manage it from my project.

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

2 participants