d-add-soname
authorDebian Rust Maintainers <pkg-rust-maintainers@alioth-lists.debian.net>
Sun, 29 Dec 2019 22:17:04 +0000 (22:17 +0000)
committerXimin Luo <infinity0@debian.org>
Sun, 29 Dec 2019 22:17:04 +0000 (22:17 +0000)
Gbp-Pq: Name d-add-soname.patch

src/librustc_codegen_ssa/back/link.rs

index a2b50ea8e2bf79a5f142b7472d8b36257ce4b6b1..6785285d18fb88a2959e6dd1a03caca19aee9257 100644 (file)
@@ -1251,6 +1251,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 {