llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-backend-amdgpu Author: Matthias Gehre (mgehre-amd) <details> <summary>Changes</summary> Fixes https://github.com/ROCm/TheRock/issues/785. ROCM_PATH doesn't always have a layout where the device libraries can be found, so fallback to resource dirs even when ROCM_PATH is set. --- Full diff: https://github.com/llvm/llvm-project/pull/177346.diff 2 Files Affected: - (modified) clang/lib/Driver/ToolChains/AMDGPU.cpp (+3-4) - (modified) clang/test/Driver/rocm-detect.hip (+13) ``````````diff diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 87ccd40372681..a2ac7ca40fba2 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -211,16 +211,15 @@ RocmInstallationDetector::getInstallationPathCandidates() { // For candidate specified by --rocm-path we do not do strict check, i.e., // checking existence of HIP version file and device library files. + // These are added first as highest priority candidates, but we continue + // to add clang-relative paths to support cases where the compiler has its + // own device libraries (e.g., python wheels with bundled device libs). if (!RocmPathArg.empty()) { ROCmSearchDirs.emplace_back(RocmPathArg.str()); - DoPrintROCmSearchDirs(); - return ROCmSearchDirs; } else if (std::optional<std::string> RocmPathEnv = llvm::sys::Process::GetEnv("ROCM_PATH")) { if (!RocmPathEnv->empty()) { ROCmSearchDirs.emplace_back(std::move(*RocmPathEnv)); - DoPrintROCmSearchDirs(); - return ROCmSearchDirs; } } diff --git a/clang/test/Driver/rocm-detect.hip b/clang/test/Driver/rocm-detect.hip index b28b2bc6379dd..77cf65ddff160 100644 --- a/clang/test/Driver/rocm-detect.hip +++ b/clang/test/Driver/rocm-detect.hip @@ -94,6 +94,16 @@ // RUN: --print-rocm-search-dirs %s 2>&1 \ // RUN: | FileCheck -check-prefixes=ROCM-REL %s +// Test that device libs from resource dir are found even when ROCM_PATH is set +// to a location without device libs. +// This verifies that clang-relative paths are still searched after ROCM_PATH. +// RUN: rm -rf %t/* +// RUN: mkdir -p %t/fake_rocm +// RUN: env ROCM_PATH=%t/fake_rocm \ +// RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx900 -nogpuinc \ +// RUN: -resource-dir=%S/Inputs/rocm_resource_dir %s 2>&1 \ +// RUN: | FileCheck -check-prefixes=ROCM-PATH-FALLBACK %s + // GFX902-DEFAULTLIBS: error: cannot find ROCm device library for gfx902; provide its path via '--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build without ROCm device library // NODEFAULTLIBS-NOT: error: cannot find @@ -118,3 +128,6 @@ // ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm // ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm-3.10.0 + +// ROCM-PATH-FALLBACK-NOT: error: cannot find ROCm device library +// ROCM-PATH-FALLBACK: "-mlink-builtin-bitcode" "{{.*}}rocm_resource_dir{{(/|\\\\)}}lib{{(64)?}}{{(/|\\\\)}}amdgcn{{(/|\\\\)}}bitcode{{(/|\\\\)}}ocml.bc" `````````` </details> https://github.com/llvm/llvm-project/pull/177346 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
