summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2023-03-24 12:17:25 +0200
committerTom Stellard <tstellar@redhat.com>2023-04-04 10:55:36 -0700
commit35551022bf04a468ca73adeca7de8a06e89c7cc6 (patch)
treebc0c44c3554776d53bed031501fcf53610fe6599
parent1fa1bc9c2dff6ea28803e77790ffeddc7d22ec42 (diff)
downloadllvm-35551022bf04a468ca73adeca7de8a06e89c7cc6.tar.gz
[llvm-rc] Respect the executable specified in the --preprocessor command
The arguments passed in this option were passed onto the child process, but we still blindly used the clang binary that we had found to sys::ExecuteAndWait as the intended executable to run. If the user hasn't specified any custom --preprocessor command, Args[0] is equal to the variable Clang. This doesn't affect any tests, since the tests only print the arguments it would try to execute (but not the first parameter to sys::ExecuteAndWait), but there's no testes for executing it (and validating that it did execute the right thing). Differential Revision: https://reviews.llvm.org/D146793 (cherry picked from commit d2fa6b694c2052cef1ddd507f6569bc84e3bbe35)
-rw-r--r--llvm/tools/llvm-rc/llvm-rc.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp
index 8e525bd41201..b6b44d4f5899 100644
--- a/llvm/tools/llvm-rc/llvm-rc.cpp
+++ b/llvm/tools/llvm-rc/llvm-rc.cpp
@@ -226,7 +226,7 @@ struct RcOptions {
bool preprocess(StringRef Src, StringRef Dst, const RcOptions &Opts,
const char *Argv0) {
std::string Clang;
- if (Opts.PrintCmdAndExit) {
+ if (Opts.PrintCmdAndExit || !Opts.PreprocessCmd.empty()) {
Clang = "clang";
} else {
ErrorOr<std::string> ClangOrErr = findClang(Argv0, Opts.Triple);
@@ -266,7 +266,7 @@ bool preprocess(StringRef Src, StringRef Dst, const RcOptions &Opts,
}
// The llvm Support classes don't handle reading from stdout of a child
// process; otherwise we could avoid using a temp file.
- int Res = sys::ExecuteAndWait(Clang, Args);
+ int Res = sys::ExecuteAndWait(Args[0], Args);
if (Res) {
fatalError("llvm-rc: Preprocessing failed.");
}