teak-llvm/clang/test/Driver/cuda-detect-path.cu
Jonas Hahnfeld 7f9c518423 [CUDA] Detect installation in PATH
If the CUDA toolkit is not installed to its default locations
in /usr/local/cuda, the user is forced to specify --cuda-path.
This is tedious and the driver can be smarter if well-known tools
(like ptxas) can already be found in the PATH environment variable.

Add option --cuda-path-ignore-env if the user wants to ignore
set environment variables. Also use it in the tests to make sure
the driver always finds the same CUDA installation, regardless
of the user's environment.

Differential Revision: https://reviews.llvm.org/D42642

llvm-svn: 323848
2018-01-31 08:26:51 +00:00

84 lines
4.5 KiB
Plaintext

// REQUIRES: clang-driver
// REQUIRES: x86-registered-target
// REQUIRES: nvptx-registered-target
// This tests uses the PATH environment variable.
// REQUIRES: !system-windows
// RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
// RUN: %clang -v --target=i386-unknown-linux --sysroot=%S/no-cuda-there \
// RUN: 2>&1 | FileCheck %s
// RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
// RUN: %clang -v --target=i386-apple-macosx --sysroot=%S/no-cuda-there \
// RUN: 2>&1 | FileCheck %s
// RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
// RUN: %clang -v --target=x86_64-unknown-linux --sysroot=%S/no-cuda-there \
// RUN: 2>&1 | FileCheck %s
// RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
// RUN: %clang -v --target=x86_64-apple-macosx --sysroot=%S/no-cuda-there \
// RUN: 2>&1 | FileCheck %s
// Check that we follow ptxas binaries that are symlinks.
// RUN: env PATH=%S/Inputs/CUDA-symlinks/usr/bin \
// RUN: %clang -v --target=i386-unknown-linux --sysroot=%S/no-cuda-there \
// RUN: 2>&1 | FileCheck %s --check-prefix SYMLINKS
// RUN: env PATH=%S/Inputs/CUDA-symlinks/usr/bin \
// RUN: %clang -v --target=i386-apple-macosx --sysroot=%S/no-cuda-there \
// RUN: 2>&1 | FileCheck %s --check-prefix SYMLINKS
// RUN: env PATH=%S/Inputs/CUDA-symlinks/usr/bin \
// RUN: %clang -v --target=x86_64-unknown-linux --sysroot=%S/no-cuda-there \
// RUN: 2>&1 | FileCheck %s --check-prefix SYMLINKS
// RUN: env PATH=%S/Inputs/CUDA-symlinks/usr/bin \
// RUN: %clang -v --target=x86_64-apple-macosx --sysroot=%S/no-cuda-there \
// RUN: 2>&1 | FileCheck %s --check-prefix SYMLINKS
// We only take a CUDA installation from PATH if it contains libdevice.
// RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
// RUN: %clang -v --target=i386-unknown-linux --sysroot=%S/no-cuda-there \
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
// RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
// RUN: %clang -v --target=i386-apple-macosx --sysroot=%S/no-cuda-there \
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
// RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
// RUN: %clang -v --target=x86_64-unknown-linux --sysroot=%S/no-cuda-there \
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
// RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
// RUN: %clang -v --target=x86_64-apple-macosx --sysroot=%S/no-cuda-there \
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
// We even require libdevice if -nocudalib is passed to avoid false positives
// if the distribution merges CUDA into /usr and ptxas ends up /usr/bin.
// RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
// RUN: %clang -v --target=i386-unknown-linux --sysroot=%S/no-cuda-there -nocudalib \
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
// RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
// RUN: %clang -v --target=i386-apple-macosx --sysroot=%S/no-cuda-there -nocudalib \
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
// RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
// RUN: %clang -v --target=x86_64-unknown-linux --sysroot=%S/no-cuda-there -nocudalib \
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
// RUN: env PATH=%S/Inputs/CUDA-nolibdevice/usr/local/cuda/bin \
// RUN: %clang -v --target=x86_64-apple-macosx --sysroot=%S/no-cuda-there -nocudalib \
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
// Check that the CUDA installation in PATH is not taken when passing
// the option --cuda-path-ignore-env.
// RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
// RUN: %clang -v --target=i386-unknown-linux --sysroot=%S/no-cuda-there --cuda-path-ignore-env \
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
// RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
// RUN: %clang -v --target=i386-apple-macosx --sysroot=%S/no-cuda-there --cuda-path-ignore-env \
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
// RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
// RUN: %clang -v --target=x86_64-unknown-linux --sysroot=%S/no-cuda-there --cuda-path-ignore-env \
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
// RUN: env PATH=%S/Inputs/CUDA/usr/local/cuda/bin \
// RUN: %clang -v --target=x86_64-apple-macosx --sysroot=%S/no-cuda-there --cuda-path-ignore-env \
// RUN: 2>&1 | FileCheck %s --check-prefix NOCUDA
// CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA/usr/local/cuda
// SYMLINKS: Found CUDA installation: {{.*}}/Inputs/CUDA-symlinks/opt/cuda
// NOCUDA-NOT: Found CUDA installation: