Skip to content

Commit

Permalink
Unconditionally pass a version script to the linker.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Apr 5, 2018
1 parent acbc6c5 commit 679ba55
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
9 changes: 3 additions & 6 deletions src/librustc_trans/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -957,12 +957,9 @@ fn link_args(cmd: &mut Linker,
}
}

// If we're building a dynamic library then some platforms need to make sure
// that all symbols are exported correctly from the dynamic library.
if crate_type != config::CrateTypeExecutable ||
sess.target.target.options.is_like_emscripten {
cmd.export_symbols(tmpdir, crate_type);
}
// We are always giving the linker a list of exported symbols so it can hide
// as many symbols as possible.
cmd.export_symbols(tmpdir, crate_type);

// When linking a dynamic library, we put the metadata into a section of the
// executable. This metadata is in a separate object file from the main
Expand Down
9 changes: 9 additions & 0 deletions src/test/run-make-fulldeps/reproducible-build/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ fn main() {
for arg in env::args().skip(1) {
let path = Path::new(&arg);
if !path.is_file() {
let arg = if arg.ends_with("/list") && arg.contains("rustc.") {
// Special case the linker script since it contains a temporary
// directory name created by the compiler
let end = arg.rfind("rustc.").unwrap();
(&arg[..end]).to_string()
} else {
arg.to_string()
};

out.push_str(&arg);
out.push_str("\n");
continue
Expand Down
6 changes: 2 additions & 4 deletions src/test/run-make-fulldeps/symbol-visibility/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ all:
# Check that a Rust dylib does not export generics if -Zshare-generics=no
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c _ZN.*public_generic_function_from_rlib.*E)" -eq "0" ]

# Check that an executable does not export any dynamic symbols
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ]
# Check that an executable does not export any dynamic Rust symbols
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_rust_function_from_exe)" -eq "0" ]
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c _ZN.*h.*E)" -eq "0" ]

Expand Down Expand Up @@ -87,8 +86,7 @@ all:
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rlib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c _ZN.*public_generic_function_from_rlib.*E)" -eq "1" ]

# Check that an executable does not export any dynamic symbols
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ]
# Check that an executable does not export any dynamic Rust symbols
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_rust_function_from_exe)" -eq "0" ]
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c _ZN.*h.*E)" -eq "0" ]
endif

0 comments on commit 679ba55

Please sign in to comment.