1
1
include ../tools.mk
2
2
3
- # ignore-windows
4
- #
5
- # On MINGW the --version-script, --dynamic-list, and --retain-symbol args don't
6
- # seem to work reliably.
3
+ # ignore-windows-msvc
7
4
8
5
NM =nm -D
9
6
CDYLIB_NAME =liba_cdylib.so
@@ -19,6 +16,14 @@ EXE_NAME=an_executable
19
16
COMBINED_CDYLIB_NAME =libcombined_rlib_dylib.dylib
20
17
endif
21
18
19
+ ifdef IS_WINDOWS
20
+ NM =nm -g
21
+ CDYLIB_NAME =liba_cdylib.dll.a
22
+ RDYLIB_NAME =liba_rust_dylib.dll.a
23
+ EXE_NAME =an_executable.exe
24
+ COMBINED_CDYLIB_NAME =libcombined_rlib_dylib.dll.a
25
+ endif
26
+
22
27
# `grep` regex for symbols produced by either `legacy` or `v0` mangling
23
28
RE_ANY_RUST_SYMBOL ="_ZN.*h.*E\|_R[a-zA-Z0-9_]+"
24
29
30
35
$(RUSTC ) -Zshare-generics=no a_cdylib.rs --crate-name combined_rlib_dylib --crate-type=rlib,cdylib
31
36
32
37
# Check that a cdylib exports its public #[no_mangle] functions
33
- [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ]
38
+ [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep - c public_c_function_from_cdylib)" -eq "1" ]
34
39
# Check that a cdylib exports the public #[no_mangle] functions of dependencies
35
- [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
40
+ [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep - c public_c_function_from_rlib)" -eq "1" ]
36
41
# Check that a cdylib DOES NOT export any public Rust functions
37
- [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
42
+ [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep - c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
38
43
39
44
# Check that a Rust dylib exports its monomorphic functions
40
- [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rust_dylib)" -eq "1" ]
41
- [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rust_dylib)" -eq "1" ]
45
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep - c public_c_function_from_rust_dylib)" -eq "1" ]
46
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep - c public_rust_function_from_rust_dylib)" -eq "1" ]
42
47
# Check that a Rust dylib does not export generics if -Zshare-generics=no
43
- [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rust_dylib)" -eq "0" ]
48
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep - c public_generic_function_from_rust_dylib)" -eq "0" ]
44
49
45
50
46
51
# Check that a Rust dylib exports the monomorphic functions from its dependencies
47
- [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
48
- [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rlib)" -eq "1" ]
52
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep - c public_c_function_from_rlib)" -eq "1" ]
53
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep - c public_rust_function_from_rlib)" -eq "1" ]
49
54
# Check that a Rust dylib does not export generics if -Zshare-generics=no
50
- [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rlib)" -eq "0" ]
55
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep - c public_generic_function_from_rlib)" -eq "0" ]
51
56
52
57
# Check that an executable does not export any dynamic symbols
53
- [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ]
54
- [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_rust_function_from_exe)" -eq "0" ]
58
+ [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep - c public_c_function_from_rlib)" -eq "0" ]
59
+ [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep - c public_rust_function_from_exe)" -eq "0" ]
55
60
56
61
57
62
# Check the combined case, where we generate a cdylib and an rlib in the same
58
63
# compilation session:
59
64
# Check that a cdylib exports its public #[no_mangle] functions
60
- [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ]
65
+ [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -v __imp_ | grep - c public_c_function_from_cdylib)" -eq "1" ]
61
66
# Check that a cdylib exports the public #[no_mangle] functions of dependencies
62
- [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
67
+ [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -v __imp_ | grep - c public_c_function_from_rlib)" -eq "1" ]
63
68
# Check that a cdylib DOES NOT export any public Rust functions
64
- [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
69
+ [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -v __imp_ | grep - c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
65
70
66
71
67
72
$(RUSTC) -Zshare-generics=yes an_rlib.rs
70
75
$(RUSTC) -Zshare-generics=yes an_executable.rs
71
76
72
77
# Check that a cdylib exports its public #[no_mangle] functions
73
- [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ]
78
+ [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep - c public_c_function_from_cdylib)" -eq "1" ]
74
79
# Check that a cdylib exports the public #[no_mangle] functions of dependencies
75
- [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
80
+ [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep - c public_c_function_from_rlib)" -eq "1" ]
76
81
# Check that a cdylib DOES NOT export any public Rust functions
77
- [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
82
+ [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v __imp_ | grep - c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
78
83
79
84
# Check that a Rust dylib exports its monomorphic functions, including generics this time
80
- [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rust_dylib)" -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" ]
85
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep - c public_c_function_from_rust_dylib)" -eq "1" ]
86
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep - c public_rust_function_from_rust_dylib)" -eq "1" ]
87
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep - c public_generic_function_from_rust_dylib)" -eq "1" ]
83
88
84
89
# Check that a Rust dylib exports the monomorphic functions from its dependencies
85
- [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
86
- [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rlib)" -eq "1" ]
87
- [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rlib)" -eq "1" ]
90
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep - c public_c_function_from_rlib)" -eq "1" ]
91
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep - c public_rust_function_from_rlib)" -eq "1" ]
92
+ [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v __imp_ | grep - c public_generic_function_from_rlib)" -eq "1" ]
88
93
89
94
# Check that an executable does not export any dynamic symbols
90
- [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ]
91
- [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_rust_function_from_exe)" -eq "0" ]
95
+ [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep - c public_c_function_from_rlib)" -eq "0" ]
96
+ [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v __imp_ | grep - c public_rust_function_from_exe)" -eq "0" ]
0 commit comments