cargo icon indicating copy to clipboard operation
cargo copied to clipboard

add --nocapture for build-scripts

Open A4-Tacks opened this issue 2 years ago • 5 comments

Problem

Directly output the output of build-script to stdout/stderr.

I do this because sometimes the error log is very large, which can easily exceed 4GB of cargo memory usage

But sometimes I only need the error header quickly and terminate when I see the required error But for the current cargo, I need to wait for its output to be completed before outputting it uniformly, which may take a very long time

Proposed Solution

No response

Notes

No response

A4-Tacks avatar Mar 03 '24 14:03 A4-Tacks

But sometimes I only need the error header quickly and terminate when I see the required error

Did you mean terminating manually by yourself, or Cargo terminates when build script exits with non-zero code?

I do this because sometimes the error log is very large, which can easily exceed 4GB of cargo memory usage

An alternative way to deal with high memory usage is Cargo parses build script directives while streaming the output, instead of capturing it and parsing it after build script execution. (See the code here)

weihanglo avatar Mar 03 '24 15:03 weihanglo

Did you mean terminating manually by yourself, or Cargo terminates when build script exits with non-zero code?

Yes, I mean manually terminate it

A4-Tacks avatar Mar 03 '24 15:03 A4-Tacks

If I'm understanding this, a single build scripts output is over 4GB? What is the situation leading to that?

epage avatar Mar 04 '24 15:03 epage

If I'm understanding this, a single build scripts output is over 4GB? What is the situation leading to that?

I use the lalrpop library to build a complex language parser, which outputs an extremely large state table when I make modifications that cause conflicts

A4-Tacks avatar Mar 04 '24 15:03 A4-Tacks

I have a project that uses a cargo build script to compile some C++ code with make that is then linked to the rest of the project, and this feature would be useful to me if implemented. I just discovered that I had a bunch of compiler warnings from GCC that I never saw when building, because the C++ still compiled without errors, so the cargo build script never errored, and thus the warning messages were never shown.

I'm still pretty new to Rust, so I don't know if there's some way to tell Cargo to display stderr that it captures regardless of the build script's exit status or not. But regardless I think this is an important feature to implement.

nyankittone avatar Dec 04 '25 09:12 nyankittone