[PATCH] D146793: [llvm-rc] Respect the executable specified in the --preprocessor command

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 24 03:25:05 PDT 2023


mstorsjo created this revision.
mstorsjo added reviewers: aganea, alvinhochun, thieta.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: LLVM.

The arguments passed in this option were passed onto the child
process, but we still blindly 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).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146793

Files:
  llvm/tools/llvm-rc/llvm-rc.cpp


Index: llvm/tools/llvm-rc/llvm-rc.cpp
===================================================================
--- llvm/tools/llvm-rc/llvm-rc.cpp
+++ llvm/tools/llvm-rc/llvm-rc.cpp
@@ -227,7 +227,7 @@
 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 @@
   }
   // 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.");
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146793.508019.patch
Type: text/x-patch
Size: 848 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230324/29dc1b86/attachment.bin>


More information about the llvm-commits mailing list