diff options
| author | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2019-04-14 19:05:21 +0200 |
|---|---|---|
| committer | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2019-06-12 23:07:13 +0200 |
| commit | 52bd4f263b57faf987dc32d40642403e313e175a (patch) | |
| tree | 009e1a7c156815cad6032fefbfb3a91a5b9a1b6a | |
| parent | 185dcebbff7f3c18fb94be82f76bdfd620cfb096 (diff) | |
| download | rust-52bd4f263b57faf987dc32d40642403e313e175a.tar.gz rust-52bd4f263b57faf987dc32d40642403e313e175a.zip | |
Add a limit_rdylib_exports option and disable it for Solaris
| -rw-r--r-- | src/librustc_codegen_ssa/back/linker.rs | 11 | ||||
| -rw-r--r-- | src/librustc_target/spec/mod.rs | 6 | ||||
| -rw-r--r-- | src/librustc_target/spec/solaris_base.rs | 1 | ||||
| -rw-r--r-- | src/librustc_target/spec/wasm32_base.rs | 5 | ||||
| -rw-r--r-- | src/librustc_target/spec/wasm32_experimental_emscripten.rs | 1 | ||||
| -rw-r--r-- | src/librustc_target/spec/wasm32_unknown_emscripten.rs | 1 |
6 files changed, 18 insertions, 7 deletions
diff --git a/src/librustc_codegen_ssa/back/linker.rs b/src/librustc_codegen_ssa/back/linker.rs index eee9533535f..39ccf4f46b7 100644 --- a/src/librustc_codegen_ssa/back/linker.rs +++ b/src/librustc_codegen_ssa/back/linker.rs @@ -381,15 +381,12 @@ impl<'a> Linker for GccLinker<'a> { // The object files have far more public symbols than we actually want to export, // so we hide them all here. - if crate_type == CrateType::ProcMacro { - return + if !self.sess.target.target.options.limit_rdylib_exports { + return; } - // Symbol visibility takes care of this for the WebAssembly. - // Additionally the only known linker, LLD, doesn't support the script - // arguments just yet - if self.sess.target.target.arch == "wasm32" { - return; + if crate_type == CrateType::ProcMacro { + return } let mut arg = OsString::new(); diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 844edbb946a..329d3f2b2f3 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -748,6 +748,9 @@ pub struct TargetOptions { /// wasm32 where the whole program either has simd or not. pub simd_types_indirect: bool, + /// Pass a list of symbol which should be exported in the dylib to the linker. + pub limit_rdylib_exports: bool, + /// If set, have the linker export exactly these symbols, instead of using /// the usual logic to figure this out from the crate itself. pub override_export_symbols: Option<Vec<String>>, @@ -843,6 +846,7 @@ impl Default for TargetOptions { emit_debug_gdb_scripts: true, requires_uwtable: false, simd_types_indirect: true, + limit_rdylib_exports: true, override_export_symbols: None, merge_functions: MergeFunctions::Aliases, target_mcount: "mcount".to_string(), @@ -1149,6 +1153,7 @@ impl Target { key!(emit_debug_gdb_scripts, bool); key!(requires_uwtable, bool); key!(simd_types_indirect, bool); + key!(limit_rdylib_exports, bool); key!(override_export_symbols, opt_list); key!(merge_functions, MergeFunctions)?; key!(target_mcount); @@ -1364,6 +1369,7 @@ impl ToJson for Target { target_option_val!(emit_debug_gdb_scripts); target_option_val!(requires_uwtable); target_option_val!(simd_types_indirect); + target_option_val!(limit_rdylib_exports); target_option_val!(override_export_symbols); target_option_val!(merge_functions); target_option_val!(target_mcount); diff --git a/src/librustc_target/spec/solaris_base.rs b/src/librustc_target/spec/solaris_base.rs index 0dfbb13b773..9e7eda03773 100644 --- a/src/librustc_target/spec/solaris_base.rs +++ b/src/librustc_target/spec/solaris_base.rs @@ -8,6 +8,7 @@ pub fn opts() -> TargetOptions { has_rpath: true, target_family: Some("unix".to_string()), is_like_solaris: true, + limit_rdylib_exports: false, // Linker doesn't support this .. Default::default() } diff --git a/src/librustc_target/spec/wasm32_base.rs b/src/librustc_target/spec/wasm32_base.rs index edaf902c130..39a8ce92825 100644 --- a/src/librustc_target/spec/wasm32_base.rs +++ b/src/librustc_target/spec/wasm32_base.rs @@ -106,6 +106,11 @@ pub fn options() -> TargetOptions { // no dynamic linking, no need for default visibility! default_hidden_visibility: true, + // Symbol visibility takes care of this for the WebAssembly. + // Additionally the only known linker, LLD, doesn't support the script + // arguments just yet + limit_rdylib_exports: false, + // we use the LLD shipped with the Rust toolchain by default linker: Some("rust-lld".to_owned()), lld_flavor: LldFlavor::Wasm, diff --git a/src/librustc_target/spec/wasm32_experimental_emscripten.rs b/src/librustc_target/spec/wasm32_experimental_emscripten.rs index 5ecd66306d0..b802bee25ae 100644 --- a/src/librustc_target/spec/wasm32_experimental_emscripten.rs +++ b/src/librustc_target/spec/wasm32_experimental_emscripten.rs @@ -24,6 +24,7 @@ pub fn target() -> Result<Target, String> { is_like_emscripten: true, max_atomic_width: Some(32), post_link_args, + limit_rdylib_exports: false, target_family: Some("unix".to_string()), .. Default::default() }; diff --git a/src/librustc_target/spec/wasm32_unknown_emscripten.rs b/src/librustc_target/spec/wasm32_unknown_emscripten.rs index a6e9340ce28..e0df36884bf 100644 --- a/src/librustc_target/spec/wasm32_unknown_emscripten.rs +++ b/src/librustc_target/spec/wasm32_unknown_emscripten.rs @@ -26,6 +26,7 @@ pub fn target() -> Result<Target, String> { is_like_emscripten: true, max_atomic_width: Some(32), post_link_args, + limit_rdylib_exports: false, target_family: Some("unix".to_string()), codegen_backend: "emscripten".to_string(), .. Default::default() |
