Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Clang] Add env var for nvptx-arch/amdgpu-arch timeout #102521

Merged
merged 8 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ def warn_drv_amdgpu_cov6: Warning<
" use at your own risk">;
def err_drv_undetermined_gpu_arch : Error<
"cannot determine %0 architecture: %1; consider passing it via "
"'%2'">;
"'%2' or increasing the tool timeout using the environment variable "
"'CLANG_TOOL_CHAIN_PROGRAM_WAIT' (in secs, <=0 is inifinite)">;
jdenny-ornl marked this conversation as resolved.
Show resolved Hide resolved
def warn_drv_multi_gpu_arch : Warning<
"multiple %0 architectures are detected: %1; only the first one is used for "
"'%2'">, InGroup<MultiGPU>;
Expand Down
12 changes: 11 additions & 1 deletion clang/lib/Driver/ToolChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/VersionTuple.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/TargetParser/AArch64TargetParser.h"
Expand Down Expand Up @@ -105,7 +106,7 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T,

llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
ToolChain::executeToolChainProgram(StringRef Executable,
unsigned SecondsToWait) const {
unsigned DefaultSecondsToWait) const {
llvm::SmallString<64> OutputFile;
llvm::sys::fs::createTemporaryFile("toolchain-program", "txt", OutputFile);
llvm::FileRemover OutputRemover(OutputFile.c_str());
Expand All @@ -116,6 +117,15 @@ ToolChain::executeToolChainProgram(StringRef Executable,
};

std::string ErrorMessage;
int SecondsToWait = DefaultSecondsToWait;
if (std::optional<std::string> Str =
llvm::sys::Process::GetEnv("CLANG_TOOL_CHAIN_PROGRAM_WAIT")) {
int Val = std::atoi(Str->c_str());
if (Val > 0)
SecondsToWait = Val;
else
SecondsToWait = 0; // infinite
jdenny-ornl marked this conversation as resolved.
Show resolved Hide resolved
}
if (llvm::sys::ExecuteAndWait(Executable, {}, {}, Redirects, SecondsToWait,
/*MemoryLimit=*/0, &ErrorMessage))
return llvm::createStringError(std::error_code(),
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Driver/ToolChains/AMDGPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,8 @@ AMDGPUToolChain::getSystemGPUArchs(const ArgList &Args) const {
else
Program = GetProgramPath("amdgpu-arch");

auto StdoutOrErr = executeToolChainProgram(Program, /*SecondsToWait=*/10);
auto StdoutOrErr = executeToolChainProgram(Program,
/*DefaultSecondsToWait=*/10);
if (!StdoutOrErr)
return StdoutOrErr.takeError();

Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Driver/ToolChains/Cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,8 @@ NVPTXToolChain::getSystemGPUArchs(const ArgList &Args) const {
else
Program = GetProgramPath("nvptx-arch");

auto StdoutOrErr = executeToolChainProgram(Program, /*SecondsToWait=*/10);
auto StdoutOrErr = executeToolChainProgram(Program,
/*DefaultSecondsToWait=*/10);
if (!StdoutOrErr)
return StdoutOrErr.takeError();

Expand Down
1 change: 1 addition & 0 deletions llvm/utils/lit/lit/TestingConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def fromdefaults(litConfig):
"SYSTEMROOT",
"TERM",
"CLANG",
"CLANG_TOOL_CHAIN_PROGRAM_WAIT",
"LLDB",
"LD_PRELOAD",
"LLVM_SYMBOLIZER_PATH",
Expand Down
Loading