Skip to content

Commit 3555102

Browse files
mstorsjotstellar
authored andcommitted
[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 d2fa6b6)
1 parent 1fa1bc9 commit 3555102

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/tools/llvm-rc/llvm-rc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ struct RcOptions {
226226
bool preprocess(StringRef Src, StringRef Dst, const RcOptions &Opts,
227227
const char *Argv0) {
228228
std::string Clang;
229-
if (Opts.PrintCmdAndExit) {
229+
if (Opts.PrintCmdAndExit || !Opts.PreprocessCmd.empty()) {
230230
Clang = "clang";
231231
} else {
232232
ErrorOr<std::string> ClangOrErr = findClang(Argv0, Opts.Triple);
@@ -266,7 +266,7 @@ bool preprocess(StringRef Src, StringRef Dst, const RcOptions &Opts,
266266
}
267267
// The llvm Support classes don't handle reading from stdout of a child
268268
// process; otherwise we could avoid using a temp file.
269-
int Res = sys::ExecuteAndWait(Clang, Args);
269+
int Res = sys::ExecuteAndWait(Args[0], Args);
270270
if (Res) {
271271
fatalError("llvm-rc: Preprocessing failed.");
272272
}

0 commit comments

Comments
 (0)