Skip to content

[Clang][AMDGPU] Improve error message when device libraries for COV6 are missing #134745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def err_drv_no_cuda_libdevice : Error<
"libdevice">;

def err_drv_no_rocm_device_lib : Error<
"cannot find ROCm device library%select{| for %1| for ABI version %1}0; provide its path via "
"cannot find ROCm device library%select{| for %1| for ABI version %1"
"%select{|, which requires ROCm %3 or higher}2}0; provide its path via "
"'--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build "
"without ROCm device library">;
def err_drv_no_hip_runtime : Error<
Expand Down
8 changes: 7 additions & 1 deletion clang/lib/Driver/ToolChains/AMDGPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,13 @@ bool RocmInstallationDetector::checkCommonBitcodeLibs(
return false;
}
if (ABIVer.requiresLibrary() && getABIVersionPath(ABIVer).empty()) {
D.Diag(diag::err_drv_no_rocm_device_lib) << 2 << ABIVer.toString();
// Starting from COV6, we will report minimum ROCm version requirement in
// the error message.
if (ABIVer.getAsCodeObjectVersion() < 6)
D.Diag(diag::err_drv_no_rocm_device_lib) << 2 << ABIVer.toString() << 0;
else
D.Diag(diag::err_drv_no_rocm_device_lib)
<< 2 << ABIVer.toString() << 1 << "6.3";
return false;
}
return true;
Expand Down
6 changes: 4 additions & 2 deletions clang/lib/Driver/ToolChains/ROCm.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ struct DeviceLibABIVersion {
/// and below works with ROCm 5.0 and below which does not have
/// abi_version_*.bc. Code object v5 requires abi_version_500.bc.
bool requiresLibrary() { return ABIVersion >= 500; }
std::string toString() {
std::string toString() { return Twine(getAsCodeObjectVersion()).str(); }

unsigned getAsCodeObjectVersion() const {
assert(ABIVersion % 100 == 0 && "Not supported");
return Twine(ABIVersion / 100).str();
return ABIVersion / 100;
}
};

Expand Down
2 changes: 1 addition & 1 deletion clang/test/Driver/hip-device-libs.hip
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,4 @@
// NOABI4-NOT: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_400.bc"
// NOABI4-NOT: "-mlink-builtin-bitcode" "{{.*}}oclc_abi_version_500.bc"
// 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
// 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
// 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