Skip to content

Commit

Permalink
Rollup merge of rust-lang#74009 - mati865:mingw-tests-implib, r=nikom…
Browse files Browse the repository at this point in the history
…atsakis

Fix MinGW `run-make-fulldeps` tests

`compiler-rt-works-on-mingw` and `libs-search-path` were not ran because `only-mingw` doesn't match any target.
Enabled and verified few ignored tests with `windows-gnu` toolchain. They are still ignored on MSVC since I'm not experienced with this target.
  • Loading branch information
Manishearth committed Jul 16, 2020
2 parents 599a77d + 17bc07d commit 9d59c05
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-include ../tools.mk

# only-mingw
# only-windows-gnu

all:
$(CXX) foo.cpp -c -o $(TMPDIR)/foo.o
Expand Down
4 changes: 0 additions & 4 deletions src/test/run-make-fulldeps/include_bytes_deps/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
-include ../tools.mk

# ignore-windows
# ignore-freebsd
# FIXME: on windows `rustc --dep-info` produces Makefile dependency with
# windows native paths (e.g. `c:\path\to\libfoo.a`)
# but msys make seems to fail to recognize such paths, so test fails.

all:
$(RUSTC) --emit dep-info main.rs
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-make-fulldeps/intrinsic-unreachable/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-include ../tools.mk

# ignore-windows
# ignore-windows-msvc
#
# Because of Windows exception handling, the code is not necessarily any shorter.
# https://github.com/llvm-mirror/llvm/commit/64b2297786f7fd6f5fa24cdd4db0298fbf211466
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-make-fulldeps/issue-51671/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-include ../tools.mk

# ignore-windows
# ignore-windows-msvc

all:
$(RUSTC) --emit=obj app.rs
Expand Down
10 changes: 0 additions & 10 deletions src/test/run-make-fulldeps/libs-search-path/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion src/test/run-make-fulldeps/libs-search-path/empty.rs

This file was deleted.

6 changes: 1 addition & 5 deletions src/test/run-make-fulldeps/redundant-libs/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
-include ../tools.mk

ifdef IS_WINDOWS
all:
else
# ignore-windows-msvc

# rustc will remove one of the two redundant references to foo below. Depending
# on which one gets removed, we'll get a linker error on SOME platforms (like
Expand All @@ -23,5 +21,3 @@ RUSTC_FLAGS = \
all: $(call DYLIB,foo) $(call STATICLIB,bar) $(call STATICLIB,baz)
$(RUSTC) $(RUSTC_FLAGS) main.rs
$(call RUN,main)

endif
63 changes: 34 additions & 29 deletions src/test/run-make-fulldeps/symbol-visibility/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
include ../tools.mk

# ignore-windows
#
# On MINGW the --version-script, --dynamic-list, and --retain-symbol args don't
# seem to work reliably.
# ignore-windows-msvc

NM=nm -D
CDYLIB_NAME=liba_cdylib.so
Expand All @@ -19,6 +16,14 @@ EXE_NAME=an_executable
COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.dylib
endif

ifdef IS_WINDOWS
NM=nm -g
CDYLIB_NAME=liba_cdylib.dll.a
RDYLIB_NAME=liba_rust_dylib.dll.a
EXE_NAME=an_executable.exe
COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.dll.a
endif

# `grep` regex for symbols produced by either `legacy` or `v0` mangling
RE_ANY_RUST_SYMBOL="_ZN.*h.*E\|_R[a-zA-Z0-9_]+"

Expand All @@ -30,38 +35,38 @@ all:
$(RUSTC) -Zshare-generics=no a_cdylib.rs --crate-name combined_rlib_dylib --crate-type=rlib,cdylib

# Check that a cdylib exports its public #[no_mangle] functions
[ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v _imp__ | grep -c public_c_function_from_cdylib)" -eq "1" ]
# Check that a cdylib exports the public #[no_mangle] functions of dependencies
[ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v _imp__ | grep -c public_c_function_from_rlib)" -eq "1" ]
# Check that a cdylib DOES NOT export any public Rust functions
[ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
[ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v _imp__ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]

# Check that a Rust dylib exports its monomorphic functions
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rust_dylib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rust_dylib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v _imp__ | grep -c public_c_function_from_rust_dylib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v _imp__ | grep -c public_rust_function_from_rust_dylib)" -eq "1" ]
# Check that a Rust dylib does not export generics if -Zshare-generics=no
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rust_dylib)" -eq "0" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v _imp__ | grep -c public_generic_function_from_rust_dylib)" -eq "0" ]


