mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
Fix tmp files being left on Windows builds.
Clang writes object files by first writing to a .tmp file and then renaming to the final .obj name. On Windows, if a compile is killed partway through the .tmp files don't get deleted. Currently it seems like RemoveFileOnSignal takes care of deleting the tmp files on Linux, but on Windows we need to call setDeleteDisposition on tmp files so that they are deleted when closed. This patch switches to using TempFile to create the .tmp files we write when creating object files, since it uses setDeleteDisposition on Windows. This change applies to both Linux and Windows for consistency. Differential Revision: https://reviews.llvm.org/D102876
This commit is contained in:
parent
82e56dec58
commit
c579427605
@ -1229,7 +1229,7 @@ Error TempFile::keep(const Twine &Name) {
|
||||
auto H = reinterpret_cast<HANDLE>(_get_osfhandle(FD));
|
||||
std::error_code RenameEC = setDeleteDisposition(H, false);
|
||||
if (!RenameEC) {
|
||||
RenameEC = rename_fd(FD, Name);
|
||||
RenameEC = rename_handle(H, Name);
|
||||
// If rename failed because it's cross-device, copy instead
|
||||
if (RenameEC ==
|
||||
std::error_code(ERROR_NOT_SAME_DEVICE, std::system_category())) {
|
||||
|
@ -560,11 +560,6 @@ static std::error_code rename_handle(HANDLE FromHandle, const Twine &To) {
|
||||
return errc::permission_denied;
|
||||
}
|
||||
|
||||
static std::error_code rename_fd(int FromFD, const Twine &To) {
|
||||
HANDLE FromHandle = reinterpret_cast<HANDLE>(_get_osfhandle(FromFD));
|
||||
return rename_handle(FromHandle, To);
|
||||
}
|
||||
|
||||
std::error_code rename(const Twine &From, const Twine &To) {
|
||||
// Convert to utf-16.
|
||||
SmallVector<wchar_t, 128> WideFrom;
|
||||
|
Loading…
Reference in New Issue
Block a user