Set DT_SONAME when building dylibs
authorAngus Lees <gus@debian.org>
Fri, 10 Apr 2020 10:33:25 +0000 (11:33 +0100)
committerXimin Luo <infinity0@debian.org>
Fri, 10 Apr 2020 10:33:25 +0000 (11:33 +0100)
commite7ca6bc1b0284ea5db9214e079f30f395e782161
tree460671e11ce9b4bf8c51c5899310cc0c3d48a2f6
parent7f71faa545445df5773fe7ba189625db61649c19
Set DT_SONAME when building dylibs

Forwarded: no

In Rust, library filenames include a version-specific hash to help
the run-time linker find the correct version.  Unlike in C/C++, the
compiler looks for all libraries matching a glob that ignores the
hash and reads embedded metadata to work out versions, etc.

The upshot is that there is no need for the usual "libfoo.so ->
libfoo-1.2.3.so" symlink common with C/C++ when building with Rust,
and no need to communicate an alternate filename to use at run-time
vs compile time.  If linking to a Rust dylib from C/C++ however, a
"libfoo.so -> libfoo-$hash.so" symlink may well be useful and in
this case DT_SONAME=libfoo-$hash.so would be required.  More
mundanely, various tools (eg: dpkg-shlibdeps) complain if they don't
find DT_SONAME on shared libraries in public directories.

This patch passes -Wl,-soname=$outfile when building dylibs (and
using a GNU linker).

Gbp-Pq: Name d-add-soname.patch
src/librustc_codegen_ssa/back/link.rs