[lld] r291496 - Support non-regular output files.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 9 15:07:05 PST 2017
Author: ruiu
Date: Mon Jan 9 17:07:05 2017
New Revision: 291496
URL: http://llvm.org/viewvc/llvm-project?rev=291496&view=rev
Log:
Support non-regular output files.
This patch enables something like "-o /dev/null".
Previouly, it failed because such files cannot be renamed.
Differential Revision: https://reviews.llvm.org/D28010
Modified:
lld/trunk/ELF/Writer.cpp
lld/trunk/test/ELF/basic.s
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=291496&r1=291495&r2=291496&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Mon Jan 9 17:07:05 2017
@@ -1635,10 +1635,12 @@ static void unlinkAsync(StringRef Path)
// Path as a new file. If we do that in a different thread, the new
// thread can remove the new file.
SmallString<128> TempPath;
- if (auto EC = sys::fs::createUniqueFile(Path + "tmp%%%%%%%%", TempPath))
- fatal(EC, "createUniqueFile failed");
- if (auto EC = sys::fs::rename(Path, TempPath))
- fatal(EC, "rename failed");
+ if (sys::fs::createUniqueFile(Path + "tmp%%%%%%%%", TempPath))
+ return;
+ if (sys::fs::rename(Path, TempPath)) {
+ sys::fs::remove(TempPath);
+ return;
+ }
// Remove TempPath in background.
std::thread([=] { ::remove(TempPath.str().str().c_str()); }).detach();
Modified: lld/trunk/test/ELF/basic.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/basic.s?rev=291496&r1=291495&r2=291496&view=diff
==============================================================================
--- lld/trunk/test/ELF/basic.s (original)
+++ lld/trunk/test/ELF/basic.s Mon Jan 9 17:07:05 2017
@@ -4,6 +4,7 @@
# RUN: ld.lld %t -o %t2
# RUN: llvm-readobj -file-headers -sections -program-headers -symbols %t2 \
# RUN: | FileCheck %s
+# RUN: ld.lld %t -o /dev/null
# exits with return code 42 on linux
.globl _start
More information about the llvm-commits
mailing list