ld.bfd wants to ensure that unresolved symbols in libraries are all
resolved when linking a binary. It will follow DT_NEEDED entries in
libraries to find dependencies, but it then needs a way to find the
dependencies. Since DT_NEEDED are resolved names
(e.g. libcap_pwd.so.1 instead of libcap_pwd.so), ld.bfd needs to find
the real libraries, not the symlinks in /usr/lib. The casper
libraries are tucked away in /lib/casper, so use -Wl,-rpath-link to
tell the linker to look there to find the missing dependencies.
I've no idea why lld doesn't require this. Maybe it doesn't validate
unresolved symbols in shared libraries pulled in, only unresolved
symbols in the objects being linked?
Alternatively, perhaps lib9p should have an -rpath of /lib/casper
along with other things that link against casper helpers. This would
also let us remove /lib/casper from rtld's default path which seems
a bit odd.
Fixes: cff482380436 bhyve: Move libcasper dependecy to lib9p