Skip to content

Commit 5545f76

Browse files
authored
Pass the executable name as arg[0] when calling ExecuteAndWait() (#114067)
PR #111976 was enabling the tests updated in the PR to run on all systems. We found a few didn't run on z/OS. I tracked the problem down to: 1. the ExecuteToolChainProgram() function wasn't passing the executable name as the first arg. That was causing exec on z/OS to fail. 2. the temp file needs to be a text file so codepage conversion happens.
1 parent 705f3eb commit 5545f76

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

clang/lib/Driver/ToolChain.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T,
109109
llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
110110
ToolChain::executeToolChainProgram(StringRef Executable) const {
111111
llvm::SmallString<64> OutputFile;
112-
llvm::sys::fs::createTemporaryFile("toolchain-program", "txt", OutputFile);
112+
llvm::sys::fs::createTemporaryFile("toolchain-program", "txt", OutputFile,
113+
llvm::sys::fs::OF_Text);
113114
llvm::FileRemover OutputRemover(OutputFile.c_str());
114115
std::optional<llvm::StringRef> Redirects[] = {
115116
{""},
@@ -128,7 +129,8 @@ ToolChain::executeToolChainProgram(StringRef Executable) const {
128129
*Str + "'");
129130
SecondsToWait = std::max(SecondsToWait, 0); // infinite
130131
}
131-
if (llvm::sys::ExecuteAndWait(Executable, {}, {}, Redirects, SecondsToWait,
132+
if (llvm::sys::ExecuteAndWait(Executable, {Executable}, {}, Redirects,
133+
SecondsToWait,
132134
/*MemoryLimit=*/0, &ErrorMessage))
133135
return llvm::createStringError(std::error_code(),
134136
Executable + ": " + ErrorMessage);

0 commit comments

Comments
 (0)