[lld] r301423 - Make LLD work even if the current directory is not writable.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 26 09:15:07 PDT 2017


Author: ruiu
Date: Wed Apr 26 11:15:07 2017
New Revision: 301423

URL: http://llvm.org/viewvc/llvm-project?rev=301423&view=rev
Log:
Make LLD work even if the current directory is not writable.

Added:
    lld/trunk/test/ELF/driver-access.test
Modified:
    lld/trunk/ELF/Filesystem.cpp

Modified: lld/trunk/ELF/Filesystem.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Filesystem.cpp?rev=301423&r1=301422&r2=301423&view=diff
==============================================================================
--- lld/trunk/ELF/Filesystem.cpp (original)
+++ lld/trunk/ELF/Filesystem.cpp Wed Apr 26 11:15:07 2017
@@ -70,5 +70,7 @@ void elf::unlinkAsync(StringRef Path) {
 // is called. We use that class without calling commit() to predict
 // if the given file is writable.
 std::error_code elf::tryCreateFile(StringRef Path) {
+  if (Path.empty())
+    return std::error_code();
   return FileOutputBuffer::create(Path, 1).getError();
 }

Added: lld/trunk/test/ELF/driver-access.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/driver-access.test?rev=301423&view=auto
==============================================================================
--- lld/trunk/test/ELF/driver-access.test (added)
+++ lld/trunk/test/ELF/driver-access.test Wed Apr 26 11:15:07 2017
@@ -0,0 +1,14 @@
+# REQUIRES: x86, shell
+# Make sure that LLD works even if the current directory is not writable.
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld %t.o -o %t.exe
+
+# RUN: mkdir -p %t.dir
+# RUN: chmod 100 %t.dir
+# RUN: cd %t.dir
+# RUN: ld.lld %t.o -o %t.exe
+
+.globl _start
+_start:
+  nop




More information about the llvm-commits mailing list