Skip to content

Commit 44def17

Browse files
[Flang][AMDGPU] Add rocm-path flag
ROCm installation path is used for finding and automatically linking required bitcode libraries.
1 parent 299b636 commit 44def17

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,8 @@ def hip_link : Flag<["--"], "hip-link">, Group<opencl_Group>,
13411341
HelpText<"Link clang-offload-bundler bundles for HIP">;
13421342
def no_hip_rt: Flag<["-"], "no-hip-rt">, Group<hip_Group>,
13431343
HelpText<"Do not link against HIP runtime libraries">;
1344-
def rocm_path_EQ : Joined<["--"], "rocm-path=">, Group<hip_Group>,
1344+
def rocm_path_EQ : Joined<["--"], "rocm-path=">,
1345+
Visibility<[FlangOption]>, Group<hip_Group>,
13451346
HelpText<"ROCm installation path, used for finding and automatically linking required bitcode libraries.">;
13461347
def hip_path_EQ : Joined<["--"], "hip-path=">, Group<hip_Group>,
13471348
HelpText<"HIP runtime installation path, used for finding HIP version and adding HIP include path.">;

clang/lib/Driver/ToolChains/Flang.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,10 @@ void Flang::AddAMDGPUTargetArgs(const ArgList &Args,
342342
StringRef Val = A->getValue();
343343
CmdArgs.push_back(Args.MakeArgString("-mcode-object-version=" + Val));
344344
}
345+
346+
// Check ROCm path if specified
347+
const ToolChain &TC = getToolChain();
348+
TC.getDeviceLibs(Args);
345349
}
346350

347351
void Flang::addTargetOptions(const ArgList &Args,

flang/test/Driver/driver-help-hidden.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
! CHECK-NEXT: -print-target-triple Print the normalized target triple
145145
! CHECK-NEXT: -pthread Support POSIX threads in generated code
146146
! CHECK-NEXT: -P Disable linemarker output in -E mode
147+
! CHECK-NEXT: --rocm-path=<value> ROCm installation path, used for finding and automatically linking required bitcode libraries.
147148
! CHECK-NEXT: -Rpass-analysis=<value> Report transformation analysis from optimization passes whose name matches the given POSIX regular expression
148149
! CHECK-NEXT: -Rpass-missed=<value> Report missed transformations by optimization passes whose name matches the given POSIX regular expression
149150
! CHECK-NEXT: -Rpass=<value> Report transformations performed by optimization passes whose name matches the given POSIX regular expression

flang/test/Driver/driver-help.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
! HELP-NEXT: -print-target-triple Print the normalized target triple
133133
! HELP-NEXT: -pthread Support POSIX threads in generated code
134134
! HELP-NEXT: -P Disable linemarker output in -E mode
135+
! HELP-NEXT: --rocm-path=<value> ROCm installation path, used for finding and automatically linking required bitcode libraries.
135136
! HELP-NEXT: -Rpass-analysis=<value> Report transformation analysis from optimization passes whose name matches the given POSIX regular expression
136137
! HELP-NEXT: -Rpass-missed=<value> Report missed transformations by optimization passes whose name matches the given POSIX regular expression
137138
! HELP-NEXT: -Rpass=<value> Report transformations performed by optimization passes whose name matches the given POSIX regular expression

flang/test/Driver/omp-driver-offload.f90

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,24 @@
201201
! RUN: -nogpulibc %s 2>&1 \
202202
! RUN: | FileCheck --check-prefix=NO-LIBC-GPU-AMDGPU %s
203203
! NO-LIBC-GPU-AMDGPU-NOT: "-lcgpu-amdgpu"
204+
205+
! RUN: rm -rf %t/Inputs
206+
207+
! RUN: not %flang -### -v --target=x86_64-unknown-linux-gnu -fopenmp \
208+
! RUN: --offload-arch=gfx900 \
209+
! RUN: --rocm-path=%t/Inputs/rocm %s 2>&1 \
210+
! RUN: | FileCheck --check-prefix=ROCM-PATH-NOT-FOUND %s
211+
! ROCM-PATH-NOT-FOUND: error: cannot find ROCm device library;
212+
213+
! RUN: rm -rf %t/Inputs
214+
! RUN: mkdir -p %t/Inputs
215+
! RUN: cp -r %S/../../../clang/test/Driver/Inputs/rocm %t/Inputs
216+
! RUN: mkdir -p %t/Inputs/rocm/share/hip
217+
! RUN: mkdir -p %t/Inputs/rocm/hip
218+
! RUN: mv %t/Inputs/rocm/bin/.hipVersion %t/Inputs/rocm/share/hip/version
219+
220+
! RUN: %flang -### -v --target=x86_64-unknown-linux-gnu -fopenmp \
221+
! RUN: --offload-arch=gfx900 \
222+
! RUN: --rocm-path=%t/Inputs/rocm %s 2>&1 \
223+
! RUN: | FileCheck --check-prefix=ROCM-PATH %s
224+
! ROCM-PATH: Found HIP installation: {{.*Inputs.*rocm}}, version 3.6.20214-a2917cd

0 commit comments

Comments
 (0)