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

Build progressbar interleaved with rustc errors #5695

Closed
bjorn3 opened this issue Jul 7, 2018 · 16 comments · Fixed by #5698
Closed

Build progressbar interleaved with rustc errors #5695

bjorn3 opened this issue Jul 7, 2018 · 16 comments · Fixed by #5698

Comments

@bjorn3
Copy link
Member

bjorn3 commented Jul 7, 2018

[...]
error[E0308]: mismatched types
   --> /Users/bjorn/.cargo/git/checkouts/miri-f9dcdd0c0ec69fb1/9143a69/src/fn_call.rs:202:83
    |
202 |                     let ptr = self.memory.allocate(Size::from_bytes(size), align, Some(MemoryKind::C.into()))?;
    |                                                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `rustc_mir::interpret::MemoryKind`, found enum `std::option::Option`
    |
    = note: expected type `rustc_mir::interpret::MemoryKind<memory::MemoryKind>`
               found type `std::option::Option<_>`

error[E0308]: mismatched types===============================>       ] 122/137: serde, hyper, serde_derive, miri, ring                               
   --> /Users/bjorn/.cargo/git/checkouts/miri-f9dcdd0c0ec69fb1/9143a69/src/fn_call.rs:398:25
    |
398 |                         Some(MemoryKind::Env.into()),
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `rustc_mir::interpret::MemoryKind`, found enum `std::option::Option`
    |
    = note: expected type `rustc_mir::interpret::MemoryKind<memory::MemoryKind>`
               found type `std::option::Option<_>`

error[E0308]: mismatched types===============================>       ] 122/137: serde, hyper, serde_derive, miri, ring                               
   --> /Users/bjorn/.cargo/git/checkouts/miri-f9dcdd0c0ec69fb1/9143a69/src/fn_call.rs:659:48
    |
659 |                                                Some(MemoryKind::Rust.into()))?;
    |                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `rustc_mir::interpret::MemoryKind`, found enum `std::option::Option`
    |
    = note: expected type `rustc_mir::interpret::MemoryKind<memory::MemoryKind>`
               found type `std::option::Option<_>`

error[E0308]: mismatched types================================>      ] 123/137: serde, hyper, serde_derive, miri, ring                               
   --> /Users/bjorn/.cargo/git/checkouts/miri-f9dcdd0c0ec69fb1/9143a69/src/fn_call.rs:673:48
    |
673 |                                                Some(MemoryKind::Rust.into()))?;
    |                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `rustc_mir::interpret::MemoryKind`, found enum `std::option::Option`
    |
    = note: expected type `rustc_mir::interpret::MemoryKind<memory::MemoryKind>`
               found type `std::option::Option<_>`

   Compiling toml v0.4.6                                                                                                                             
   Compiling bincode v1.0.1                                                                                                                          
error: aborting due to 9 previous errors======================>      ] 124/137: hyper, serde_derive, miri, ring, toml, bincode 
@alexcrichton
Copy link
Member

Thanks for the report!

cc @kennytm, I had forgotten about this interaction :(

I'm not sure how to solve this without capturing rustc's errors which we don't currently have the ability to do without losing formatting :(

alexcrichton added a commit to alexcrichton/cargo that referenced this issue Jul 8, 2018
This is primarily blocked on rust-lang#5695 which unfortunately doesn't have a great fix
today, so disable it for now while we try to work out a better solution.

Closes rust-lang#5695
Closes rust-lang#5697
bors added a commit that referenced this issue Jul 9, 2018
Disable progress bar for build in Cargo

This is primarily blocked on #5695 which unfortunately doesn't have a great fix
today, so disable it for now while we try to work out a better solution.

Closes #5695
Closes #5697
@bors bors closed this as completed in #5698 Jul 9, 2018
@Eh2406
Copy link
Contributor

Eh2406 commented Jul 9, 2018 via email

@ehuss
Copy link
Contributor

ehuss commented Jul 9, 2018

@Eh2406 it depends on the platform. On Windows there is a global lock between rustc processes. On other platforms, the only coordination is to rely on the operating system to flush data in atomic blocks. In POSIX this is typically PIPE_BUF in size. On linux this is 4k which is pretty safe for most rust messages. On macos it is 512 bytes, which can cause problems on some large messages.

@alexcrichton
Copy link
Member

It's true though! We might be able to create a protocol between Cargo and rustc about how errors are coordinated and that could buy Cargo more flexibility in this regard

@euclio
Copy link
Contributor

euclio commented Jul 9, 2018

I seem to remember a discussion about extracting rustc's error formatting machinery into a reusable crate (though I can't find that discussion, sorry!). If that happened, would using rustc's JSON output be enough, as cargo could use that crate to recreate the errors?

