Skip to content

Commit

Permalink
Support: Do not check if a file exists before executing (llvm#128821)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
arsenm authored Feb 26, 2025
1 parent fe13cb9 commit 8dd6095
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
7 changes: 0 additions & 7 deletions llvm/lib/Support/Unix/Program.inc
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,6 @@ static bool Execute(ProcessInfo &PI, StringRef Program,
ArrayRef<std::optional<StringRef>> Redirects,
unsigned MemoryLimit, std::string *ErrMsg,
BitVector *AffinityMask, bool DetachProcess) {
if (!llvm::sys::fs::exists(Program)) {
if (ErrMsg)
*ErrMsg = std::string("Executable \"") + Program.str() +
std::string("\" doesn't exist!");
return false;
}

assert(!AffinityMask && "Starting a process with an affinity mask is "
"currently not supported on Unix!");

Expand Down
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-rc/windres-preproc.test
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

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

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

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

Expand Down

0 comments on commit 8dd6095

Please sign in to comment.