From 48fe5fcbb86f6f5809a82e9cb9116c8ecd264666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 13 Jun 2020 14:18:02 +0200 Subject: [PATCH 1/4] Create implib for dlls when testing MinGW targets --- src/test/run-make-fulldeps/tools.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/run-make-fulldeps/tools.mk b/src/test/run-make-fulldeps/tools.mk index 04bf78ed210..1effa46e101 100644 --- a/src/test/run-make-fulldeps/tools.mk +++ b/src/test/run-make-fulldeps/tools.mk @@ -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 From 2a9b51dcc48ae0215c963b03147e9bac39a49a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 3 Jul 2020 20:18:51 +0200 Subject: [PATCH 2/4] Allow matching test by target and env --- src/tools/compiletest/src/header.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 571e7a59113..d6e28e93c96 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -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 From 933a06d8a3eb24260f88bd408586044fc3592cee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 3 Jul 2020 20:40:00 +0200 Subject: [PATCH 3/4] Remove invalid test When ran on Windows `cp` will follow symlink: `checkout/build///lib/rustlib/src/rust`. It points to `checkout` which means the test will get stuck in copying loop until there is no space left. --- src/test/run-make-fulldeps/libs-search-path/Makefile | 10 ---------- src/test/run-make-fulldeps/libs-search-path/empty.rs | 1 - 2 files changed, 11 deletions(-) delete mode 100644 src/test/run-make-fulldeps/libs-search-path/Makefile delete mode 100644 src/test/run-make-fulldeps/libs-search-path/empty.rs diff --git a/src/test/run-make-fulldeps/libs-search-path/Makefile b/src/test/run-make-fulldeps/libs-search-path/Makefile deleted file mode 100644 index f31036ffa19..00000000000 --- a/src/test/run-make-fulldeps/libs-search-path/Makefile +++ /dev/null @@ -1,10 +0,0 @@ --include ../tools.mk - -# only-mingw - -all: empty.rs - cp -r $(shell cygpath -u $(shell $(RUSTC) --print sysroot)) $(TMPDIR)/sysroot - $(RUSTC) --target $(TARGET) --sysroot $(TMPDIR)/sysroot -L$(TMPDIR)/obj -Z print-link-args empty.rs | $(CGREP) 'lib\\crt2.o' - mkdir -p $(TMPDIR)/obj - mv $(TMPDIR)/sysroot/lib/rustlib/$(TARGET)/lib/crt2.o $(TMPDIR)/obj/crt2.o - $(RUSTC) --target $(TARGET) --sysroot $(TMPDIR)/sysroot -L$(TMPDIR)/obj -Z print-link-args empty.rs | $(CGREP) 'obj\\crt2.o' diff --git a/src/test/run-make-fulldeps/libs-search-path/empty.rs b/src/test/run-make-fulldeps/libs-search-path/empty.rs deleted file mode 100644 index f328e4d9d04..00000000000 --- a/src/test/run-make-fulldeps/libs-search-path/empty.rs +++ /dev/null @@ -1 +0,0 @@ -fn main() {} From af1d01ebb3ad442aabeaaba7dc77912f539e0555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 3 Jul 2020 20:55:13 +0200 Subject: [PATCH 4/4] Fix various tests to run on windows-gnu --- .../compiler-rt-works-on-mingw/Makefile | 2 +- .../include_bytes_deps/Makefile | 4 -- .../intrinsic-unreachable/Makefile | 2 +- .../run-make-fulldeps/issue-51671/Makefile | 2 +- .../run-make-fulldeps/redundant-libs/Makefile | 6 +- .../symbol-visibility/Makefile | 63 ++++++++++--------- src/test/run-make-fulldeps/used/Makefile | 2 +- 7 files changed, 39 insertions(+), 42 deletions(-) diff --git a/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/Makefile b/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/Makefile index d7d078e56b2..0cf5d185521 100644 --- a/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/Makefile +++ b/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/Makefile @@ -1,6 +1,6 @@ -include ../tools.mk -# only-mingw +# only-windows-gnu all: $(CXX) foo.cpp -c -o $(TMPDIR)/foo.o diff --git a/src/test/run-make-fulldeps/include_bytes_deps/Makefile b/src/test/run-make-fulldeps/include_bytes_deps/Makefile index ce79cec67dc..f91af88efe1 100644 --- a/src/test/run-make-fulldeps/include_bytes_deps/Makefile +++ b/src/test/run-make-fulldeps/include_bytes_deps/Makefile @@ -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 diff --git a/src/test/run-make-fulldeps/intrinsic-unreachable/Makefile b/src/test/run-make-fulldeps/intrinsic-unreachable/Makefile index 483091ad4ee..2037728568e 100644 --- a/src/test/run-make-fulldeps/intrinsic-unreachable/Makefile +++ b/src/test/run-make-fulldeps/intrinsic-unreachable/Makefile @@ -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 diff --git a/src/test/run-make-fulldeps/issue-51671/Makefile b/src/test/run-make-fulldeps/issue-51671/Makefile index 3027ee578c7..ba3d3b71007 100644 --- a/src/test/run-make-fulldeps/issue-51671/Makefile +++ b/src/test/run-make-fulldeps/issue-51671/Makefile @@ -1,6 +1,6 @@ -include ../tools.mk -# ignore-windows +# ignore-windows-msvc all: $(RUSTC) --emit=obj app.rs diff --git a/src/test/run-make-fulldeps/redundant-libs/Makefile b/src/test/run-make-fulldeps/redundant-libs/Makefile index 9486e07d21b..8468d102bec 100644 --- a/src/test/run-make-fulldeps/redundant-libs/Makefile +++ b/src/test/run-make-fulldeps/redundant-libs/Makefile @@ -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 @@ -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 diff --git a/src/test/run-make-fulldeps/symbol-visibility/Makefile b/src/test/run-make-fulldeps/symbol-visibility/Makefile index 7901866015b..dc55c947d89 100644 --- a/src/test/run-make-fulldeps/symbol-visibility/Makefile +++ b/src/test/run-make-fulldeps/symbol-visibility/Makefile @@ -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 @@ -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_]+" @@ -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 @@ -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" ] diff --git a/src/test/run-make-fulldeps/used/Makefile b/src/test/run-make-fulldeps/used/Makefile index 8d913e39935..4d904472931 100644 --- a/src/test/run-make-fulldeps/used/Makefile +++ b/src/test/run-make-fulldeps/used/Makefile @@ -1,6 +1,6 @@ -include ../tools.mk -# ignore-windows +# ignore-windows-msvc all: $(RUSTC) -C opt-level=3 --emit=obj used.rs