The new driver uses an augmented linker wrapper to perform the device
linking phase, but to the user looks like a regular linker invocation.
Contrary to the old driver, the new driver contains all the information
necessary to produce a linked device image in the host object itself.
Currently, we infer the usage of the device linker by the user
specifying an offloading toolchain, e.g. (--offload-arch=...) or
(-fopenmp-targets=...), but this shouldn't be strictly necessary.
This patch introduces a new option --offload-link to tell
the driver to use the offloading linker instead. So a compilation flow
can now look like this,
clang foo.cu --offload-new-driver -fgpu-rdc --offload-arch=sm_70 -c clang foo.o --offload-link -lcudart
I was considering if this could be merged into the -fuse-ld option,
but because the device linker wraps over the users linker it would
conflict with that. In the future it's possible to merge this into lld
completely or gold via a plugin and we would use this option to
enable the device linking feature. Let me know what you think for this.
We typically use option aliases to provide compatibility with the legacy options. AFAICT there are no current uses of Alias for the sake of saving a few characters in an option name.
Is -dlink really needed? It's not going to be typed manually all that often, and a slightly longer option does not make any difference for cmake or make files.
I assume that partial motivation for -dlink is that it's a shortened alias used by NVCC for its functionally similar --device-link option. I do not think it buys us anything. We never intended to be option-compatible with nvcc and clang's CUDA compilation and relevant options have only partial overlap with NVCC's functionality-wise and almost none syntax-wise. Adding one rarely used option for the same of matching NVCC's is not worth it, IMO.