Skip to content

Commit d2fa6b6

Browse files
committed
[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
1 parent 7cf203e commit d2fa6b6

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
@@ -227,7 +227,7 @@ struct RcOptions {
227227
bool preprocess(StringRef Src, StringRef Dst, const RcOptions &Opts,
228228
const char *Argv0) {
229229
std::string Clang;
230-
if (Opts.PrintCmdAndExit) {
230+
if (Opts.PrintCmdAndExit || !Opts.PreprocessCmd.empty()) {
231231
Clang = "clang";
232232
} else {
233233
ErrorOr<std::string> ClangOrErr = findClang(Argv0, Opts.Triple);
@@ -267,7 +267,7 @@ bool preprocess(StringRef Src, StringRef Dst, const RcOptions &Opts,
267267
}
268268
// The llvm Support classes don't handle reading from stdout of a child
269269
// process; otherwise we could avoid using a temp file.
270-
int Res = sys::ExecuteAndWait(Clang, Args);
270+
int Res = sys::ExecuteAndWait(Args[0], Args);
271271
if (Res) {
272272
fatalError("llvm-rc: Preprocessing failed.");
273273
}

0 commit comments

Comments
 (0)