Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/cargo/core/compiler/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@

use crate::core::Workspace;
use crate::core::compiler::CompileTarget;
use crate::util::flock::is_on_nfs_mount;
use crate::util::{CargoResult, FileLock};
use cargo_util::paths;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -152,17 +153,21 @@ 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 =
dest.open_rw_exclusive_create(".cargo-lock", ws.gctx(), "build directory")?;
let artifact_dir_lock = if is_on_nfs_mount(root.as_path_unlocked()) {
None
} else {
Some(dest.open_rw_exclusive_create(".cargo-lock", ws.gctx(), "artifact directory")?)
};

let build_dir_lock = if root != build_root {
let build_dir_lock = if root == build_root || is_on_nfs_mount(build_root.as_path_unlocked())
{
None
} else {
Some(build_dest.open_rw_exclusive_create(
".cargo-lock",
ws.gctx(),
"build directory",
)?)
} else {
None
};
let root = root.into_path_unlocked();
let build_root = build_root.into_path_unlocked();
Expand Down Expand Up @@ -222,7 +227,7 @@ pub struct ArtifactDirLayout {
timings: PathBuf,
/// The lockfile for a build (`.cargo-lock`). Will be unlocked when this
/// struct is `drop`ped.
_lock: FileLock,
_lock: Option<FileLock>,
}

impl ArtifactDirLayout {
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/util/flock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ fn acquire(
}

#[cfg(all(target_os = "linux", not(target_env = "musl")))]
fn is_on_nfs_mount(path: &Path) -> bool {
pub fn is_on_nfs_mount(path: &Path) -> bool {
use std::ffi::CString;
use std::mem;
use std::os::unix::prelude::*;
Expand All @@ -445,7 +445,7 @@ fn is_on_nfs_mount(path: &Path) -> bool {
}

#[cfg(any(not(target_os = "linux"), target_env = "musl"))]
fn is_on_nfs_mount(_path: &Path) -> bool {
pub fn is_on_nfs_mount(_path: &Path) -> bool {
false
}

Expand Down
2 changes: 1 addition & 1 deletion src/cargo/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ mod dependency_queue;
pub mod diagnostic_server;
pub mod edit_distance;
pub mod errors;
mod flock;
pub mod flock;
pub mod frontmatter;
pub mod graph;
mod hasher;
Expand Down