about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo>2017-10-31 14:00:28 +0100
committerMichael Woerister <michaelwoerister@posteo>2017-10-31 14:00:28 +0100
commitd3951ff5e1ac0166346d119a3cbeea7f21865fda (patch)
tree7425133b07a6f21088c60144def7ffa036e2875a
parentc13e35eb2e3be6c1f3ad14dd39200b41808a5a34 (diff)
Add regression test for symbol visibility when compiling rlib+cdylib in one session.
-rw-r--r--src/test/run-make/symbol-visibility/Makefile14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/test/run-make/symbol-visibility/Makefile b/src/test/run-make/symbol-visibility/Makefile
index 988c9473f6a..f1ada814bdb 100644
--- a/src/test/run-make/symbol-visibility/Makefile
+++ b/src/test/run-make/symbol-visibility/Makefile
@@ -9,17 +9,17 @@ all:
 else
 
 NM=nm -D
-DYLIB_EXT=so
 CDYLIB_NAME=liba_cdylib.so
 RDYLIB_NAME=liba_rust_dylib.so
 EXE_NAME=an_executable
+COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.so
 
 ifeq ($(UNAME),Darwin)
 NM=nm -gU
-DYLIB_EXT=dylib
 CDYLIB_NAME=liba_cdylib.dylib
 RDYLIB_NAME=liba_rust_dylib.dylib
 EXE_NAME=an_executable
+COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.dylib
 endif
 
 all:
@@ -27,6 +27,7 @@ all:
 	$(RUSTC) a_cdylib.rs
 	$(RUSTC) a_rust_dylib.rs
 	$(RUSTC) an_executable.rs
+	$(RUSTC) a_cdylib.rs --crate-name combined_rlib_dylib --crate-type=rlib,cdylib
 
 	# Check that a cdylib exports its public #[no_mangle] functions
 	[ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ]
@@ -47,4 +48,13 @@ all:
 	[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ]
 	[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_rust_function_from_exe)" -eq "0" ]
 
+
+	# Check the combined case, where we generate a cdylib and an rlib in the same
+	# compilation session:
+	# Check that a cdylib exports its public #[no_mangle] functions
+	[ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ]
+	# Check that a cdylib exports the public #[no_mangle] functions of dependencies
+	[ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
+	# Check that a cdylib DOES NOT export any public Rust functions
+	[ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c _ZN.*h.*E)" -eq "0" ]
 endif