5 # On MINGW the --version-script, --dynamic-list, and --retain-symbol args don't
6 # seem to work reliably.
9 CDYLIB_NAME=liba_cdylib.so
10 RDYLIB_NAME=liba_rust_dylib.so
11 EXE_NAME=an_executable
12 COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.so
14 ifeq ($(UNAME),Darwin)
16 CDYLIB_NAME=liba_cdylib.dylib
17 RDYLIB_NAME=liba_rust_dylib.dylib
18 EXE_NAME=an_executable
19 COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.dylib
23 $(RUSTC) -Zshare-generics=no an_rlib.rs
24 $(RUSTC) -Zshare-generics=no a_cdylib.rs
25 $(RUSTC) -Zshare-generics=no a_rust_dylib.rs
26 $(RUSTC) -Zshare-generics=no an_executable.rs
27 $(RUSTC) -Zshare-generics=no a_cdylib.rs --crate-name combined_rlib_dylib --crate-type=rlib,cdylib
29 # Check that a cdylib exports its public #[no_mangle] functions
30 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ]
31 # Check that a cdylib exports the public #[no_mangle] functions of dependencies
32 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
33 # Check that a cdylib DOES NOT export any public Rust functions
34 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c _ZN.*h.*E)" -eq "0" ]
36 # Check that a Rust dylib exports its monomorphic functions
37 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rust_dylib)" -eq "1" ]
38 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c _ZN.*public_rust_function_from_rust_dylib.*E)" -eq "1" ]
39 # Check that a Rust dylib does not export generics if -Zshare-generics=no
40 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c _ZN.*public_generic_function_from_rust_dylib.*E)" -eq "0" ]
43 # Check that a Rust dylib exports the monomorphic functions from its dependencies
44 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
45 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rlib)" -eq "1" ]
46 # Check that a Rust dylib does not export generics if -Zshare-generics=no
47 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c _ZN.*public_generic_function_from_rlib.*E)" -eq "0" ]
49 # Check that an executable does not export any dynamic symbols
50 [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ]
51 [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_rust_function_from_exe)" -eq "0" ]
54 # Check the combined case, where we generate a cdylib and an rlib in the same
55 # compilation session:
56 # Check that a cdylib exports its public #[no_mangle] functions
57 [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ]
58 # Check that a cdylib exports the public #[no_mangle] functions of dependencies
59 [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
60 # Check that a cdylib DOES NOT export any public Rust functions
61 [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c _ZN.*h.*E)" -eq "0" ]
64 $(RUSTC) -Zshare-generics=yes an_rlib.rs
65 $(RUSTC) -Zshare-generics=yes a_cdylib.rs
66 $(RUSTC) -Zshare-generics=yes a_rust_dylib.rs
67 $(RUSTC) -Zshare-generics=yes an_executable.rs
69 # Check that a cdylib exports its public #[no_mangle] functions
70 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ]
71 # Check that a cdylib exports the public #[no_mangle] functions of dependencies
72 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
73 # Check that a cdylib DOES NOT export any public Rust functions
74 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c _ZN.*h.*E)" -eq "0" ]
76 # Check that a Rust dylib exports its monomorphic functions, including generics this time
77 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rust_dylib)" -eq "1" ]
78 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c _ZN.*public_rust_function_from_rust_dylib.*E)" -eq "1" ]
79 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c _ZN.*public_generic_function_from_rust_dylib.*E)" -eq "1" ]
81 # Check that a Rust dylib exports the monomorphic functions from its dependencies
82 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
83 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rlib)" -eq "1" ]
84 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c _ZN.*public_generic_function_from_rlib.*E)" -eq "1" ]
86 # Check that an executable does not export any dynamic symbols
87 [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ]
88 [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_rust_function_from_exe)" -eq "0" ]