Skip to content

Commit f19c6f2

Browse files
authored
[Clang][AMDGPU] Improve error message when device libraries for COV6 are missing (#134745)
#130963 switches the default to COV6, which requires ROCm 6.3. Currently, if the device libraries for COV6 are not found, the error message is not very helpful. This PR provides a more informative error message in such cases.
1 parent 0e98817 commit f19c6f2

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ def err_drv_no_cuda_libdevice : Error<
6767
"libdevice">;
6868

6969
def err_drv_no_rocm_device_lib : Error<
70-
"cannot find ROCm device library%select{| for %1| for ABI version %1}0; provide its path via "
70+
"cannot find ROCm device library%select{| for %1| for ABI version %1"
71+
"%select{|, which requires ROCm %3 or higher}2}0; provide its path via "
7172
"'--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build "
7273
"without ROCm device library">;
7374
def err_drv_no_hip_runtime : Error<

clang/lib/Driver/ToolChains/AMDGPU.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,13 @@ bool RocmInstallationDetector::checkCommonBitcodeLibs(
935935
return false;
936936
}
937937
if (ABIVer.requiresLibrary() && getABIVersionPath(ABIVer).empty()) {
938-
D.Diag(diag::err_drv_no_rocm_device_lib) << 2 << ABIVer.toString();
938+
// Starting from COV6, we will report minimum ROCm version requirement in
939+
// the error message.
940+
if (ABIVer.getAsCodeObjectVersion() < 6)
941+
D.Diag(diag::err_drv_no_rocm_device_lib) << 2 << ABIVer.toString() << 0;
942+
else
943+
D.Diag(diag::err_drv_no_rocm_device_lib)
944+
<< 2 << ABIVer.toString() << 1 << "6.3";
939945
return false;
940946
}
941947
return true;

clang/lib/Driver/ToolChains/ROCm.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ struct DeviceLibABIVersion {
3737
/// and below works with ROCm 5.0 and below which does not have
3838
/// abi_version_*.bc. Code object v5 requires abi_version_500.bc.
3939
bool requiresLibrary() { return ABIVersion >= 500; }
40-
std::string toString() {
40+
std::string toString() { return Twine(getAsCodeObjectVersion()).str(); }
41+
42+
unsigned getAsCodeObjectVersion() const {
4143
assert(ABIVersion % 100 == 0 && "Not supported");
42-
return Twine(ABIVersion / 100).str();
44+
return ABIVersion / 100;
4345
}
4446
};
4547

clang/test/Driver/hip-device-libs.hip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,4 @@
254254
// NOABI4-NOT: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_400.bc"
255255
// NOABI4-NOT: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_500.bc"
256256
// NOABI5: error: cannot find ROCm device library for ABI version 5; provide its path via '--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build without ROCm device library
257-
// NOABI6: error: cannot find ROCm device library for ABI version 6; provide its path via '--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build without ROCm device library
257+
// NOABI6: error: cannot find ROCm device library for ABI version 6, which requires ROCm 6.3 or higher; provide its path via '--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build without ROCm device library

0 commit comments

Comments
 (0)