Skip to content

Commit c2005f0

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 4a48740 commit c2005f0

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// UNSUPPORTED: system-windows
2+
//
3+
// Copying clang to a new location and running it will not work unless it is
4+
// statically linked. Dynamically linked builds typically use relative rpaths,
5+
// which this will break.
6+
// REQUIRES: static-libs
7+
//
8+
// Test detecting ROCm installation from clang installed in /opt/rocm/lib/llvm/bin.
9+
// This exercises the RocmInstallationDetector logic that backs up from
10+
// /opt/rocm/lib/llvm/bin to the ROCm root, while avoiding dependence on any
11+
// real /opt/rocm installation by using a synthetic sysroot under %t.
12+
//
13+
// RUN: rm -rf %t/*
14+
// Set up a fake ROCm installation rooted at /opt/rocm in the synthetic sysroot
15+
// so that the device libraries and HIP runtime can be found.
16+
// RUN: mkdir -p %t/sysroot/opt/rocm
17+
// RUN: cp -r %S/Inputs/rocm/* %t/sysroot/opt/rocm
18+
// Copy the built clang binary so that its InstalledDir and the real path used
19+
// by the driver both reside under /opt/rocm/lib/llvm/bin, which is what the
20+
// detection logic inspects.
21+
// RUN: mkdir -p %t/sysroot/opt/rocm/lib/llvm/bin
22+
// RUN: cp %clang %t/sysroot/opt/rocm/lib/llvm/bin/clang
23+
// RUN: %t/sysroot/opt/rocm/lib/llvm/bin/clang -### --target=x86_64-linux-gnu \
24+
// RUN: --offload-arch=gfx1010 --print-rocm-search-dirs %s 2>&1 \
25+
// RUN: | FileCheck -check-prefixes=ROCM-LIB-LLVM %s
26+
//
27+
// ROCM-LIB-LLVM: ROCm installation search path: {{.*sysroot/opt/rocm$}}
28+
// ROCM-LIB-LLVM-NOT: ROCm installation search path: {{.*sysroot/opt/rocm/lib$}}

0 commit comments

Comments
 (0)