Skip to content

Commit be3b972

Browse files
authored
Rollup merge of #74009 - mati865:mingw-tests-implib, r=nikomatsakis
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.
2 parents f6cd31c + af1d01e commit be3b972

File tree

11 files changed

+41
-54
lines changed

11 files changed

+41
-54
lines changed

src/test/run-make-fulldeps/compiler-rt-works-on-mingw/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-include ../tools.mk
22

3-
# only-mingw
3+
# only-windows-gnu
44

55
all:
66
$(CXX) foo.cpp -c -o $(TMPDIR)/foo.o

src/test/run-make-fulldeps/include_bytes_deps/Makefile

-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
-include ../tools.mk
22

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

95
all:
106
$(RUSTC) --emit dep-info main.rs

src/test/run-make-fulldeps/intrinsic-unreachable/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-include ../tools.mk
22

3-
# ignore-windows
3+
# ignore-windows-msvc
44
#
55
# Because of Windows exception handling, the code is not necessarily any shorter.
66
# https://github.com/llvm-mirror/llvm/commit/64b2297786f7fd6f5fa24cdd4db0298fbf211466

src/test/run-make-fulldeps/issue-51671/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-include ../tools.mk
22

3-
# ignore-windows
3+
# ignore-windows-msvc
44

55
all:
66
$(RUSTC) --emit=obj app.rs

src/test/run-make-fulldeps/libs-search-path/Makefile

-10
This file was deleted.

src/test/run-make-fulldeps/libs-search-path/empty.rs

-1
This file was deleted.

src/test/run-make-fulldeps/redundant-libs/Makefile

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
-include ../tools.mk
22

3-
ifdef IS_WINDOWS
4-
all:
5-
else
3+
# ignore-windows-msvc
64

75
# rustc will remove one of the two redundant references to foo below. Depending
86
# on which one gets removed, we'll get a linker error on SOME platforms (like
@@ -23,5 +21,3 @@ RUSTC_FLAGS = \
2321
all: $(call DYLIB,foo) $(call STATICLIB,bar) $(call STATICLIB,baz)
2422
$(RUSTC) $(RUSTC_FLAGS) main.rs
2523
$(call RUN,main)
26-
27-
endif
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
include ../tools.mk
22

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
74

85
NM=nm -D
96
CDYLIB_NAME=liba_cdylib.so
@@ -19,6 +16,14 @@ EXE_NAME=an_executable
1916
COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.dylib
2017
endif
2118

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+
2227
# `grep` regex for symbols produced by either `legacy` or `v0` mangling
2328
RE_ANY_RUST_SYMBOL="_ZN.*h.*E\|_R[a-zA-Z0-9_]+"
2429

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

3237
# 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" ]
3439
# 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" ]
3641
# 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" ]
3843

3944
# 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" ]
4247
# 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" ]
4449

4550

4651
# 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" ]
4954
# 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" ]
5156

5257
# 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" ]
5560

5661

5762
# Check the combined case, where we generate a cdylib and an rlib in the same
5863
# compilation session:
5964
# 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" ]
6166
# 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" ]
6368
# 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" ]
6570

6671

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

7277
# 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" ]
7479
# 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" ]
7681
# 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" ]
7883

7984
# 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" ]
8388

8489
# 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" ]
8893

8994
# 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" ]

src/test/run-make-fulldeps/tools.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ ifdef IS_MSVC
150150
$(CC) $< -link -dll -out:`cygpath -w $@`
151151
else
152152
%.dll: lib%.o
153-
$(CC) -o $@ $< -shared
153+
$(CC) -o $@ $< -shared -Wl,--out-implib=$@.a
154154
endif
155155

156156
$(TMPDIR)/lib%.o: %.c

src/test/run-make-fulldeps/used/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-include ../tools.mk
22

3-
# ignore-windows
3+
# ignore-windows-msvc
44

55
all:
66
$(RUSTC) -C opt-level=3 --emit=obj used.rs

src/tools/compiletest/src/header.rs

+1
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,7 @@ impl Config {
867867
&self.target == name || // triple
868868
util::matches_os(&self.target, name) || // target
869869
util::matches_env(&self.target, name) || // env
870+
self.target.ends_with(name) || // target and env
870871
name == util::get_arch(&self.target) || // architecture
871872
name == util::get_pointer_width(&self.target) || // pointer width
872873
name == self.stage_id.split('-').next().unwrap() || // stage

0 commit comments

Comments
 (0)