|
1 | 1 | include ../tools.mk
|
2 | 2 |
|
| 3 | +ifdef IS_WINDOWS |
| 4 | +# Do nothing on MSVC. |
| 5 | +# On MINGW the --version-script, --dynamic-list, and --retain-symbol args don't |
| 6 | +# seem to work reliably. |
| 7 | +all: |
| 8 | + exit 0 |
| 9 | +else |
| 10 | + |
| 11 | +NM=nm -D |
| 12 | +DYLIB_EXT=so |
| 13 | +CDYLIB_NAME=liba_cdylib.so |
| 14 | +RDYLIB_NAME=liba_rust_dylib.so |
| 15 | +EXE_NAME=an_executable |
| 16 | + |
| 17 | +ifeq ($(UNAME),Darwin) |
| 18 | +NM=nm -gU |
| 19 | +DYLIB_EXT=dylib |
| 20 | +CDYLIB_NAME=liba_cdylib.dylib |
| 21 | +RDYLIB_NAME=liba_rust_dylib.dylib |
| 22 | +EXE_NAME=an_executable |
| 23 | +endif |
| 24 | + |
3 | 25 | all:
|
4 | 26 | $(RUSTC) an_rlib.rs
|
5 | 27 | $(RUSTC) a_cdylib.rs
|
6 | 28 | $(RUSTC) a_rust_dylib.rs
|
7 | 29 | $(RUSTC) an_executable.rs
|
8 | 30 |
|
9 | 31 | # Check that a cdylib exports its public #[no_mangle] functions
|
10 |
| - [ "$$(nm -D $(TMPDIR)/liba_cdylib.so | grep -c public_c_function_from_cdylib)" -eq "1" ] |
| 32 | + [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ] |
11 | 33 | # Check that a cdylib exports the public #[no_mangle] functions of dependencies
|
12 |
| - [ "$$(nm -D $(TMPDIR)/liba_cdylib.so | grep -c public_c_function_from_rlib)" -eq "1" ] |
| 34 | + [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ] |
13 | 35 | # Check that a cdylib DOES NOT export any public Rust functions
|
14 |
| - [ "$$(nm -D $(TMPDIR)/liba_cdylib.so | grep -c _ZN.*h.*E)" -eq "0" ] |
| 36 | + [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c _ZN.*h.*E)" -eq "0" ] |
15 | 37 |
|
16 | 38 | # Check that a Rust dylib exports its monomorphic functions
|
17 |
| - [ "$$(nm -D $(TMPDIR)/liba_rust_dylib.so | grep -c public_c_function_from_rust_dylib)" -eq "1" ] |
18 |
| - [ "$$(nm -D $(TMPDIR)/liba_rust_dylib.so | grep -c _ZN.*public_rust_function_from_rust_dylib.*E)" -eq "1" ] |
| 39 | + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rust_dylib)" -eq "1" ] |
| 40 | + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c _ZN.*public_rust_function_from_rust_dylib.*E)" -eq "1" ] |
19 | 41 |
|
20 | 42 | # Check that a Rust dylib exports the monomorphic functions from its dependencies
|
21 |
| - [ "$$(nm -D $(TMPDIR)/liba_rust_dylib.so | grep -c public_c_function_from_rlib)" -eq "1" ] |
22 |
| - [ "$$(nm -D $(TMPDIR)/liba_rust_dylib.so | grep -c public_rust_function_from_rlib)" -eq "1" ] |
| 43 | + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ] |
| 44 | + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rlib)" -eq "1" ] |
23 | 45 |
|
24 | 46 | # Check that an executable does not export any dynamic symbols
|
25 |
| - [ "$$(nm -D $(TMPDIR)/an_executable | grep -c public_c_function_from_rlib)" -eq "0" ] |
26 |
| - [ "$$(nm -D $(TMPDIR)/an_executable | grep -c public_rust_function_from_exe)" -eq "0" ] |
| 47 | + [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ] |
| 48 | + [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_rust_function_from_exe)" -eq "0" ] |
| 49 | + |
| 50 | +endif |
0 commit comments