From 9dc49520adaff3547d8bceefa5f5b4cec47bfb0f Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Wed, 7 May 2025 11:11:57 -0400 Subject: [PATCH] HACK: Handle ROCM installation layout of lib/llvm/bin/clang++. --- clang/lib/Driver/ToolChains/AMDGPU.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index a29aa3179bbd9..495d44a44b819 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -181,8 +181,17 @@ RocmInstallationDetector::getInstallationPathCandidates() { // Some versions of the rocm llvm package install to /opt/rocm/llvm/bin // Some versions of the aomp package install to /opt/rocm/aomp/bin - if (ParentName == "llvm" || ParentName.starts_with("aomp")) + if (ParentName == "llvm" || ParentName.starts_with("aomp")) { ParentDir = llvm::sys::path::parent_path(ParentDir); + ParentName = llvm::sys::path::filename(ParentDir); + + // Some versions of the rocm llvm package install to + // /opt/rocm/lib/llvm/bin, so also back up if within the lib dir still. + if (ParentName == "lib") { + ParentDir = llvm::sys::path::parent_path(ParentDir); + } + } + // Some versions of the aomp package install to /opt/rocm/aomp/bin // and it seems ParentDir is already pointing to correct place. return Candidate(ParentDir.str(), /*StrictChecking=*/true);