[CUDA] Driver changes to support CUDA compilation on MacOS.
authorJustin Lebar <jlebar@google.com>
Fri, 18 Nov 2016 00:41:22 +0000 (00:41 +0000)
committerJustin Lebar <jlebar@google.com>
Fri, 18 Nov 2016 00:41:22 +0000 (00:41 +0000)
commit66c4fd7987d216e91d219e5e8437673a7b0167f8
treee5db1f8f7dd6d58a09a36a0b8b12363c79371919
parent25a41c1f630c5ad29ce7180a06d737118cead85a
[CUDA] Driver changes to support CUDA compilation on MacOS.

Summary:
Compiling CUDA device code requires us to know the host toolchain,
because CUDA device-side compiles pull in e.g. host headers.

When we only supported Linux compilation, this worked because
CudaToolChain, which is responsible for device-side CUDA compilation,
inherited from the Linux toolchain.  But in order to support MacOS,
CudaToolChain needs to take a HostToolChain pointer.

Because a CUDA toolchain now requires a host TC, we no longer will
create a CUDA toolchain from Driver::getToolChain -- you have to go
through CreateOffloadingDeviceToolChains.  I am *pretty* sure this is
correct, and that previously any attempt to create a CUDA toolchain
through getToolChain() would eventually have resulted in us throwing
"error: unsupported use of NVPTX for host compilation".

In any case hacking getToolChain to create a CUDA+host toolchain would
be wrong, because a Driver can be reused for multiple compilations,
potentially with different host TCs, and getToolChain will cache the
result, causing us to potentially use a stale host TC.

So that's the main change in this patch.

In addition, we have to pull CudaInstallationDetector out of Generic_GCC
and into a top-level class.  It's now used by the Generic_GCC and MachO
toolchains.

Reviewers: tra

Subscribers: rryan, hfinkel, sfantao

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

llvm-svn: 287285
13 files changed:
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains.cpp
clang/lib/Driver/ToolChains.h
clang/lib/Driver/Tools.cpp
clang/test/Driver/Inputs/CUDA-macosx/usr/local/cuda/bin/.keep [new file with mode: 0644]
clang/test/Driver/Inputs/CUDA-macosx/usr/local/cuda/include/.keep [new file with mode: 0644]
clang/test/Driver/Inputs/CUDA-macosx/usr/local/cuda/lib/.keep [new file with mode: 0644]
clang/test/Driver/Inputs/CUDA-macosx/usr/local/cuda/nvvm/libdevice/libdevice.compute_30.10.bc [new file with mode: 0644]
clang/test/Driver/Inputs/CUDA-macosx/usr/local/cuda/nvvm/libdevice/libdevice.compute_35.10.bc [new file with mode: 0644]
clang/test/Driver/cuda-detect.cu
clang/test/Driver/cuda-external-tools.cu
clang/test/Driver/cuda-macosx.cu [new file with mode: 0644]