# Check that a Rust dylib exports the monomorphic functions from its dependencies
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rlib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v _imp__ | grep -c public_c_function_from_rlib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v _imp__ | grep -c public_rust_function_from_rlib)" -eq "1" ]
# Check that a Rust dylib does not export generics if -Zshare-generics=no
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rlib)" -eq "0" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v _imp__ | grep -c public_generic_function_from_rlib)" -eq "0" ]

# Check that an executable does not export any dynamic symbols
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ]
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_rust_function_from_exe)" -eq "0" ]
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v _imp__ | grep -c public_c_function_from_rlib)" -eq "0" ]
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v _imp__ | grep -c public_rust_function_from_exe)" -eq "0" ]


# Check the combined case, where we generate a cdylib and an rlib in the same
# compilation session:
# Check that a cdylib exports its public #[no_mangle] functions
[ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -v _imp__ | grep -c public_c_function_from_cdylib)" -eq "1" ]
# Check that a cdylib exports the public #[no_mangle] functions of dependencies
[ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -v _imp__ | grep -c public_c_function_from_rlib)" -eq "1" ]
# Check that a cdylib DOES NOT export any public Rust functions
[ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
[ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -v _imp__ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]


$(RUSTC) -Zshare-generics=yes an_rlib.rs
Expand All @@ -70,22 +75,22 @@ all:
$(RUSTC) -Zshare-generics=yes an_executable.rs

# Check that a cdylib exports its public #[no_mangle] functions
[ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v _imp__ | grep -c public_c_function_from_cdylib)" -eq "1" ]
# Check that a cdylib exports the public #[no_mangle] functions of dependencies
[ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v _imp__ | grep -c public_c_function_from_rlib)" -eq "1" ]
# Check that a cdylib DOES NOT export any public Rust functions
[ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]
[ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -v _imp__ | grep -c $(RE_ANY_RUST_SYMBOL))" -eq "0" ]

# Check that a Rust dylib exports its monomorphic functions, including generics this time
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rust_dylib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rust_dylib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rust_dylib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v _imp__ | grep -c public_c_function_from_rust_dylib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v _imp__ | grep -c public_rust_function_from_rust_dylib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v _imp__ | grep -c public_generic_function_from_rust_dylib)" -eq "1" ]

# Check that a Rust dylib exports the monomorphic functions from its dependencies
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rlib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_generic_function_from_rlib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v _imp__ | grep -c public_c_function_from_rlib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v _imp__ | grep -c public_rust_function_from_rlib)" -eq "1" ]
[ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -v _imp__ | grep -c public_generic_function_from_rlib)" -eq "1" ]

# Check that an executable does not export any dynamic symbols
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ]
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_rust_function_from_exe)" -eq "0" ]
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v _imp__ | grep -c public_c_function_from_rlib)" -eq "0" ]
[ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -v _imp__ | grep -c public_rust_function_from_exe)" -eq "0" ]
2 changes: 1 addition & 1 deletion src/test/run-make-fulldeps/tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ ifdef IS_MSVC
$(CC) $< -link -dll -out:`cygpath -w $@`
else
%.dll: lib%.o
$(CC) -o $@ $< -shared
$(CC) -o $@ $< -shared -Wl,--out-implib=$@.a
endif

$(TMPDIR)/lib%.o: %.c
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-make-fulldeps/used/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-include ../tools.mk

# ignore-windows
# ignore-windows-msvc

all:
$(RUSTC) -C opt-level=3 --emit=obj used.rs
Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@ impl Config {
&self.target == name || // triple
util::matches_os(&self.target, name) || // target
util::matches_env(&self.target, name) || // env
self.target.ends_with(name) || // target and env
name == util::get_arch(&self.target) || // architecture
name == util::get_pointer_width(&self.target) || // pointer width
name == self.stage_id.split('-').next().unwrap() || // stage
Expand Down

0 comments on commit 9d59c05

Please sign in to comment.