1 // REQUIRES: x86-registered-target
2 // REQUIRES: amdgpu-registered-target
3 // UNSUPPORTED: system-windows
5 // Make sure the appropriate device specific library is available.
7 // We don't include every target in the test directory, so just pick a valid
8 // target not included in the test.
10 // RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 \
11 // RUN: --rocm-path=%S/Inputs/rocm %s 2>&1 \
12 // RUN: | FileCheck -check-prefixes=COMMON,GFX902-DEFAULTLIBS %s
14 // Should not interpret -nostdlib as disabling offload libraries.
15 // RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 -nostdlib \
16 // RUN: --rocm-path=%S/Inputs/rocm %s 2>&1 \
17 // RUN: | FileCheck -check-prefixes=COMMON,GFX902-DEFAULTLIBS %s
19 // RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 -nogpulib \
20 // RUN: --rocm-path=%S/Inputs/rocm %s 2>&1 \
21 // RUN: | FileCheck -check-prefixes=COMMON,NODEFAULTLIBS %s
23 // Test environment variable ROCM_PATH.
24 // RUN: env ROCM_PATH=%S/Inputs/rocm %clang -### -target x86_64-linux-gnu \
25 // RUN: --print-rocm-search-dirs %s 2>&1 \
26 // RUN: | FileCheck -check-prefixes=ROCM-ENV %s
28 // Test detecting latest /opt/rocm-{release} directory.
30 // RUN: mkdir -p %T/opt
31 // RUN: cp -r %S/Inputs/rocm %T/opt/rocm-3.9.0-1234
32 // RUN: cp -r %S/Inputs/rocm %T/opt/rocm-3.10.0
33 // RUN: %clang -### -target x86_64-linux-gnu --sysroot=%T \
34 // RUN: --print-rocm-search-dirs %s 2>&1 \
35 // RUN: | FileCheck -check-prefixes=ROCM-REL %s
37 // Test ROCm installation built by SPACK by invoke clang at %T/rocm-spack/llvm-amdgpu-*
38 // directory through a soft link.
40 // RUN: rm -rf %T/rocm-spack
41 // RUN: cp -r %S/Inputs/rocm-spack %T
42 // RUN: ln -fs %clang %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang
43 // RUN: %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### -v \
44 // RUN: -resource-dir=%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/lib/clang \
45 // RUN: -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 --print-rocm-search-dirs %s 2>&1 \
46 // RUN: | FileCheck -check-prefixes=SPACK %s
48 // Test SPACK installation with multiple hip and rocm-device-libs packages of the same
49 // ROCm release. Clang cannot determine which one to use and emit diagnostics. --hip-path
50 // and --rocm-device-lib-path can be used to specify them.
52 // RUN: cp -r %T/rocm-spack/hip-* %T/rocm-spack/hip-4.0.0-abcd
53 // RUN: %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### -v \
54 // RUN: -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 %s 2>&1 \
55 // RUN: | FileCheck -check-prefixes=SPACK-MULT %s
56 // RUN: %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### -v \
57 // RUN: -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 \
58 // RUN: --hip-path=%T/rocm-spack/hip-4.0.0-abcd \
59 // RUN: %s 2>&1 | FileCheck -check-prefixes=SPACK-SET %s
61 // Test invalid SPACK ROCm installation missing hip and rocm-device-libs packages.
62 // The message about SPACK is emitted only if -v is specified.
64 // RUN: rm -rf %T/rocm-spack/hip-*
65 // RUN: rm -rf %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn
66 // RUN: %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### -v \
67 // RUN: -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 %s 2>&1 \
68 // RUN: | FileCheck -check-prefixes=SPACK-MISS %s
69 // RUN: %T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang --version 2>&1 \
70 // RUN: | FileCheck -check-prefixes=SPACK-MISS-SILENT %s
72 // 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
74 // NODEFAULTLIBS-NOT: error: cannot find
76 // COMMON: "-triple" "amdgcn-amd-amdhsa"
78 // ROCM-ENV: ROCm installation search path: {{.*}}/Inputs/rocm
80 // ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm
81 // ROCM-REL: ROCm installation search path: {{.*}}/opt/rocm-3.10.0
83 // SPACK: InstalledDir: [[DIR:.*]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
84 // SPACK: ROCm installation search path (Spack 4.0.0): [[DIR]]
85 // SPACK: ROCm installation search path: [[CLANG:.*]]
86 // SPACK: ROCm installation search path: [[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z
87 // SPACK: ROCm installation search path: [[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/lib/clang
88 // SPACK: ROCm installation search path: /opt/rocm
89 // SPACK: Found HIP installation: [[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd
90 // SPACK: "-triple" "amdgcn-amd-amdhsa"
91 // SPACK-SAME: "-mlink-builtin-bitcode" "[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/hip.bc"
92 // SPACK-SAME: "-idirafter" "[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/include"
94 // SPACK-MULT: InstalledDir: [[DIR:.*]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
95 // SPACK-MULT-DAG: Cannot use SPACK package hip-4.0.0 at [[DIR]] due to multiple installations for the same version
96 // SPACK-MULT-NOT: Found HIP installation: [[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd
97 // SPACK-MULT-NOT: "-internal-isystem" "[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/include"
99 // SPACK-SET: InstalledDir: [[DIR:.*]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
100 // SPACK-SET: Found HIP installation: [[DIR]]/hip-4.0.0-abcd, version 4.0.20214-a2917cd
101 // SPACK-SET: "-triple" "amdgcn-amd-amdhsa"
102 // SPACK-SET-SAME: "-mlink-builtin-bitcode" "[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/hip.bc"
103 // SPACK-SET-SAME: "-idirafter" "[[DIR]]/hip-4.0.0-abcd/include"
105 // SPACK-MISS: InstalledDir: [[DIR:.*]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
106 // SPACK-MISS-DAG: SPACK package hip-4.0.0 not found at [[DIR]]
107 // SPACK-MISS-NOT: Found HIP installation: [[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd
108 // SPACK-MISS-NOT: "-idirafter" "[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/include"
110 // SPACK-MISS-SILENT-NOT: SPACK package hip-{{.*}} not found at
111 // SPACK-MISS-SILENT-NOT: Found HIP installation