Skip to content

Commit d3951ff

Browse files
Add regression test for symbol visibility when compiling rlib+cdylib in one session.
1 parent c13e35e commit d3951ff

File tree

1 file changed

+12
-2
lines changed
  • src/test/run-make/symbol-visibility

1 file changed

+12
-2
lines changed

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

+12-2
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,25 @@ all:
99
else
1010

1111
NM=nm -D
12-
DYLIB_EXT=so
1312
CDYLIB_NAME=liba_cdylib.so
1413
RDYLIB_NAME=liba_rust_dylib.so
1514
EXE_NAME=an_executable
15+
COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.so
1616

1717
ifeq ($(UNAME),Darwin)
1818
NM=nm -gU
19-
DYLIB_EXT=dylib
2019
CDYLIB_NAME=liba_cdylib.dylib
2120
RDYLIB_NAME=liba_rust_dylib.dylib
2221
EXE_NAME=an_executable
22+
COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.dylib
2323
endif
2424

2525
all:
2626
$(RUSTC) an_rlib.rs
2727
$(RUSTC) a_cdylib.rs
2828
$(RUSTC) a_rust_dylib.rs
2929
$(RUSTC) an_executable.rs
30+
$(RUSTC) a_cdylib.rs --crate-name combined_rlib_dylib --crate-type=rlib,cdylib
3031

3132
# Check that a cdylib exports its public #[no_mangle] functions
3233
[ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ]
@@ -47,4 +48,13 @@ all:
4748
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ]
4849
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_rust_function_from_exe)" -eq "0" ]
4950

51+
52+
# Check the combined case, where we generate a cdylib and an rlib in the same
53+
# compilation session:
54+
# Check that a cdylib exports its public #[no_mangle] functions
55+
[ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ]
56+
# Check that a cdylib exports the public #[no_mangle] functions of dependencies
57+
[ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
58+
# Check that a cdylib DOES NOT export any public Rust functions
59+
[ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c _ZN.*h.*E)" -eq "0" ]
5060
endif

0 commit comments

Comments
 (0)