@@ -23,11 +23,11 @@ COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.dylib
23
23
endif
24
24
25
25
all :
26
- $(RUSTC ) an_rlib.rs
27
- $(RUSTC ) a_cdylib.rs
28
- $(RUSTC ) a_rust_dylib.rs
29
- $(RUSTC ) an_executable.rs
30
- $(RUSTC ) a_cdylib.rs --crate-name combined_rlib_dylib --crate-type=rlib,cdylib
26
+ $(RUSTC ) -Zshare-generics=no an_rlib.rs
27
+ $(RUSTC ) -Zshare-generics=no a_cdylib.rs
28
+ $(RUSTC ) -Zshare-generics=no a_rust_dylib.rs
29
+ $(RUSTC ) -Zshare-generics=no an_executable.rs
30
+ $(RUSTC ) -Zshare-generics=no a_cdylib.rs --crate-name combined_rlib_dylib --crate-type=rlib,cdylib
31
31
32
32
# Check that a cdylib exports its public #[no_mangle] functions
33
33
[ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ]
39
39
# Check that a Rust dylib exports its monomorphic functions
40
40
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rust_dylib)" -eq "1" ]
41
41
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c _ZN.*public_rust_function_from_rust_dylib.*E)" -eq "1" ]
42
+ # Check that a Rust dylib does not export generics if -Zshare-generics=no
43
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c _ZN.*public_generic_function_from_rust_dylib.*E)" -eq "0" ]
44
+
42
45
43
46
# Check that a Rust dylib exports the monomorphic functions from its dependencies
44
47
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
45
48
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rlib)" -eq "1" ]
49
+ # Check that a Rust dylib does not export generics if -Zshare-generics=no
50
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c _ZN.*public_generic_function_from_rlib.*E)" -eq "0" ]
46
51
47
52
# Check that an executable does not export any dynamic symbols
48
53
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ]
49
54
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_rust_function_from_exe)" -eq "0" ]
55
+ [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c _ZN.*h.*E)" -eq "0" ]
50
56
51
57
52
58
# Check the combined case, where we generate a cdylib and an rlib in the same
57
63
[ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
58
64
# Check that a cdylib DOES NOT export any public Rust functions
59
65
[ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c _ZN.*h.*E)" -eq "0" ]
66
+
67
+
68
+ $(RUSTC) -Zshare-generics=yes an_rlib.rs
69
+ $(RUSTC) -Zshare-generics=yes a_cdylib.rs
70
+ $(RUSTC) -Zshare-generics=yes a_rust_dylib.rs
71
+ $(RUSTC) -Zshare-generics=yes an_executable.rs
72
+
73
+ # Check that a cdylib exports its public #[no_mangle] functions
74
+ [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ]
75
+ # Check that a cdylib exports the public #[no_mangle] functions of dependencies
76
+ [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
77
+ # Check that a cdylib DOES NOT export any public Rust functions
78
+ [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c _ZN.*h.*E)" -eq "0" ]
79
+
80
+ # Check that a Rust dylib exports its monomorphic functions, including generics this time
81
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rust_dylib)" -eq "1" ]
82
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c _ZN.*public_rust_function_from_rust_dylib.*E)" -eq "1" ]
83
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c _ZN.*public_generic_function_from_rust_dylib.*E)" -eq "1" ]
84
+
85
+ # Check that a Rust dylib exports the monomorphic functions from its dependencies
86
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
87
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rlib)" -eq "1" ]
88
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c _ZN.*public_generic_function_from_rlib.*E)" -eq "1" ]
89
+
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" ]
92
+ [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_rust_function_from_exe)" -eq "0" ]
93
+ [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c _ZN.*h.*E)" -eq "0" ]
60
94
endif
0 commit comments