Skip to content

Commit 4e55bc7

Browse files
committed
auto merge of #13795 : klutzy/rust/win-make-check, r=alexcrichton
Fixes #12303. Also contains a partial fix for `make check` failure.
2 parents ff25d62 + 405861e commit 4e55bc7

File tree

15 files changed

+131
-22
lines changed

15 files changed

+131
-22
lines changed

src/etc/maketest.py

+37-10
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,53 @@
1212
import os
1313
import sys
1414

15-
# FIXME #12303 these tests are broken on windows
16-
if os.name == 'nt':
17-
print 'ignoring make tests on windows'
18-
sys.exit(0)
15+
# msys1/msys2 automatically converts `/abs/path1:/abs/path2` into
16+
# `c:\real\abs\path1;c:\real\abs\path2` (semicolons) if shell thinks
17+
# the value is list of paths.
18+
# this causes great confusion and error: shell and Makefile doesn't like
19+
# windows paths so it is really error-prone. revert it for peace.
20+
def normalize_path(v):
21+
# c:\path -> /c/path
22+
if ':\\' in v:
23+
v = '/' + v.replace(':\\', '/')
24+
v = v.replace('\\', '/')
25+
return v
26+
27+
28+
def putenv(name, value):
29+
if os.name == 'nt':
30+
value = normalize_path(value)
31+
os.putenv(name, value)
32+
1933

2034
make = sys.argv[2]
21-
os.putenv('RUSTC', os.path.abspath(sys.argv[3]))
22-
os.putenv('TMPDIR', os.path.abspath(sys.argv[4]))
23-
os.putenv('CC', sys.argv[5])
24-
os.putenv('RUSTDOC', os.path.abspath(sys.argv[6]))
35+
putenv('RUSTC', os.path.abspath(sys.argv[3]))
36+
putenv('TMPDIR', os.path.abspath(sys.argv[4]))
37+
putenv('CC', sys.argv[5])
38+
putenv('RUSTDOC', os.path.abspath(sys.argv[6]))
2539
filt = sys.argv[7]
2640
ldpath = sys.argv[8]
2741
if ldpath != '':
28-
os.putenv(ldpath.split('=')[0], ldpath.split('=')[1])
42+
name = ldpath.split('=')[0]
43+
value = ldpath.split('=')[1]
44+
if os.name == 'nt' and name != 'PATH':
45+
value = ":".join(normalize_path(v) for v in value.split(";"))
46+
os.putenv(name, value)
2947

3048
if not filt in sys.argv[1]:
3149
sys.exit(0)
3250
print('maketest: ' + os.path.basename(os.path.dirname(sys.argv[1])))
3351

