Link explicitly to private transitive dependencies on stub libraries
We represent stub libraries, e.g., for CUDA, using imported SHARED
library targets with only IMPORTED_IMPLIB
, and no IMPORTED_LOCATION
,
to indicate that the stub file is meant only for linkers and not dynamic
loaders. See !8582 (merged) and !9041 (merged).
If a shared library is linked to a stub, it has a NEEDED
field
populated with the SONAME
found in the stub. When a dependent target
links to such a shared library, some linkers want to find a library file
on disk and load it to see what symbols it provides. This is necessary
for linkers that enforce --no-allow-shlib-undefined
. On hosts with
only the stub library installed, e.g., with only the CUDA toolkit
development package, the real runtime library corresponding to the
stub's SONAME
may not even exist, so no -rpath-link
flag can help
linkers find it. Pass the stub library to linkers explicitly so they
can find it without searching.
Topic-rename: link-stubs-transitively