Skip to content

Commit 1a5c4e5

Browse files
jhuber6tru
authored andcommitted
[Clang] Correctly forward --cuda-path to the nvlink wrapper (#100170)
Summary: This was not forwarded properly as it would try to pass it to `nvlink`. Fixes #100168 (cherry picked from commit 7e1fcf5)
1 parent 4d4a410 commit 1a5c4e5

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

clang/lib/Driver/ToolChains/Cuda.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,10 @@ void NVPTX::Linker::ConstructJob(Compilation &C, const JobAction &JA,
609609
CmdArgs.push_back(Args.MakeArgString(
610610
"--pxtas-path=" + Args.getLastArgValue(options::OPT_ptxas_path_EQ)));
611611

612+
if (Args.hasArg(options::OPT_cuda_path_EQ))
613+
CmdArgs.push_back(Args.MakeArgString(
614+
"--cuda-path=" + Args.getLastArgValue(options::OPT_cuda_path_EQ)));
615+
612616
// Add paths specified in LIBRARY_PATH environment variable as -L options.
613617
addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
614618

clang/test/Driver/linker-wrapper-passes.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// REQUIRES: llvm-plugins, llvm-examples
44
// REQUIRES: x86-registered-target
55
// REQUIRES: amdgpu-registered-target
6-
76
// Setup.
87
// RUN: mkdir -p %t
98
// RUN: %clang -cc1 -emit-llvm-bc -o %t/host-x86_64-unknown-linux-gnu.bc \

clang/test/Driver/nvlink-wrapper.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,10 @@ int baz() { return y + x; }
6363
// RUN: -arch sm_52 -o a.out 2>&1 | FileCheck %s --check-prefix=LTO
6464
// LTO: ptxas{{.*}} -m64 -c [[PTX:.+]].s -O3 -arch sm_52 -o [[CUBIN:.+]].cubin
6565
// LTO: nvlink{{.*}} -arch sm_52 -o a.out [[CUBIN]].cubin {{.*}}-u-{{.*}}.cubin {{.*}}-y-{{.*}}.cubin
66+
67+
//
68+
// Check that we don't forward some arguments.
69+
//
70+
// RUN: clang-nvlink-wrapper --dry-run %t.o %t-u.o %t-y.a \
71+
// RUN: -arch sm_52 --cuda-path/opt/cuda -o a.out 2>&1 | FileCheck %s --check-prefix=PATH
72+
// PATH-NOT: --cuda-path=/opt/cuda

clang/tools/clang-nvlink-wrapper/NVLinkOpts.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ def verbose : Flag<["-"], "v">, HelpText<"Print verbose information">;
1212
def version : Flag<["--"], "version">,
1313
HelpText<"Display the version number and exit">;
1414

15-
def cuda_path_EQ : Joined<["--"], "cuda-path=">,
15+
def cuda_path_EQ : Joined<["--"], "cuda-path=">, Flags<[WrapperOnlyOption]>,
1616
MetaVarName<"<dir>">, HelpText<"Set the system CUDA path">;
17-
def ptxas_path_EQ : Joined<["--"], "ptxas-path=">,
17+
def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Flags<[WrapperOnlyOption]>,
1818
MetaVarName<"<dir>">, HelpText<"Set the 'ptxas' path">;
1919

2020
def o : JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,

0 commit comments

Comments
 (0)