Skip to content

Conversation

@yxsamliu
Copy link
Collaborator

@yxsamliu yxsamliu commented Nov 26, 2025

Add a lit test that exercises RocmInstallationDetector when clang is installed under /opt/rocm/lib/llvm/bin, using a synthetic sysroot so it does not depend on any real /opt/rocm installation. The test copies the built clang binary into the test tree so the driver observes the expected InstalledDir and real path, following the precedent of other driver tests that copy %clang into a temporary layout.

This is for testing #138928

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Nov 26, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 26, 2025

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Yaxun (Sam) Liu (yxsamliu)

Changes

Add a lit test that exercises RocmInstallationDetector when clang is installed under /opt/rocm/lib/llvm/bin, using a synthetic sysroot so it does not depend on any real /opt/rocm installation. The test copies the built clang binary into the test tree so the driver observes the expected InstalledDir and real path, following the precedent of other driver tests that copy %clang into a temporary layout.

This is for testing #168711


Full diff: https://github.com/llvm/llvm-project/pull/169705.diff

1 Files Affected:

  • (modified) clang/test/Driver/rocm-detect.hip (+17)
diff --git a/clang/test/Driver/rocm-detect.hip b/clang/test/Driver/rocm-detect.hip
index b28b2bc6379dd..fd701dfa1a303 100644
--- a/clang/test/Driver/rocm-detect.hip
+++ b/clang/test/Driver/rocm-detect.hip
@@ -94,6 +94,20 @@
 // RUN:   --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-REL %s
 
+// Test detecting ROCm installation from clang installed in /opt/rocm/lib/llvm/bin.
+// This exercises the RocmInstallationDetector logic that backs up from
+// /opt/rocm/lib/llvm/bin to the ROCm root, while avoiding dependence on any
+// real /opt/rocm installation by using a synthetic sysroot under %t.
+// RUN: rm -rf %t/*
+// RUN: mkdir -p %t/sysroot/opt/rocm/lib/llvm/bin
+// Copy the built clang binary so that its InstalledDir and the real path used
+// by the driver both reside under /opt/rocm/lib/llvm/bin, which is what the
+// detection logic inspects.
+// RUN: cp %clang %t/sysroot/opt/rocm/lib/llvm/bin/clang
+// RUN: %t/sysroot/opt/rocm/lib/llvm/bin/clang -### --target=x86_64-linux-gnu \
+// RUN:   --offload-arch=gfx1010 --print-rocm-search-dirs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=ROCM-LIB-LLVM %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 +132,6 @@
 
 // ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm
 // ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm-3.10.0
+
+// ROCM-LIB-LLVM: ROCm installation search path: {{.*sysroot/opt/rocm$}}
+// ROCM-LIB-LLVM-NOT: ROCm installation search path: {{.*sysroot/opt/rocm/lib$}}

@github-actions
Copy link

github-actions bot commented Nov 26, 2025

🐧 Linux x64 Test Results

  • 111698 tests passed
  • 4470 tests skipped

Add a lit test that exercises RocmInstallationDetector when clang is installed
under /opt/rocm/lib/llvm/bin, using a synthetic sysroot so it does not depend
on any real /opt/rocm installation. The test copies the built clang binary
into the test tree so the driver observes the expected InstalledDir and real
path, following the precedent of other driver tests that copy %clang into a
temporary layout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants