Skip to content

Commit 8dd6095

Browse files
authored
Support: Do not check if a file exists before executing (#128821)
Let the actual syscall error if the file doesn't exist. This produces a more standard "no such file or directory" phrasing of the error message, and avoids an extra step. The same antipattern appears in the windows code, we should probably fix that one too.
1 parent fe13cb9 commit 8dd6095

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

llvm/lib/Support/Unix/Program.inc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,6 @@ static bool Execute(ProcessInfo &PI, StringRef Program,
168168
ArrayRef<std::optional<StringRef>> Redirects,
169169
unsigned MemoryLimit, std::string *ErrMsg,
170170
BitVector *AffinityMask, bool DetachProcess) {
171-
if (!llvm::sys::fs::exists(Program)) {
172-
if (ErrMsg)
173-
*ErrMsg = std::string("Executable \"") + Program.str() +
174-
std::string("\" doesn't exist!");
175-
return false;
176-
}
177-
178171
assert(!AffinityMask && "Starting a process with an affinity mask is "
179172
"currently not supported on Unix!");
180173

llvm/test/tools/llvm-rc/windres-preproc.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
;; Test error messages when unable to execute the preprocessor.
2121

22-
; RUN: not llvm-windres --preprocessor intentionally-missing-executable %p/Inputs/empty.rc %t.res 2>&1 | FileCheck %s --check-prefix=CHECK4
23-
; CHECK4: llvm-rc: Preprocessing failed: Executable "intentionally-missing-executable" doesn't exist!
22+
; RUN: not llvm-windres --preprocessor intentionally-missing-executable %p/Inputs/empty.rc %t.res 2>&1 | FileCheck -DMSG=%errc_ENOENT %s --check-prefix=CHECK4
23+
; CHECK4: llvm-rc: Preprocessing failed: posix_spawn failed: [[MSG]]
2424

2525
;; Test --preprocessor with an argument with spaces.
2626

0 commit comments

Comments
 (0)