File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
crates/cargo-test-support/src Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -1741,6 +1741,10 @@ fn _process(t: &OsStr) -> cargo::util::ProcessBuilder {
1741
1741
. env_remove ( "GIT_COMMITTER_NAME" )
1742
1742
. env_remove ( "GIT_COMMITTER_EMAIL" )
1743
1743
. env_remove ( "MSYSTEM" ) ; // assume cmd.exe everywhere on windows
1744
+ if cfg ! ( target_os = "macos" ) {
1745
+ // Work-around a bug in macOS 10.15, see `link_or_copy` for details.
1746
+ p. env ( "__CARGO_COPY_DONT_LINK_DO_NOT_USE_THIS" , "1" ) ;
1747
+ }
1744
1748
p
1745
1749
}
1746
1750
Original file line number Diff line number Diff line change @@ -379,7 +379,20 @@ fn _link_or_copy(src: &Path, dst: &Path) -> CargoResult<()> {
379
379
} ;
380
380
symlink ( src, dst)
381
381
} else {
382
- fs:: hard_link ( src, dst)
382
+ if env:: var_os ( "__CARGO_COPY_DONT_LINK_DO_NOT_USE_THIS" ) . is_some ( ) {
383
+ // This is a work-around for a bug in macOS 10.15. When running on
384
+ // APFS, there seems to be a strange race condition with
385
+ // Gatekeeper where it will forcefully kill a process launched via
386
+ // `cargo run` with SIGKILL. Copying seems to avoid the problem.
387
+ // This shouldn't affect anyone except Cargo's test suite because
388
+ // it is very rare, and only seems to happen under heavy load and
389
+ // rapidly creating lots of executables and running them.
390
+ // See https://github.com/rust-lang/cargo/issues/7821 for the
391
+ // gory details.
392
+ fs:: copy ( src, dst) . map ( |_| ( ) )
393
+ } else {
394
+ fs:: hard_link ( src, dst)
395
+ }
383
396
} ;
384
397
link_result
385
398
. or_else ( |err| {
You can’t perform that action at this time.
0 commit comments