Skip to content

Commit adbe247

Browse files
committed
Reapply "[Clang] Correctly forward --cuda-path to the nvlink wrapper (#100170)"
This reverts commit 7d388ae.
1 parent 7d388ae commit adbe247

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
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: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
// Check various clang-linker-wrapper pass options after -offload-opt.
22

3-
// REQUIRES: llvm-plugins, llvm-examples
4-
// REQUIRES: x86-registered-target
5-
// REQUIRES: amdgpu-registered-target
6-
73
// Setup.
84
// RUN: mkdir -p %t
95
// RUN: %clang -cc1 -emit-llvm-bc -o %t/host-x86_64-unknown-linux-gnu.bc \
@@ -13,7 +9,7 @@
139
// RUN: opt %t/openmp-amdgcn-amd-amdhsa.bc -o %t/openmp-amdgcn-amd-amdhsa.bc \
1410
// RUN: -passes=forceattrs -force-remove-attribute=f:noinline
1511
// RUN: clang-offload-packager -o %t/openmp-x86_64-unknown-linux-gnu.out \
16-
// RUN: --image=file=%t/openmp-amdgcn-amd-amdhsa.bc,triple=amdgcn-amd-amdhsa
12+
// RUN: --image=file=%t/openmp-amdgcn-amd-amdhsa.bc,arch=gfx90a,triple=amdgcn-amd-amdhsa
1713
// RUN: %clang -cc1 -S -o %t/host-x86_64-unknown-linux-gnu.s \
1814
// RUN: -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
1915
// RUN: -fembed-offload-object=%t/openmp-x86_64-unknown-linux-gnu.out \

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)