rust/add-soname.patch
Kristoffer Gronlund 743ec85b28 Accepting request 437035 from home:KGronlund:branches:devel:languages:rust
- Update to 1.11
  + Add support for cdylib crate types
- Remove merged patches:
  * 0001-Fix-misleading-intentation-errors-on-gcc-6.0.patch
  * 0002-Fix-GCC-6-misleading-indentation-error-in-hoedown.patch

OBS-URL: https://build.opensuse.org/request/show/437035
OBS-URL: https://build.opensuse.org/package/show/devel:languages:rust/rust?expand=0&rev=5
2016-10-24 07:34:54 +00:00

36 lines
1.6 KiB
Diff

Description: 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).
Author: Angus Lees <gus@debian.org>
Forwarded: no
--- a/src/librustc_trans/back/link.rs
+++ b/src/librustc_trans/back/link.rs
@@ -840,6 +840,12 @@
cmd.args(&rpath::get_rpath_flags(&mut rpath_config));
}
+ if (crate_type == config::CrateTypeDylib || crate_type == config::CrateTypeCdylib) && t.options.linker_is_gnu {
+ let filename = String::from(out_filename.file_name().unwrap().to_str().unwrap());
+ let soname = [String::from("-Wl,-soname=") + &filename];
+ cmd.args(&soname);
+ }
+
// Finally add all the linker arguments provided on the command line along
// with any #[link_args] attributes found inside the crate
if let Some(ref args) = sess.opts.cg.link_args {