Skip to content

Commit ba18be4

Browse files
committed
[Clang] Correctly forward --cuda-path to the nvlink wrapper
Summary: This was not forwarded properly as it would try to pass it to `nvlink`. Fixes #100168
1 parent 43ca631 commit ba18be4

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
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/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)