[llvm-branch-commits] [llvm] 3555102 - [llvm-rc] Respect the executable specified in the --preprocessor command
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Apr 4 10:56:02 PDT 2023
Author: Martin Storsjö
Date: 2023-04-04T10:55:36-07:00
New Revision: 35551022bf04a468ca73adeca7de8a06e89c7cc6
URL: https://github.com/llvm/llvm-project/commit/35551022bf04a468ca73adeca7de8a06e89c7cc6
DIFF: https://github.com/llvm/llvm-project/commit/35551022bf04a468ca73adeca7de8a06e89c7cc6.diff
LOG: [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)
Added:
Modified:
llvm/tools/llvm-rc/llvm-rc.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp
index 8e525bd412015..b6b44d4f58992 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.");
}
More information about the llvm-branch-commits
mailing list