Skip to content

Commit 679ba55

Browse files
Unconditionally pass a version script to the linker.
1 parent acbc6c5 commit 679ba55

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

src/librustc_trans/back/link.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -957,12 +957,9 @@ fn link_args(cmd: &mut Linker,
957957
}
958958
}
959959

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

967964
// When linking a dynamic library, we put the metadata into a section of the
968965
// executable. This metadata is in a separate object file from the main

src/test/run-make-fulldeps/reproducible-build/linker.rs

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ fn main() {
2727
for arg in env::args().skip(1) {
2828
let path = Path::new(&arg);
2929
if !path.is_file() {
30+
let arg = if arg.ends_with("/list") && arg.contains("rustc.") {
31+
// Special case the linker script since it contains a temporary
32+
// directory name created by the compiler
33+
let end = arg.rfind("rustc.").unwrap();
34+
(&arg[..end]).to_string()
35+
} else {
36+
arg.to_string()
37+
};
38+
3039
out.push_str(&arg);
3140
out.push_str("\n");
3241
continue

src/test/run-make-fulldeps/symbol-visibility/Makefile

+2-4
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ all:
4949
# Check that a Rust dylib does not export generics if -Zshare-generics=no
5050
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c _ZN.*public_generic_function_from_rlib.*E)" -eq "0" ]
5151

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

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

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

0 commit comments

Comments
 (0)