mirror of https://github.com/rust-lang/rust.git
Auto merge of #59752 - Zoxc:dylib-fix, r=alexcrichton
Limit dylib symbols This makes `windows-gnu` match the behavior of `windows-msvc`. It probably doesn't make sense to export these symbols on other platforms either.
This commit is contained in:
commit
dbebcee8d0
|
@ -15,10 +15,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
wget \
|
wget \
|
||||||
patch
|
patch
|
||||||
|
|
||||||
# FIXME: build the `ptx-linker` instead.
|
|
||||||
RUN curl -sL https://github.com/denzp/rust-ptx-linker/releases/download/v0.9.0-alpha.2/rust-ptx-linker.linux64.tar.gz | \
|
|
||||||
tar -xzvC /usr/bin
|
|
||||||
|
|
||||||
RUN curl -sL https://nodejs.org/dist/v9.2.0/node-v9.2.0-linux-x64.tar.xz | \
|
RUN curl -sL https://nodejs.org/dist/v9.2.0/node-v9.2.0-linux-x64.tar.xz | \
|
||||||
tar -xJ
|
tar -xJ
|
||||||
|
|
||||||
|
|
|
@ -377,23 +377,16 @@ impl<'a> Linker for GccLinker<'a> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're compiling a dylib, then we let symbol visibility in object
|
// We manually create a list of exported symbols to ensure we don't expose any more.
|
||||||
// files to take care of whether they're exported or not.
|
// The object files have far more public symbols than we actually want to export,
|
||||||
//
|
// so we hide them all here.
|
||||||
// If we're compiling a cdylib, however, we manually create a list of
|
|
||||||
// exported symbols to ensure we don't expose any more. The object files
|
if !self.sess.target.target.options.limit_rdylib_exports {
|
||||||
// have far more public symbols than we actually want to export, so we
|
return;
|
||||||
// hide them all here.
|
|
||||||
if crate_type == CrateType::Dylib ||
|
|
||||||
crate_type == CrateType::ProcMacro {
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Symbol visibility takes care of this for the WebAssembly.
|
if crate_type == CrateType::ProcMacro {
|
||||||
// Additionally the only known linker, LLD, doesn't support the script
|
return
|
||||||
// arguments just yet
|
|
||||||
if self.sess.target.target.arch == "wasm32" {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut arg = OsString::new();
|
let mut arg = OsString::new();
|
||||||
|
|
|
@ -750,6 +750,9 @@ pub struct TargetOptions {
|
||||||
/// wasm32 where the whole program either has simd or not.
|
/// wasm32 where the whole program either has simd or not.
|
||||||
pub simd_types_indirect: bool,
|
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
|
/// If set, have the linker export exactly these symbols, instead of using
|
||||||
/// the usual logic to figure this out from the crate itself.
|
/// the usual logic to figure this out from the crate itself.
|
||||||
pub override_export_symbols: Option<Vec<String>>,
|
pub override_export_symbols: Option<Vec<String>>,
|
||||||
|
@ -845,6 +848,7 @@ impl Default for TargetOptions {
|
||||||
emit_debug_gdb_scripts: true,
|
emit_debug_gdb_scripts: true,
|
||||||
requires_uwtable: false,
|
requires_uwtable: false,
|
||||||
simd_types_indirect: true,
|
simd_types_indirect: true,
|
||||||
|
limit_rdylib_exports: true,
|
||||||
override_export_symbols: None,
|
override_export_symbols: None,
|
||||||
merge_functions: MergeFunctions::Aliases,
|
merge_functions: MergeFunctions::Aliases,
|
||||||
target_mcount: "mcount".to_string(),
|
target_mcount: "mcount".to_string(),
|
||||||
|
@ -1151,6 +1155,7 @@ impl Target {
|
||||||
key!(emit_debug_gdb_scripts, bool);
|
key!(emit_debug_gdb_scripts, bool);
|
||||||
key!(requires_uwtable, bool);
|
key!(requires_uwtable, bool);
|
||||||
key!(simd_types_indirect, bool);
|
key!(simd_types_indirect, bool);
|
||||||
|
key!(limit_rdylib_exports, bool);
|
||||||
key!(override_export_symbols, opt_list);
|
key!(override_export_symbols, opt_list);
|
||||||
key!(merge_functions, MergeFunctions)?;
|
key!(merge_functions, MergeFunctions)?;
|
||||||
key!(target_mcount);
|
key!(target_mcount);
|
||||||
|
@ -1366,6 +1371,7 @@ impl ToJson for Target {
|
||||||
target_option_val!(emit_debug_gdb_scripts);
|
target_option_val!(emit_debug_gdb_scripts);
|
||||||
target_option_val!(requires_uwtable);
|
target_option_val!(requires_uwtable);
|
||||||
target_option_val!(simd_types_indirect);
|
target_option_val!(simd_types_indirect);
|
||||||
|
target_option_val!(limit_rdylib_exports);
|
||||||
target_option_val!(override_export_symbols);
|
target_option_val!(override_export_symbols);
|
||||||
target_option_val!(merge_functions);
|
target_option_val!(merge_functions);
|
||||||
target_option_val!(target_mcount);
|
target_option_val!(target_mcount);
|
||||||
|
|
|
@ -8,6 +8,7 @@ pub fn opts() -> TargetOptions {
|
||||||
has_rpath: true,
|
has_rpath: true,
|
||||||
target_family: Some("unix".to_string()),
|
target_family: Some("unix".to_string()),
|
||||||
is_like_solaris: true,
|
is_like_solaris: true,
|
||||||
|
limit_rdylib_exports: false, // Linker doesn't support this
|
||||||
|
|
||||||
.. Default::default()
|
.. Default::default()
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,11 @@ pub fn options() -> TargetOptions {
|
||||||
// no dynamic linking, no need for default visibility!
|
// no dynamic linking, no need for default visibility!
|
||||||
default_hidden_visibility: true,
|
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
|
// we use the LLD shipped with the Rust toolchain by default
|
||||||
linker: Some("rust-lld".to_owned()),
|
linker: Some("rust-lld".to_owned()),
|
||||||
lld_flavor: LldFlavor::Wasm,
|
lld_flavor: LldFlavor::Wasm,
|
||||||
|
|
|
@ -24,6 +24,7 @@ pub fn target() -> Result<Target, String> {
|
||||||
is_like_emscripten: true,
|
is_like_emscripten: true,
|
||||||
max_atomic_width: Some(32),
|
max_atomic_width: Some(32),
|
||||||
post_link_args,
|
post_link_args,
|
||||||
|
limit_rdylib_exports: false,
|
||||||
target_family: Some("unix".to_string()),
|
target_family: Some("unix".to_string()),
|
||||||
.. Default::default()
|
.. Default::default()
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,6 +26,7 @@ pub fn target() -> Result<Target, String> {
|
||||||
is_like_emscripten: true,
|
is_like_emscripten: true,
|
||||||
max_atomic_width: Some(32),
|
max_atomic_width: Some(32),
|
||||||
post_link_args,
|
post_link_args,
|
||||||
|
limit_rdylib_exports: false,
|
||||||
target_family: Some("unix".to_string()),
|
target_family: Some("unix".to_string()),
|
||||||
codegen_backend: "emscripten".to_string(),
|
codegen_backend: "emscripten".to_string(),
|
||||||
.. Default::default()
|
.. Default::default()
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// assembly-output: ptx-linker
|
// assembly-output: ptx-linker
|
||||||
// compile-flags: --crate-type cdylib
|
// compile-flags: --crate-type cdylib
|
||||||
// only-nvptx64
|
// only-nvptx64
|
||||||
|
// ignore-nvptx64
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// assembly-output: emit-asm
|
// assembly-output: emit-asm
|
||||||
// compile-flags: --crate-type rlib
|
// compile-flags: --crate-type rlib
|
||||||
// only-nvptx64
|
// only-nvptx64
|
||||||
|
// ignore-nvptx64
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// assembly-output: ptx-linker
|
// assembly-output: ptx-linker
|
||||||
// compile-flags: --crate-type cdylib -C link-arg=--arch=sm_60
|
// compile-flags: --crate-type cdylib -C link-arg=--arch=sm_60
|
||||||
// only-nvptx64
|
// only-nvptx64
|
||||||
|
// ignore-nvptx64
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// assembly-output: ptx-linker
|
// assembly-output: ptx-linker
|
||||||
// compile-flags: --crate-type cdylib -C target-cpu=sm_50
|
// compile-flags: --crate-type cdylib -C target-cpu=sm_50
|
||||||
// only-nvptx64
|
// only-nvptx64
|
||||||
|
// ignore-nvptx64
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// assembly-output: ptx-linker
|
// assembly-output: ptx-linker
|
||||||
// compile-flags: --crate-type cdylib
|
// compile-flags: --crate-type cdylib
|
||||||
// only-nvptx64
|
// only-nvptx64
|
||||||
|
// ignore-nvptx64
|
||||||
|
|
||||||
#![feature(abi_ptx, core_intrinsics)]
|
#![feature(abi_ptx, core_intrinsics)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// assembly-output: ptx-linker
|
// assembly-output: ptx-linker
|
||||||
// compile-flags: --crate-type cdylib
|
// compile-flags: --crate-type cdylib
|
||||||
// only-nvptx64
|
// only-nvptx64
|
||||||
|
// ignore-nvptx64
|
||||||
|
|
||||||
#![feature(abi_ptx)]
|
#![feature(abi_ptx)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// assembly-output: ptx-linker
|
// assembly-output: ptx-linker
|
||||||
// compile-flags: --crate-type bin
|
// compile-flags: --crate-type bin
|
||||||
// only-nvptx64
|
// only-nvptx64
|
||||||
|
// ignore-nvptx64
|
||||||
|
|
||||||
#![feature(abi_ptx)]
|
#![feature(abi_ptx)]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// assembly-output: ptx-linker
|
// assembly-output: ptx-linker
|
||||||
// compile-flags: --crate-type cdylib
|
// compile-flags: --crate-type cdylib
|
||||||
// only-nvptx64
|
// only-nvptx64
|
||||||
|
// ignore-nvptx64
|
||||||
|
|
||||||
#![feature(abi_ptx)]
|
#![feature(abi_ptx)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// assembly-output: ptx-linker
|
// assembly-output: ptx-linker
|
||||||
// compile-flags: --crate-type cdylib
|
// compile-flags: --crate-type cdylib
|
||||||
// only-nvptx64
|
// only-nvptx64
|
||||||
|
// ignore-nvptx64
|
||||||
|
|
||||||
#![feature(abi_ptx)]
|
#![feature(abi_ptx)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
Loading…
Reference in New Issue