d-add-soname
authorDebian Rust Maintainers <pkg-rust-maintainers@alioth-lists.debian.net>
Thu, 5 Sep 2019 07:06:23 +0000 (08:06 +0100)
committerXimin Luo <infinity0@debian.org>
Thu, 5 Sep 2019 07:06:23 +0000 (08:06 +0100)
Gbp-Pq: Name d-add-soname.patch

src/librustc_codegen_ssa/back/link.rs

index e3d297e78623ed05bd94f2fb02225e6a16b8a601..376097ac5830c828eddc69866e480f274b54691b 100644 (file)
@@ -1207,6 +1207,13 @@ fn link_args<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
         cmd.args(&rpath::get_rpath_flags(&mut rpath_config));
     }
 
+    if (crate_type == config::CrateType::Dylib || crate_type == config::CrateType::Cdylib)
+       && 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 {