@alexcrichton
Copy link
Member

Indeed! If that happened we could safely capture rustc's output and render it to the console in Cargo as rustc would.

@ishitatsuyuki
Copy link
Contributor

Regarding error buffering, I don't think we need to parse rustc's JSON output? I think my idea here is a more generic way to achieve this.

@kennytm
Copy link
Member

kennytm commented Jul 10, 2018

@ishitatsuyuki Cargo currently needs to know the terminal size for the progress bar. This is done by ioctl(STDERR_FILENO, TIOCGWINSZ) on Unix and GetConsoleScreenBufferInfo(GetStdHandle(STD_ERROR_HANDLE)) on Windows. While rustc currently doesn't need to know the terminal size, I cannot deny the possibility that it might be used in the future. Do you know if it is possible to transmit these info to the child process while piping/teeing their stdout/stderr?

@ishitatsuyuki
Copy link
Contributor

@kennytm I believe that the solution here is to buffer all rustc output until the invocation ends, and rustc should never be interactive or display a progress indicator as it's not a compiler's job but the build tool's.

Though, if we ever need to RPC with rustc, we can change the implementation when we do. I'd say that there's not much motivation for it to be done in the near future, though.

@bjorn3
Copy link
Member Author

bjorn3 commented Jul 11, 2018

[...] buffer all rustc output until the invocation ends [...]

Please don't, That would drastically increase the time before the first errors are printed in some cases.

@ishitatsuyuki
Copy link
Contributor

@bjorn3 To address that, we can stream the output in the case that only one rustc is running. Otherwise, buffering benefits more because you don't want the error contexts to be mixed up anyway.

bors added a commit that referenced this issue Jul 12, 2018
Reintroduce the compile progress bar as an unstable feature (-Z compile-progress)

This allows us to test the feature on-demand to see if there's any other bugs besides #5695.

Also, fixed the flickering #5697 (this was caused by build script emitting Stdout/Stderr events).
@kennytm
Copy link
Member

kennytm commented Jul 19, 2018

I tried (line-)buffering all output of rustc with --color always forwarded. It works fine on Unix and MSYS2 but is totally broken on Windows 7:

screenshot_2018_07_19 22_16_34-fs8

It is using ANSI code despite cmd.exe does not support it.

@ishitatsuyuki
Copy link
Contributor

@kennytm Yes, this is expected. As I wrote before, we should parse all ANSI escapes (limiting to colours) and feed them again into termcolor, making it a portable solution.

@vorner
Copy link

vorner commented Jul 23, 2018

Just throwing a vague idea in, I'm not sure if that would work or be portable. I think the ncurses (and likely other curses) libraries allow to split the terminal into multiple windows that scroll independently. If the progress bar lived in one and rustcs (and other possible things, liku build scripts) run in the other, they should not interact.

Or how do things like screen or tmux work? Do they create a pty for the child processes and process that?

@ishitatsuyuki
Copy link
Contributor

@vorner What are you suggesting that is not portable? The width detecting progress bar or the buffering approach?

I think tmux creates a pty for each pane indeed.

@vorner
Copy link

vorner commented Jul 23, 2018

I didn't say it is not portable. I only said I didn't do any research so I don't know if it is or not. And I was talking about the ncurses windows and PTYs.

bors added a commit that referenced this issue Aug 6, 2018
Fully capture rustc and rustdoc output when -Zcompile-progress is passed

Fixes #5764 and #5695.

On Windows, we will parse the ANSI escape code into console commands via my `fwdansi` package, based on @ishitatsuyuki's idea in #5695 (comment). Outside of Windows the content is forwarded as-is.
matthiaskrgr added a commit to matthiaskrgr/cargo that referenced this issue Sep 23, 2018
…once rust-lang#5695 is fixed

The issue has been resolved and the compile-progress has been reenabled already.
bors added a commit that referenced this issue Sep 23, 2018
job queue: remove outdated comment about reenabling compile-progress once #5695 is fixed

The issue has been resolved and the compile-progress has been reenabled already.
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

Successfully merging a pull request may close this issue.

8 participants