Skip to content

Commit 8ecdc4e

Browse files
Make symbol-visibility test case work on all platforms.
1 parent 3548c8f commit 8ecdc4e

File tree

1 file changed

+33
-9
lines changed
  • src/test/run-make/symbol-visibility

1 file changed

+33
-9
lines changed
+33-9
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,50 @@
11
include ../tools.mk
22

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+
325
all:
426
$(RUSTC) an_rlib.rs
527
$(RUSTC) a_cdylib.rs
628
$(RUSTC) a_rust_dylib.rs
729
$(RUSTC) an_executable.rs
830

931
# 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" ]
1133
# 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" ]
1335
# 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" ]
1537

1638
# 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" ]
1941

2042
# 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" ]
2345

2446
# 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

Comments
 (0)