[llvm] Support: Do not check if a file exists before executing (PR #128821)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 25 21:29:49 PST 2025
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/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.
>From a75612fc511cf88c0f7d9e96b5c54b375a380dad Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Wed, 26 Feb 2025 12:06:28 +0700
Subject: [PATCH] Support: Do not check if a file exists before executing
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.
---
llvm/lib/Support/Unix/Program.inc | 7 -------
llvm/test/tools/llvm-rc/windres-preproc.test | 2 +-
2 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
index 0708df1eed0a3..6d68369ad191c 100644
--- a/llvm/lib/Support/Unix/Program.inc
+++ b/llvm/lib/Support/Unix/Program.inc
@@ -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!");
diff --git a/llvm/test/tools/llvm-rc/windres-preproc.test b/llvm/test/tools/llvm-rc/windres-preproc.test
index 52427862e760b..ad558c9a0c927 100644
--- a/llvm/test/tools/llvm-rc/windres-preproc.test
+++ b/llvm/test/tools/llvm-rc/windres-preproc.test
@@ -20,7 +20,7 @@
;; 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!
+; CHECK4: llvm-rc: Preprocessing failed: posix_spawn failed: No such file or directory
;; Test --preprocessor with an argument with spaces.
More information about the llvm-commits
mailing list