-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Do not lock the artifact-dir for check builds #16230
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -127,6 +127,7 @@ impl Layout { | |||||||||||||||
| ws: &Workspace<'_>, | ||||||||||||||||
| target: Option<CompileTarget>, | ||||||||||||||||
| dest: &str, | ||||||||||||||||
| must_take_artifact_dir_lock: bool, | ||||||||||||||||
| ) -> CargoResult<Layout> { | ||||||||||||||||
| let is_new_layout = ws.gctx().cli_unstable().build_dir_new_layout; | ||||||||||||||||
| let mut root = ws.target_dir(); | ||||||||||||||||
|
|
@@ -153,7 +154,9 @@ impl Layout { | |||||||||||||||
| // For now we don't do any more finer-grained locking on the artifact | ||||||||||||||||
| // directory, so just lock the entire thing for the duration of this | ||||||||||||||||
| // compile. | ||||||||||||||||
| let artifact_dir_lock = if is_on_nfs_mount(root.as_path_unlocked()) { | ||||||||||||||||
| let artifact_dir_lock = if !must_take_artifact_dir_lock | ||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of conditionally grabbing the lock, can we put the entire artifact layout in an
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked into this and it got pretty hairy. Switching from For example, in cargo/src/cargo/core/compiler/build_runner/mod.rs Lines 395 to 397 in 8c4a25c
and we use this in cargo/src/cargo/core/compiler/compilation.rs Lines 308 to 311 in 8c4a25c
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't that make the case even stronger? We are trying to read from a location we do not write to and do not have locked. |
||||||||||||||||
| || is_on_nfs_mount(root.as_path_unlocked()) | ||||||||||||||||
| { | ||||||||||||||||
| None | ||||||||||||||||
| } else { | ||||||||||||||||
| Some(dest.open_rw_exclusive_create(".cargo-lock", ws.gctx(), "artifact directory")?) | ||||||||||||||||
|
|
||||||||||||||||
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.
Instead of intent, can we check if artifacts are produced? Do we know that?
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 checked and I think it may be possible to use some of the logic from
CompilationFilesoutput but we would likely need to duplicate it as we need to constructLayoutbeforeCompilationFiles.See https://github.com/rust-lang/cargo/blob/master/src/cargo/core/compiler/build_runner/compilation_files.rs#L405
Let me know if there is a better way to get this data.
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.
Hmm, that can get messy. We could create an
enumfor the base path and calculate the full path later but unsure how well that will work out.However, this does highlight a need for either this or conditionally grabbing the lock (#16230 (comment))
cargo/src/cargo/core/compiler/build_runner/compilation_files.rs
Lines 529 to 540 in 8c4a25c
We would have been writing out SBOMs without holding the lock. If we don't feel SBOMs are relevant for
cargo checkthen making the layout optional (to catch problems like this) is sufficient. If not, then we need to somehow be aware of this for locking and then that starts to look like needing to resolve this item.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.
Note: if we change SBOMs, lets do that in its own PR and make a note against rust-lang/rfcs#3553
CC @arlosi