CUDA: Pass more link libraries to device linking
Previously we dropped non-target items from the device link line because
nvcc rejects paths to shared library files, and only with target items
do we know the kind of library. However, this also prevents projects
from linking to system-provided libraries like cublas_device
that
contain device code.
Fix this by passing more link items to device linking. Items that are
not file paths, such as -lfoo
, can simply be passed unconditionally.
Items that are targets known to be shared libraries can still be
skipped. Items that are paths to library files can be passed directly
if they end in .a
. Otherwise, pass them using -Xnvlink
to bypass
nvcc's front-end. The nvlink tool knows to ignore shared library files.
Also pass host linker search directories to the device linker because some environments put libraries containing device code in them.
Issue: #16317 (closed)