@@ -5,13 +5,15 @@ include ../tools.mk
55NM =nm -D
66CDYLIB_NAME =liba_cdylib.so
77RDYLIB_NAME =liba_rust_dylib.so
8+ PROC_MACRO_NAME =liba_proc_macro.so
89EXE_NAME =an_executable
910COMBINED_CDYLIB_NAME =libcombined_rlib_dylib.so
1011
1112ifeq ($(UNAME ) ,Darwin)
1213NM =nm -gU
1314CDYLIB_NAME =liba_cdylib.dylib
1415RDYLIB_NAME =liba_rust_dylib.dylib
16+ PROC_MACRO_NAME =liba_proc_macro.dylib
1517EXE_NAME =an_executable
1618COMBINED_CDYLIB_NAME =libcombined_rlib_dylib.dylib
1719endif
@@ -20,6 +22,7 @@ ifdef IS_WINDOWS
2022NM =nm -g
2123CDYLIB_NAME =liba_cdylib.dll.a
2224RDYLIB_NAME =liba_rust_dylib.dll.a
25+ PROC_MACRO_NAME =liba_proc_macro.dll
2326EXE_NAME =an_executable.exe
2427COMBINED_CDYLIB_NAME =libcombined_rlib_dylib.dll.a
2528endif
3134 $(RUSTC ) -Zshare-generics=no an_rlib.rs
3235 $(RUSTC ) -Zshare-generics=no a_cdylib.rs
3336 $(RUSTC ) -Zshare-generics=no a_rust_dylib.rs
37+ $(RUSTC ) -Zshare-generics=no a_proc_macro.rs
3438 $(RUSTC ) -Zshare-generics=no an_executable.rs
3539 $(RUSTC ) -Zshare-generics=no a_cdylib.rs --crate-name combined_rlib_dylib --crate-type=rlib,cdylib
3640
5458 # Check that a Rust dylib does not export generics if -Zshare-generics=no
5559 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_generic_function_from_rlib)" -eq "0" ]
5660
61+ # Check that a proc macro exports its public #[no_mangle] functions
62+ # FIXME(#99978) avoid exporting #[no_mangle] symbols for proc macros
63+ [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_cdylib)" -eq "1" ]
64+ # Check that a proc macro exports the public #[no_mangle] functions of dependencies
65+ [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ]
66+ # Check that a proc macro DOES NOT export any public Rust functions
67+ [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
68+
5769# FIXME(nbdd0121): This is broken in MinGW, see https://github.com/rust-lang/rust/pull/95604#issuecomment-1101564032
5870ifndef IS_WINDOWS
5971 # Check that an executable does not export any dynamic symbols
7587 $(RUSTC) -Zshare-generics=yes an_rlib.rs
7688 $(RUSTC) -Zshare-generics=yes a_cdylib.rs
7789 $(RUSTC) -Zshare-generics=yes a_rust_dylib.rs
90+ $(RUSTC) -Zshare-generics=yes a_proc_macro.rs
7891 $(RUSTC) -Zshare-generics=yes an_executable.rs
7992
8093 # Check that a cdylib exports its public #[no_mangle] functions
@@ -94,6 +107,14 @@ endif
94107 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_rust_function_from_rlib)" -eq "1" ]
95108 [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_generic_function_from_rlib)" -eq "1" ]
96109
110+ # Check that a proc macro exports its public #[no_mangle] functions
111+ # FIXME(#99978) avoid exporting #[no_mangle] symbols for proc macros
112+ [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_cdylib)" -eq "1" ]
113+ # Check that a proc macro exports the public #[no_mangle] functions of dependencies
114+ [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "1" ]
115+ # Check that a proc macro DOES NOT export any public Rust functions
116+ [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
117+
97118ifndef IS_WINDOWS
98119 # Check that an executable does not export any dynamic symbols
99120 [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "0" ]
0 commit comments