Set DT_SONAME when building dylibs
authorAngus Lees <gus@debian.org>
Thu, 14 Jul 2022 11:17:39 +0000 (13:17 +0200)
committerFabian Grünbichler <debian@fabian.gruenbichler.email>
Wed, 4 Sep 2024 18:13:19 +0000 (20:13 +0200)
commitb2d5c74cbf45ce64975b23e2865f04c48fdf446f
tree24cf030c6c96966d3597eba729863b715702c754
parent11a1fb91f10cd9b6357d329b03569c7472054e49
Set DT_SONAME when building dylibs

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).

Forwarded: no

Gbp-Pq: Topic behaviour
Gbp-Pq: Name d-rustc-add-soname.patch
compiler/rustc_codegen_ssa/src/back/link.rs