34-
proc = subprocess.Popen([make, '-C', sys.argv[1]],
52+
path = sys.argv[1]
53+
if path[-1] == '/':
54+
# msys1 has a bug that `make` fails to include `../tools.mk` (parent dir)
55+
# if `-C path` option is given and `path` is absolute directory with
56+
# trailing slash (`c:/path/to/test/`).
57+
# the easist workaround is to remove the slash (`c:/path/to/test`).
58+
# msys2 seems to fix this problem.
59+
path = path[:-1]
60+
61+
proc = subprocess.Popen([make, '-C', path],
3562
stdout = subprocess.PIPE,
3663
stderr = subprocess.PIPE)
3764
out, err = proc.communicate()

src/test/run-make/c-link-to-rust-staticlib/Makefile

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

3+
ifndef IS_WINDOWS
34
ifneq ($(shell uname),Darwin)
45
EXTRAFLAGS := -lm -lrt -ldl -lpthread
56
endif
7+
endif
68

7-
# FIXME
9+
# FIXME: ignore freebsd
810
ifneq ($(shell uname),FreeBSD)
911
all:
1012
$(RUSTC) foo.rs

src/test/run-make/dep-info-custom/Makefile

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

3-
# FIXME
3+
# FIXME: ignore freebsd/windows
4+
# (windows: see `../dep-info/Makefile`)
45
ifneq ($(shell uname),FreeBSD)
6+
ifndef IS_WINDOWS
57
all:
68
$(RUSTC) --dep-info $(TMPDIR)/custom-deps-file.d --crate-type=lib lib.rs
79
sleep 1
@@ -16,3 +18,8 @@ else
1618
all:
1719

1820
endif
21+
22+
else
23+
all:
24+
25+
endif

src/test/run-make/dep-info/Makefile

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

3+
# FIXME: ignore freebsd/windows
4+
# on windows `rustc --dep-info` produces Makefile dependency with
5+
# windows native paths (e.g. `c:\path\to\libfoo.a`)
6+
# but msys make seems to fail to recognize such paths, so test fails.
37
ifneq ($(shell uname),FreeBSD)
8+
ifndef IS_WINDOWS
49
all:
510
$(RUSTC) --dep-info --crate-type=lib lib.rs
611
sleep 2
@@ -16,3 +21,8 @@ else
1621
all:
1722

1823
endif
24+
25+
else
26+
all:
27+
28+
endif

src/test/run-make/lto-smoke-c/Makefile

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

3+
ifdef IS_WINDOWS
4+
EXTRAFLAGS :=
5+
else
36
ifeq ($(shell uname),Darwin)
47
else
58
ifeq ($(shell uname),FreeBSD)
@@ -8,6 +11,7 @@ else
811
EXTRAFLAGS := -lm -lrt -ldl -lpthread
912
endif
1013
endif
14+
endif
1115

1216
# Apparently older versions of GCC segfault if -g is passed...
1317
CC := $(CC:-g=)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// FIXME #13793
12+
#[test]
13+
fn test_dummy() {
14+
}

src/test/run-make/obey-crate-type-flag/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# fail if an rlib was built
88
all:
99
$(RUSTC) test.rs
10-
rm $(TMPDIR)/libtest*.rlib
11-
rm $(TMPDIR)/libtest*
10+
rm $(TMPDIR)/$(call RLIB_GLOB,test)
11+
rm $(TMPDIR)/$(call DYLIB_GLOB,test)
1212
$(RUSTC) --crate-type dylib test.rs
13-
rm $(TMPDIR)/libtest*.rlib && exit 1 || exit 0
13+
rm $(TMPDIR)/$(call RLIB_GLOB,test) && exit 1 || exit 0

src/test/run-make/output-type-permutations/Makefile

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ all:
66
rm $(TMPDIR)/$(call DYLIB_GLOB,bar)
77
rm $(TMPDIR)/$(call STATICLIB_GLOB,bar)
88
$(RUSTC) foo.rs --crate-type=bin
9-
rm $(TMPDIR)/bar
9+
rm $(TMPDIR)/$(call BIN,bar)
1010
$(RUSTC) foo.rs --emit=asm,ir,bc,obj,link
1111
rm $(TMPDIR)/bar.ll
1212
rm $(TMPDIR)/bar.bc
1313
rm $(TMPDIR)/bar.s
1414
rm $(TMPDIR)/bar.o
15-
rm $(TMPDIR)/bar
15+
rm $(TMPDIR)/$(call BIN,bar)
1616
$(RUSTC) foo.rs --emit=asm,ir,bc,obj,link --crate-type=staticlib
1717
rm $(TMPDIR)/bar.ll
1818
rm $(TMPDIR)/bar.s
@@ -27,15 +27,15 @@ all:
2727
$(RUSTC) foo.rs --emit=obj -o $(TMPDIR)/foo
2828
rm $(TMPDIR)/foo
2929
$(RUSTC) foo.rs --emit=link -o $(TMPDIR)/foo
30-
rm $(TMPDIR)/foo
30+
rm $(TMPDIR)/$(call BIN,foo)
3131
$(RUSTC) foo.rs --crate-type=rlib -o $(TMPDIR)/foo
3232
rm $(TMPDIR)/foo
3333
$(RUSTC) foo.rs --crate-type=dylib -o $(TMPDIR)/foo
34-
rm $(TMPDIR)/foo
34+
rm $(TMPDIR)/$(call BIN,foo) # FIXME 13794
3535
$(RUSTC) foo.rs --crate-type=staticlib -o $(TMPDIR)/foo
3636
rm $(TMPDIR)/foo
3737
$(RUSTC) foo.rs --crate-type=bin -o $(TMPDIR)/foo
38-
rm $(TMPDIR)/foo
38+
rm $(TMPDIR)/$(call BIN,foo)
3939
mv $(TMPDIR)/bar.bc $(TMPDIR)/foo.bc
4040
$(RUSTC) foo.rs --emit=bc,link --crate-type=rlib
4141
cmp $(TMPDIR)/foo.bc $(TMPDIR)/bar.bc
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
-include ../tools.mk
2+
ifdef IS_WINDOWS
3+
# ignore windows
4+
RUSTC_FLAGS =
5+
else
26
# Notice the space in the end, this emulates the output of pkg-config
37
RUSTC_FLAGS = -C link-args="-lc "
8+
endif
49

510
all:
611
$(RUSTC) $(RUSTC_FLAGS) empty.rs
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
-include ../tools.mk
22

3+
# FIXME ignore windows
4+
ifndef IS_WINDOWS
5+
36
all:
47
$(RUSTDOC) --test foo.rs
58
$(RUSTDOC) -w html -o $(TMPDIR)/doc foo.rs
69
cp verify.sh $(TMPDIR)
710
$(call RUN,verify.sh) $(TMPDIR)
11+
12+
else
13+
all:
14+
15+
endif
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
-include ../tools.mk
22

3+
# ignore windows: `ln` is actually `cp` on msys.
4+
ifndef IS_WINDOWS
5+
36
all:
47
$(RUSTC) foo.rs
58
mkdir -p $(TMPDIR)/other
69
ln -nsf $(TMPDIR)/$(call DYLIB_GLOB,foo) $(TMPDIR)/other
710
$(RUSTC) bar.rs -L $(TMPDIR)/other
11+
12+
else
13+
all:
14+
15+
endif

src/test/run-make/tools.mk

+17-1
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,37 @@ FAILS = $(TMPDIR)/$(1) && exit 1 || exit 0
1010
RLIB_GLOB = lib$(1)*.rlib
1111
STATICLIB = $(TMPDIR)/lib$(1).a
1212
STATICLIB_GLOB = lib$(1)*.a
13+
BIN = $(1)
1314

14-
ifeq ($(shell uname),Darwin)
15+
UNAME = $(shell uname)
16+
ifneq (,$(findstring MINGW,$(UNAME)))
17+
IS_WINDOWS=1
18+
endif
19+
20+
ifeq ($(UNAME),Darwin)
1521
DYLIB_GLOB = lib$(1)*.dylib
1622
DYLIB = $(TMPDIR)/lib$(1).dylib
1723
else
24+
ifdef IS_WINDOWS
25+
DYLIB_GLOB = $(1)*.dll
26+
DYLIB = $(TMPDIR)/$(1).dll
27+
BIN = $(1).exe
28+
export PATH := $(PATH):$(LD_LIBRARY_PATH)
29+
else
1830
DYLIB_GLOB = lib$(1)*.so
1931
DYLIB = $(TMPDIR)/lib$(1).so
2032
endif
33+
endif
2134

2235
%.a: %.o
2336
ar crus $@ $<
2437
%.dylib: %.o
2538
$(CC) -dynamiclib -Wl,-dylib -o $@ $<
2639
%.so: %.o
2740
$(CC) -o $@ $< -shared
41+
%.dll: lib%.o
42+
$(CC) -o $@ $< -shared
43+
2844
$(TMPDIR)/lib%.o: %.c
2945
$(CC) -c -o $@ $<
3046

src/test/run-make/unicode-input/Makefile

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

3+
# FIXME ignore windows
4+
ifndef IS_WINDOWS
5+
36
all:
47
# check that we don't ICE on unicode input, issue #11178
58
$(RUSTC) multiple_files.rs
@@ -9,3 +12,8 @@ all:
912
# correct length. issue #8706
1013
$(RUSTC) span_length.rs
1114
$(call RUN,span_length) "$(RUSTC)" "$(TMPDIR)"
15+
16+
else
17+
all:
18+
19+
endif

src/test/run-make/weird-output-filenames/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ all:
66
$(RUSTC) foo.rs -o $(TMPDIR)/.foo.bar
77
rm $(TMPDIR)/.foo.bar
88
$(RUSTC) foo.rs -o $(TMPDIR)/+foo+bar
9-
rm $(TMPDIR)/+foo+bar
9+
rm $(TMPDIR)/$(call BIN,+foo+bar)

0 commit comments

Comments
 (0)