-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Unstable --keep-going flag #10383
Unstable --keep-going flag #10383
Conversation
r? @ehuss (rust-highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! I've often wanted a flag similar to this myself, typically for the reason of "please go keep doing work while I go figure out that one error"
I think though that the error handling should be improved here before landing. For example if you use make -j 10 -k
then it will still print the errors for all failed compiles, but here all errors after the first are simply swallowed up and not actually emitted anywhere. In the same manner how we display an error and then punt upwards some arbitrary error I think it would be better to display all errors here (in some fashion that makes them distinctly understandable) and then punt up perhaps something like "N build errors occurred".
Other than that though this seems reasonable to me.
src/cargo/core/compiler/job_queue.rs
Outdated
return Some(e); | ||
} else { | ||
crate::display_error(&e, &mut cx.bcx.config.shell()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize that this was preexisting, but reading over this again I'm finding it a bit confusing to follow why above cases use handle_error
but self.timings.finish
and the writeln!
below both use diferent custom logic. I think, however, that it should be fine to use handle_error
in both cases?
Or rather put another way I think it'd be good to consistently use handle_error
here if possible.
src/cargo/core/compiler/job_queue.rs
Outdated
drop(shell.warn("build failed, waiting for other jobs to finish...")); | ||
*first_error = Some(anyhow::format_err!("build failed")); | ||
} else { | ||
*first_error = Some(new_err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I keep getting somewhat confused when I think about this personally, and while I realize that this is preserving what's already happening here I think it might be best to restructure this differently. I believe the original intention of this code was, when possible, to return upwards the error we encountered during compilation if only one was encountered. That being said, however, I don't believe we can reliably return upwards an error so I think it would be better to unconditionally, for any errors encountered during the build, to use crate::display_error
and print them here. That way there's much less juggling of trying to preserve some "main" error to return while also ensuring that all other errors are printed.
With a refactoring like that I think it might make sense to change DrainErrors
from an enum to a struct with a keep_going
flag or similar since the only change in behavior would be whether or not more jobs are spawned but otherwise errors are handled consistently between --keep-going
-vs-not
@rfcbot fcp merge This is an unstable flag but personally I'd also be ok landing this insta-stable since this flag has precedent in other build systems. In any case I also wanted to get feedback from other Cargo folks if y'all have it. |
Team member @alexcrichton has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
Another prior art: portage, Gentoo Linux's package manager also has |
Thanks for the PR, but I'm going to be stepping down from the Cargo team so I'm going to un-assign myself from this. The Cargo team will help review this when they get a chance. |
Consistently use crate::display_error on errors during drain As suggested in #10383 (comment) and #10383 (comment).
☔ The latest upstream changes (presumably #10394) made this pull request unmergeable. Please resolve the merge conflicts. |
@rfcbot cancel |
@ehuss proposal cancelled. |
@rfcbot merge @rust-lang/cargo This is adds an unstable flag |
Team member @ehuss has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
@bors retry (Triaging bors problems, don't mind me.) |
@bors r- r=ehuss |
📌 Commit 4e45f58 has been approved by |
@bors r- r=ehuss |
📌 Commit 4e45f58 has been approved by |
☀️ Test successful - checks-actions |
Update cargo 13 commits in 109bfbd055325ef87a6e7f63d67da7e838f8300b..1ef1e0a12723ce9548d7da2b63119de9002bead8 2022-03-17 21:43:09 +0000 to 2022-03-31 00:17:18 +0000 - Support `-Zmultitarget` in cargo config (rust-lang/cargo#10473) - doc: Fix document url for libcurl format (rust-lang/cargo#10515) - Fix wrong info in "Environment variables" docs (rust-lang/cargo#10513) - Use the correct flag in --locked --offline error message (rust-lang/cargo#10512) - Don't treat host/target duplicates as duplicates (rust-lang/cargo#10466) - Unstable --keep-going flag (rust-lang/cargo#10383) - Part 1 of RFC2906 - Packages can inherit fields from their root workspace (rust-lang/cargo#10497) - Remove unused profile support for -Zpanic-abort-tests (rust-lang/cargo#10495) - HTTP registry implementation (rust-lang/cargo#10470) - Add a notice about review capacity. (rust-lang/cargo#10501) - Add tests for ignoring symlinks (rust-lang/cargo#10047) - Update doc string for deps_of/compute_deps. (rust-lang/cargo#10494) - Consistently use crate::display_error on errors during drain (rust-lang/cargo#10394)
Summary
This PR adds an unstable
--keep-going
flag documented as follows:Prior art
Buck and Bazel and Make all have this flag (though Bazel calls it
--keep_going
🤮) with exactly this behavior.Motivation
I need this in order to make https://github.com/dtolnay/trybuild not super slow.
Trybuild wants to run Cargo on a bunch of test cases, each of which is a bin crate. The bad options currently available are:
Give each test case its own target dir and run build on them in parallel. This is bad because all the test cases have the same dependencies in common (whatever
dev-dependencies
are declared by the project). If there are 100 test cases, all the dependencies would end up getting built 100 times, which is 100x slower than necessary despite the parallelism.Reuse a single target dir for all the test cases. Two Cargos can't operate in parallel on the same target directory, so this forces the test cases to be built serially. This is much slower than necessary on a many-core system, and compounds all of the overheads in Cargo because the project structure must be reloaded by each invocation.
The good option I'd like to switch to is:
cargo build --bins --keep-going --message-format=json
to build all the test cases in parallel. Use the filepaths in the JSON messages to ascribe diagnostics to which bin they're from.