Index: lld/Common/Filesystem.cpp =================================================================== --- lld/Common/Filesystem.cpp +++ lld/Common/Filesystem.cpp @@ -40,6 +40,15 @@ // This function spawns a background thread to remove the file. // The calling thread returns almost immediately. void lld::unlinkAsync(StringRef path) { + +#if !defined(_WIN32) + if (parallel::strategy.ThreadsRequested == 1) + return; +#endif + + if (!sys::fs::exists(path) || !sys::fs::is_regular_file(path)) + return; + // Removing a file is async on windows. #if defined(_WIN32) // On Windows co-operative programs can be expected to open LLD's @@ -71,10 +80,6 @@ } sys::fs::remove(path); #else - if (parallel::strategy.ThreadsRequested == 1 || !sys::fs::exists(path) || - !sys::fs::is_regular_file(path)) - return; - // We cannot just remove path from a different thread because we are now going // to create path as a new file. // Instead we open the file and unlink it on this thread. The unlink is fast