Skip to content

Commit eba4df0

Browse files
committed
[clang][Driver] Add ROCm lib/llvm/bin detection test
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.
1 parent 411a53e commit eba4df0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

clang/test/Driver/rocm-detect.hip

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,20 @@
9494
// RUN: --print-rocm-search-dirs %s 2>&1 \
9595
// RUN: | FileCheck -check-prefixes=ROCM-REL %s
9696

97+
// Test detecting ROCm installation from clang installed in /opt/rocm/lib/llvm/bin.
98+
// This exercises the RocmInstallationDetector logic that backs up from
99+
// /opt/rocm/lib/llvm/bin to the ROCm root, while avoiding dependence on any
100+
// real /opt/rocm installation by using a synthetic sysroot under %t.
101+
// RUN: rm -rf %t/*
102+
// RUN: mkdir -p %t/sysroot/opt/rocm/lib/llvm/bin
103+
// Copy the built clang binary so that its InstalledDir and the real path used
104+
// by the driver both reside under /opt/rocm/lib/llvm/bin, which is what the
105+
// detection logic inspects.
106+
// RUN: cp %clang %t/sysroot/opt/rocm/lib/llvm/bin/clang
107+
// RUN: %t/sysroot/opt/rocm/lib/llvm/bin/clang -### --target=x86_64-linux-gnu \
108+
// RUN: --offload-arch=gfx1010 --print-rocm-search-dirs %s 2>&1 \
109+
// RUN: | FileCheck -check-prefixes=ROCM-LIB-LLVM %s
110+
97111
// 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
98112

99113
// NODEFAULTLIBS-NOT: error: cannot find
@@ -118,3 +132,6 @@
118132

119133
// ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm
120134
// ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm-3.10.0
135+
136+
// ROCM-LIB-LLVM: ROCm installation search path: {{.*sysroot/opt/rocm$}}
137+
// ROCM-LIB-LLVM-NOT: ROCm installation search path: {{.*sysroot/opt/rocm/lib$}}

0 commit comments

Comments
 (0)