@@ -19,6 +19,9 @@ EXE_NAME=an_executable
19
19
COMBINED_CDYLIB_NAME =libcombined_rlib_dylib.dylib
20
20
endif
21
21
22
+ # `grep` regex for symbols produced by either `legacy` or `v0` mangling
23
+ RE_ANY_RUST_SYMBOL ="_ZN.*h.*E\|_R[a-zA-Z0-9_]+"
24
+
22
25
all :
23
26
$(RUSTC ) -Zshare-generics=no an_rlib.rs
24
27
$(RUSTC ) -Zshare-generics=no a_cdylib.rs
31
34
# Check that a cdylib exports the public #[no_mangle] functions of dependencies
32
35
[ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
33
36
# Check that a cdylib DOES NOT export any public Rust functions
34
- [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c _ZN.*h.*E )" -eq "0" ]
37
+ [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c $(RE_ANY_RUST_SYMBOL) )" -eq "0" ]
35
38
36
39
# Check that a Rust dylib exports its monomorphic functions
37
40
[ "$$($(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" ]
41
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rust_dylib)" -eq "1" ]
39
42
# 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
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rust_dylib)" -eq "0" ]
41
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" ]
46
49
# 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" ]
50
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rlib)" -eq "0" ]
48
51
49
52
# Check that an executable does not export any dynamic symbols
50
53
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ]
58
61
# Check that a cdylib exports the public #[no_mangle] functions of dependencies
59
62
[ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
60
63
# 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
+ [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c $(RE_ANY_RUST_SYMBOL) )" -eq "0" ]
62
65
63
66
64
67
$(RUSTC) -Zshare-generics=yes an_rlib.rs
71
74
# Check that a cdylib exports the public #[no_mangle] functions of dependencies
72
75
[ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
73
76
# Check that a cdylib DOES NOT export any public Rust functions
74
- [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c _ZN.*h.*E )" -eq "0" ]
77
+ [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c $(RE_ANY_RUST_SYMBOL) )" -eq "0" ]
75
78
76
79
# Check that a Rust dylib exports its monomorphic functions, including generics this time
77
80
[ "$$($(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
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rust_dylib)" -eq "1" ]
82
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rust_dylib)" -eq "1" ]
80
83
81
84
# Check that a Rust dylib exports the monomorphic functions from its dependencies
82
85
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
83
86
[ "$$($(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" ]
87
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rlib)" -eq "1" ]
85
88
86
89
# Check that an executable does not export any dynamic symbols
87
90
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ]
0 commit comments