[llvm] d2fa6b6 - [llvm-rc] Respect the executable specified in the --preprocessor command

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 28 01:03:44 PDT 2023


Author: Martin Storsjö
Date: 2023-03-28T11:02:41+03:00
New Revision: d2fa6b694c2052cef1ddd507f6569bc84e3bbe35

URL: https://github.com/llvm/llvm-project/commit/d2fa6b694c2052cef1ddd507f6569bc84e3bbe35
DIFF: https://github.com/llvm/llvm-project/commit/d2fa6b694c2052cef1ddd507f6569bc84e3bbe35.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

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 fbf2aa78c5d35..036178b25ed96 100644
--- a/llvm/tools/llvm-rc/llvm-rc.cpp
+++ b/llvm/tools/llvm-rc/llvm-rc.cpp
@@ -227,7 +227,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);
@@ -267,7 +267,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-commits mailing list