https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/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 this. 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. >From 9631643f2b15c21528b8f73f9a61bbc9f9a0c344 Mon Sep 17 00:00:00 2001 From: Joseph Huber <hube...@outlook.com> Date: Mon, 4 Aug 2025 08:38:24 -0500 Subject: [PATCH] [Clang] Hide `offload-arch` initialization erros behind verbose flag 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 this. 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. --- clang/tools/offload-arch/AMDGPUArchByHIP.cpp | 5 +++-- clang/tools/offload-arch/NVPTXArch.cpp | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) 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; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits