@@ -19,6 +19,9 @@ EXE_NAME=an_executable
1919COMBINED_CDYLIB_NAME =libcombined_rlib_dylib.dylib
2020endif
2121
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+
2225all :
2326 $(RUSTC ) -Zshare-generics=no an_rlib.rs
2427 $(RUSTC ) -Zshare-generics=no a_cdylib.rs
3134 # Check that a cdylib exports the public #[no_mangle] functions of dependencies
3235 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
3336 # 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" ]
3538
3639 # Check that a Rust dylib exports its monomorphic functions
3740 [ "$$($(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" ]
3942 # 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" ]
4144
4245
4346 # Check that a Rust dylib exports the monomorphic functions from its dependencies
4447 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
4548 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rlib)" -eq "1" ]
4649 # 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" ]
4851
4952 # Check that an executable does not export any dynamic symbols
5053 [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ]
5861 # Check that a cdylib exports the public #[no_mangle] functions of dependencies
5962 [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
6063 # 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" ]
6265
6366
6467 $(RUSTC) -Zshare-generics=yes an_rlib.rs
7174 # Check that a cdylib exports the public #[no_mangle] functions of dependencies
7275 [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
7376 # 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" ]
7578
7679 # Check that a Rust dylib exports its monomorphic functions, including generics this time
7780 [ "$$($(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" ]
8083
8184 # Check that a Rust dylib exports the monomorphic functions from its dependencies
8285 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
8386 [ "$$($(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" ]
8588
8689 # Check that an executable does not export any dynamic symbols
8790 [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ]
0 commit comments