]> git.proxmox.com Git - rustc.git/blame - debian/patches/d-add-soname.patch
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / debian / patches / d-add-soname.patch
CommitLineData
485151a8
AL
1Description: Set DT_SONAME when building dylibs
2 In Rust, library filenames include a version-specific hash to help
3 the run-time linker find the correct version. Unlike in C/C++, the
4 compiler looks for all libraries matching a glob that ignores the
5 hash and reads embedded metadata to work out versions, etc.
6 .
7 The upshot is that there is no need for the usual "libfoo.so ->
8 libfoo-1.2.3.so" symlink common with C/C++ when building with Rust,
9 and no need to communicate an alternate filename to use at run-time
10 vs compile time. If linking to a Rust dylib from C/C++ however, a
11 "libfoo.so -> libfoo-$hash.so" symlink may well be useful and in
12 this case DT_SONAME=libfoo-$hash.so would be required. More
13 mundanely, various tools (eg: dpkg-shlibdeps) complain if they don't
14 find DT_SONAME on shared libraries in public directories.
15 .
16 This patch passes -Wl,-soname=$outfile when building dylibs (and
17 using a GNU linker).
18Author: Angus Lees <gus@debian.org>
19Forwarded: no
20
cefde48f
XL
21--- a/compiler/rustc_codegen_ssa/src/back/link.rs
22+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
23@@ -1758,6 +1758,13 @@
50bd2472
XL
24 // OBJECT-FILES-NO, AUDIT-ORDER
25 add_rpath_args(cmd, sess, codegen_results, out_filename);
bf7d350a 26
d925017b 27+ if (crate_type == config::CrateType::Dylib || crate_type == config::CrateType::Cdylib)
d58bc66d 28+ && sess.target.linker_is_gnu {
9501650c
SL
29+ let filename = String::from(out_filename.file_name().unwrap().to_str().unwrap());
30+ let soname = [String::from("-Wl,-soname=") + &filename];
11da3108 31+ cmd.args(&soname);
485151a8
AL
32+ }
33+
50bd2472
XL
34 // OBJECT-FILES-MAYBE, CUSTOMIZATION-POINT
35 add_user_defined_link_args(cmd, sess, codegen_results);
36