[clang] 25c02fb - [Clang] Hide `offload-arch` initialization errors behind verbose flag (#151964)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 4 07:31:48 PDT 2025
Author: Joseph Huber
Date: 2025-08-04T09:31:44-05:00
New Revision: 25c02fbc42d06534444f2b724012126cfe7d618e
URL: https://github.com/llvm/llvm-project/commit/25c02fbc42d06534444f2b724012126cfe7d618e
DIFF: https://github.com/llvm/llvm-project/commit/25c02fbc42d06534444f2b724012126cfe7d618e.diff
LOG: [Clang] Hide `offload-arch` initialization errors behind verbose flag (#151964)
Summary:
This tool tries to print the offloading architectures. If the user
doesn't have the HIP libraries or the CUDA libraries it will print and
error.
This isn't super helpful since we're just querying things. So, for
example, if we're on an AMD machine with no CUDA you'll get the AMD GPUs
and then an error message saying that CUDA wasn't found. This silences
the error just on failing to find the library unless verbose is on.
Added:
Modified:
clang/tools/offload-arch/AMDGPUArchByHIP.cpp
clang/tools/offload-arch/NVPTXArch.cpp
Removed:
################################################################################
diff --git a/clang/tools/offload-arch/AMDGPUArchByHIP.cpp b/clang/tools/offload-arch/AMDGPUArchByHIP.cpp
index 02431bf909d6d..11cff4f5ecdbe 100644
--- a/clang/tools/offload-arch/AMDGPUArchByHIP.cpp
+++ b/clang/tools/offload-arch/AMDGPUArchByHIP.cpp
@@ -165,8 +165,9 @@ int printGPUsByHIP() {
llvm::sys::DynamicLibrary::getPermanentLibrary(DynamicHIPPath.c_str(),
&ErrMsg));
if (!DynlibHandle->isValid()) {
- llvm::errs() << "Failed to load " << DynamicHIPPath << ": " << ErrMsg
- << '\n';
+ if (Verbose)
+ llvm::errs() << "Failed to load " << DynamicHIPPath << ": " << ErrMsg
+ << '\n';
return 1;
}
diff --git a/clang/tools/offload-arch/NVPTXArch.cpp b/clang/tools/offload-arch/NVPTXArch.cpp
index c7b7fcdf80500..11ea2e79cd279 100644
--- a/clang/tools/offload-arch/NVPTXArch.cpp
+++ b/clang/tools/offload-arch/NVPTXArch.cpp
@@ -21,6 +21,8 @@
using namespace llvm;
+extern cl::opt<bool> Verbose;
+
typedef enum cudaError_enum {
CUDA_SUCCESS = 0,
CUDA_ERROR_NO_DEVICE = 100,
@@ -78,7 +80,10 @@ static int handleError(CUresult Err) {
int printGPUsByCUDA() {
// Attempt to load the NVPTX driver runtime.
if (llvm::Error Err = loadCUDA()) {
- logAllUnhandledErrors(std::move(Err), llvm::errs());
+ if (Verbose)
+ logAllUnhandledErrors(std::move(Err), llvm::errs());
+ else
+ consumeError(std::move(Err));
return 1;
}
More information about the cfe-commits
mailing list