Skip to content

Commit 624d322

Browse files
committed
[Clang] Fix 'clang-nvlink-wrapper' not working w/o CUDA
Summary: This would try to find `nvlink` and then fail even in `dry-run` mode. We now just let it continue and pretend like we found it. Also add it to the depends.
1 parent 41f6599 commit 624d322

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

clang/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ list(APPEND CLANG_TEST_DEPS
7878
clang-installapi
7979
clang-scan-deps
8080
clang-linker-wrapper
81+
clang-nvlink-wrapper
8182
clang-offload-bundler
8283
clang-offload-packager
8384
diagtool

clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,10 @@ Expected<StringRef> createTempFile(const ArgList &Args, const Twine &Prefix,
190190
return TempFiles.back();
191191
}
192192

193-
Expected<std::string> findProgram(StringRef Name, ArrayRef<StringRef> Paths) {
193+
Expected<std::string> findProgram(const ArgList &Args, StringRef Name,
194+
ArrayRef<StringRef> Paths) {
195+
if (Args.hasArg(OPT_dry_run))
196+
return Name.str();
194197
ErrorOr<std::string> Path = sys::findProgramByName(Name, Paths);
195198
if (!Path)
196199
Path = sys::findProgramByName(Name);
@@ -294,10 +297,9 @@ struct Symbol {
294297

295298
Expected<StringRef> runPTXAs(StringRef File, const ArgList &Args) {
296299
std::string CudaPath = Args.getLastArgValue(OPT_cuda_path_EQ).str();
300+
std::string GivenPath = Args.getLastArgValue(OPT_ptxas_path_EQ).str();
297301
Expected<std::string> PTXAsPath =
298-
Args.getLastArgValue(OPT_ptxas_path_EQ).str();
299-
if (PTXAsPath->empty())
300-
PTXAsPath = findProgram("ptxas", {CudaPath + "/bin"});
302+
findProgram(Args, "ptxas", {CudaPath + "/bin", GivenPath});
301303
if (!PTXAsPath)
302304
return PTXAsPath.takeError();
303305

@@ -686,7 +688,8 @@ Error runNVLink(ArrayRef<StringRef> Files, const ArgList &Args) {
686688
return Error::success();
687689

688690
std::string CudaPath = Args.getLastArgValue(OPT_cuda_path_EQ).str();
689-
Expected<std::string> NVLinkPath = findProgram("nvlink", {CudaPath + "/bin"});
691+
Expected<std::string> NVLinkPath =
692+
findProgram(Args, "nvlink", {CudaPath + "/bin"});
690693
if (!NVLinkPath)
691694
return NVLinkPath.takeError();
692695

0 commit comments

Comments
 (0)