@@ -5,13 +5,15 @@ include ../tools.mk
5
5
NM =nm -D
6
6
CDYLIB_NAME =liba_cdylib.so
7
7
RDYLIB_NAME =liba_rust_dylib.so
8
+ PROC_MACRO_NAME =liba_proc_macro.so
8
9
EXE_NAME =an_executable
9
10
COMBINED_CDYLIB_NAME =libcombined_rlib_dylib.so
10
11
11
12
ifeq ($(UNAME ) ,Darwin)
12
13
NM =nm -gU
13
14
CDYLIB_NAME =liba_cdylib.dylib
14
15
RDYLIB_NAME =liba_rust_dylib.dylib
16
+ PROC_MACRO_NAME =liba_proc_macro.dylib
15
17
EXE_NAME =an_executable
16
18
COMBINED_CDYLIB_NAME =libcombined_rlib_dylib.dylib
17
19
endif
@@ -20,6 +22,7 @@ ifdef IS_WINDOWS
20
22
NM =nm -g
21
23
CDYLIB_NAME =liba_cdylib.dll.a
22
24
RDYLIB_NAME =liba_rust_dylib.dll.a
25
+ PROC_MACRO_NAME =liba_proc_macro.dll
23
26
EXE_NAME =an_executable.exe
24
27
COMBINED_CDYLIB_NAME =libcombined_rlib_dylib.dll.a
25
28
endif
31
34
$(RUSTC ) -Zshare-generics=no an_rlib.rs
32
35
$(RUSTC ) -Zshare-generics=no a_cdylib.rs
33
36
$(RUSTC ) -Zshare-generics=no a_rust_dylib.rs
37
+ $(RUSTC ) -Zshare-generics=no a_proc_macro.rs
34
38
$(RUSTC ) -Zshare-generics=no an_executable.rs
35
39
$(RUSTC ) -Zshare-generics=no a_cdylib.rs --crate-name combined_rlib_dylib --crate-type=rlib,cdylib
36
40
54
58
# Check that a Rust dylib does not export generics if -Zshare-generics=no
55
59
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_generic_function_from_rlib)" -eq "0" ]
56
60
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
+
57
69
# FIXME(nbdd0121): This is broken in MinGW, see https://github.com/rust-lang/rust/pull/95604#issuecomment-1101564032
58
70
ifndef IS_WINDOWS
59
71
# Check that an executable does not export any dynamic symbols
75
87
$(RUSTC) -Zshare-generics=yes an_rlib.rs
76
88
$(RUSTC) -Zshare-generics=yes a_cdylib.rs
77
89
$(RUSTC) -Zshare-generics=yes a_rust_dylib.rs
90
+ $(RUSTC) -Zshare-generics=yes a_proc_macro.rs
78
91
$(RUSTC) -Zshare-generics=yes an_executable.rs
79
92
80
93
# Check that a cdylib exports its public #[no_mangle] functions
@@ -94,6 +107,14 @@ endif
94
107
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_rust_function_from_rlib)" -eq "1" ]
95
108
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep -c public_generic_function_from_rlib)" -eq "1" ]
96
109
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
+
97
118
ifndef IS_WINDOWS
98
119
# Check that an executable does not export any dynamic symbols
99
120
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep -c public_c_function_from_rlib)" -eq "0" ]
0 commit comments