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

Intermingled JSON output from concurrent compilers #37011

Closed
Boddlnagg opened this issue Oct 6, 2016 · 7 comments
Closed

Intermingled JSON output from concurrent compilers #37011

Boddlnagg opened this issue Oct 6, 2016 · 7 comments

Comments

@Boddlnagg
Copy link
Contributor

I don't know whether this is the right way to report this, since I found two related issues (#32486 and #30559), but my case is a bit different. It might also be a cargo issue.

In order to get JSON output from cargo, I passed --error-format json through RUSTFLAGS. When multiple crates are compiled in parallel, sometimes their build output is intermingled:

   Compiling library1 v0.1.0 (file:///D:/Code/Rust/dependency_test/library1)
   Compiling library2 v0.1.0 (file:///D:/Code/Rust/dependency_test/library2)
{"message":"function is never used: `foobar2`, #[warn(dead_code)] on by default","{"message":"function is never used: `foobar`, #[warn(dead_code)] on by default","code":codenull,"level":"warning"":,"spans":[null,"level":"warning{"file_name":"D:\\Code","\\Rust\\dependency_test\\library1\\spans":[{"file_name"src\\lib.rs":"D:,"byte_start":0,"byte_end"\\Code\\Rust\\dependency_test\\library2\\src\\lib.rs",:30,"line_start":1,"byte_start":"line_end":4,0,"byte_end"column_start":1,"":31,column_end":2,"is_primary""line_start":1,"line_end:true,"text"":4,"column_start":1,"column_end":2,"is_primary":true:[{"text":"fn foobar()","highlight_start":1,"highlight_end":,"text":12},{"text":"{","highlight_start":1,"highlight_end":2},[{"text{"text":"    let x = 2;","highlight_start":1,"highlight_end":15},{"text":"}","highlight_start":":"fn foobar2()","highlight_start":1,"highlight_end":131,"highlight_end":2}],"label":null,"suggested_replacement":null,"expansion":},{"text":"{","highlight_start":1,"highlight_end":2},{"nulltext":"    let y = 2;","highlight_start"}],"children":[:1,"highlight_end":15],"rendered":null}
},{"text":"}",{"message":"unused variable: `x`, #[warn(unused_variables)] on by default","code":null,"level":"warning","spans":[{"file_name":"D:\\Code\\Rust\\dependency_test\\library1\\src\\lib.rs","byte_start":22,"byte_end":23,"line_start""highlight_start"::1,"highlight_end":32}],"label":null,"line_end":3,"column_start","suggested_replacement":null,"expansion":null}],"children":[:9,"column_end":10,"is_primary":true,"text":[{"text":"    let x = 2;","highlight_start],"rendered":null}
":9,"highlight_end":10{"message":"unused variable: `y`, #[warn(unused_variables)] on by default","code":null,"level":"warning","spans":[{"file_name":"D:\\Code\\Rust\\dependency_test\\}],"label":null,"suggested_replacement":null,"expansion":null}library2],"children"\\src\\lib.rs","byte_start":23,"byte_end"::[],"rendered":null}
24,"line_start":3,"line_end":3,"column_start":9,"column_end":10,"is_primary":true,"text":[{"text":"    let y = 2;","highlight_start":9,"highlight_end":10}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null}
   Compiling testbin v0.1.0 (file:///D:/Code/Rust/dependency_test/binary)
{"message":"incorrect close delimiter: `}`","code":null,"level":"error","spans":[{"file_name":"src\\main.rs","byte_start":41,"byte_end":42,"line_start":3,"line_end":3,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[{"message":"unclosed delimiter","code":null,"level":"note","spans":[{"file_name":"src\\main.rs","byte_start":24,"byte_end":25,"line_start":2,"line_end":2,"column_start":13,"column_end":14,"is_primary":true,"text":[{"text":"    println!(\"Hello, world!\"","highlight_start":13,"highlight_end":14}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null}],"rendered":null}
{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":null}
error: Could not compile `testbin`.

To learn more, run the command again with --verbose.

This also happens when redirecting stderr (where Cargo prints its output) to a file, so I won't be able to parse those messages correctly.

I'm using the latest nightlies:

D:\Code\Rust\dependency_test\binary>cargo -V
cargo 0.13.0-nightly (a713da1 2016-10-05)

D:\Code\Rust\dependency_test\binary>rustc -V
rustc 1.14.0-nightly (3210fd5c2 2016-10-05)
@alexcrichton
Copy link
Member

cc @jonathandturner

You may also be interested in the --message-format json flag that just landed in Cargo which will get release tonight hopefully. I think that fixes this problem?

@Boddlnagg
Copy link
Contributor Author

Oh, yes, I was looking for such a flag but totally missed that PR. I think this will fix the problem for me 👍

@steveklabnik
Copy link
Member

So, is this not a bug, then?

@Boddlnagg
Copy link
Contributor Author

Just tried the latest nightly and that's exactly what I need (for cargo support in VisualRust), so it's a least not a bug that needs to be fixed urgently. Maybe it should be documented somewhere (in the cargo documentation) that using --error-format json via RUSTFLAGS is not supported.

@sophiajt
Copy link
Contributor

sophiajt commented Oct 7, 2016

That sounds like a bug if setting RUSTFLAGS doesn't change the output format...

@Boddlnagg
Copy link
Contributor Author

It does change the output format, but it's useless, because the output might be intermingled.

@Mark-Simulacrum
Copy link
Member

If this is a bug, I think this is a Cargo bug -- rustc itself just prints to stdout/stderr -- therefore I'm going to close.

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

5 participants