]> git.proxmox.com Git - rustc.git/blame - debian/patches/d-add-soname.patch
Refresh of the patches
[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
f3f050d1
SL
21Index: rustc.git/src/librustc_trans/back/link.rs
22===================================================================
23--- rustc.git.orig/src/librustc_trans/back/link.rs
24+++ rustc.git/src/librustc_trans/back/link.rs
25@@ -895,6 +895,12 @@ fn link_args(cmd: &mut Linker,
bf7d350a 26 cmd.args(&rpath::get_rpath_flags(&mut rpath_config));
485151a8 27 }
bf7d350a 28
8d801659 29+ if (crate_type == config::CrateTypeDylib || crate_type == config::CrateTypeCdylib) && t.options.linker_is_gnu {
9501650c
SL
30+ let filename = String::from(out_filename.file_name().unwrap().to_str().unwrap());
31+ let soname = [String::from("-Wl,-soname=") + &filename];
11da3108 32+ cmd.args(&soname);
485151a8
AL
33+ }
34+
bf7d350a
SL
35 // Finally add all the linker arguments provided on the command line along
36 // with any #[link_args] attributes found inside the crate
37 if let Some(ref args) = sess.opts.cg.link_args {