1 // REQUIRES: clang-driver
2 // REQUIRES: x86-registered-target
3 // REQUIRES: nvptx-registered-target
4 // This tests uses the PATH environment variable.
5 // REQUIRES: !system-windows
6 
7 // RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
8 // RUN:    %clang -v --target=i386-unknown-linux --sysroot=%S/no-cuda-there \
9 // RUN:    2>&1 | FileCheck %s
10 // RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
11 // RUN:    %clang -v --target=i386-apple-macosx --sysroot=%S/no-cuda-there \
12 // RUN:    2>&1 | FileCheck %s
13 // RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
14 // RUN:    %clang -v --target=x86_64-unknown-linux --sysroot=%S/no-cuda-there \
15 // RUN:    2>&1 | FileCheck %s
16 // RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
17 // RUN:    %clang -v --target=x86_64-apple-macosx --sysroot=%S/no-cuda-there \
18 // RUN:    2>&1 | FileCheck %s
19 
20 
21 // Check that we follow ptxas binaries that are symlinks.
22 // RUN: env PATH=%S/Inputs/CUDA-symlinks/usr/bin \
23 // RUN:    %clang -v --target=i386-unknown-linux --sysroot=%S/no-cuda-there \
24 // RUN:    2>&1 | FileCheck %s --check-prefix SYMLINKS
25 // RUN: env PATH=%S/Inputs/CUDA-symlinks/usr/bin \
26 // RUN:    %clang -v --target=i386-apple-macosx --sysroot=%S/no-cuda-there \
27 // RUN:    2>&1 | FileCheck %s --check-prefix SYMLINKS
28 // RUN: env PATH=%S/Inputs/CUDA-symlinks/usr/bin \
29 // RUN:    %clang -v --target=x86_64-unknown-linux --sysroot=%S/no-cuda-there \
30 // RUN:    2>&1 | FileCheck %s --check-prefix SYMLINKS
31 // RUN: env PATH=%S/Inputs/CUDA-symlinks/usr/bin \
32 // RUN:    %clang -v --target=x86_64-apple-macosx --sysroot=%S/no-cuda-there \
33 // RUN:    2>&1 | FileCheck %s --check-prefix SYMLINKS
34 
35 
36 // We only take a CUDA installation from PATH if it contains libdevice.
37 // RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
38 // RUN:    %clang -v --target=i386-unknown-linux --sysroot=%S/no-cuda-there \
39 // RUN:    2>&1 | FileCheck %s --check-prefix NOCUDA
40 // RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
41 // RUN:    %clang -v --target=i386-apple-macosx --sysroot=%S/no-cuda-there \
42 // RUN:    2>&1 | FileCheck %s --check-prefix NOCUDA
43 // RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
44 // RUN:    %clang -v --target=x86_64-unknown-linux --sysroot=%S/no-cuda-there \
45 // RUN:    2>&1 | FileCheck %s --check-prefix NOCUDA
46 // RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
47 // RUN:    %clang -v --target=x86_64-apple-macosx --sysroot=%S/no-cuda-there \
48 // RUN:    2>&1 | FileCheck %s --check-prefix NOCUDA
49 
50 // We even require libdevice if -nocudalib is passed to avoid false positives
51 // if the distribution merges CUDA into /usr and ptxas ends up /usr/bin.
52 // RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
53 // RUN:    %clang -v --target=i386-unknown-linux --sysroot=%S/no-cuda-there -nocudalib \
54 // RUN:    2>&1 | FileCheck %s --check-prefix NOCUDA
55 // RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
56 // RUN:    %clang -v --target=i386-apple-macosx --sysroot=%S/no-cuda-there -nocudalib \
57 // RUN:    2>&1 | FileCheck %s --check-prefix NOCUDA
58 // RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
59 // RUN:    %clang -v --target=x86_64-unknown-linux --sysroot=%S/no-cuda-there -nocudalib \
60 // RUN:    2>&1 | FileCheck %s --check-prefix NOCUDA
61 // RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
62 // RUN:    %clang -v --target=x86_64-apple-macosx --sysroot=%S/no-cuda-there -nocudalib \
63 // RUN:    2>&1 | FileCheck %s --check-prefix NOCUDA
64 
65 
66 // Check that the CUDA installation in PATH is not taken when passing
67 // the option --cuda-path-ignore-env.
68 // RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
69 // RUN:    %clang -v --target=i386-unknown-linux --sysroot=%S/no-cuda-there --cuda-path-ignore-env \
70 // RUN:    2>&1 | FileCheck %s --check-prefix NOCUDA
71 // RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
72 // RUN:    %clang -v --target=i386-apple-macosx --sysroot=%S/no-cuda-there --cuda-path-ignore-env \
73 // RUN:    2>&1 | FileCheck %s --check-prefix NOCUDA
74 // RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
75 // RUN:    %clang -v --target=x86_64-unknown-linux --sysroot=%S/no-cuda-there --cuda-path-ignore-env \
76 // RUN:    2>&1 | FileCheck %s --check-prefix NOCUDA
77 // RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
78 // RUN:    %clang -v --target=x86_64-apple-macosx --sysroot=%S/no-cuda-there --cuda-path-ignore-env \
79 // RUN:    2>&1 | FileCheck %s --check-prefix NOCUDA
80 
81 // CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA/usr/local/cuda
82 // SYMLINKS: Found CUDA installation: {{.*}}/Inputs/CUDA-symlinks/opt/cuda
83 // NOCUDA-NOT: Found CUDA installation:
84