Skip to content

Commit 43cc6d4

Browse files
Fix passing CC to maketest.py when CC has arguments.
rmake: Get all tests passing on MSVC (thanks Alex!). For example, I configure with CC="ccache /usr/lib/icecc/bin/gcc".
1 parent c443b27 commit 43cc6d4

File tree

34 files changed

+149
-77
lines changed

34 files changed

+149
-77
lines changed

mk/tests.mk

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,10 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),rmake): \
10461046
$$(RMAKE_TESTS:%=$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok)
10471047
@touch $$@
10481048

1049+
$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
1050+
export INCLUDE := $$(CFG_MSVC_INCLUDE_PATH_$$(HOST_$(3)))
1051+
$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
1052+
export LIB := $$(CFG_MSVC_LIB_PATH_$$(HOST_$(3)))
10491053
$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
10501054
$(S)src/test/run-make/%/Makefile \
10511055
$$(CSREQ$(1)_T_$(2)_H_$(3))
@@ -1056,15 +1060,16 @@ $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
10561060
$$(MAKE) \
10571061
$$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
10581062
$(3)/test/run-make/$$* \
1059-
"$$(CC_$(3))" \
1063+
'$$(CC_$(3))' \
10601064
"$$(CFG_GCCISH_CFLAGS_$(3))" \
10611065
$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
10621066
"$$(TESTNAME)" \
10631067
$$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3)) \
10641068
"$$(LD_LIBRARY_PATH_ENV_HOSTDIR$(1)_T_$(2)_H_$(3))" \
10651069
"$$(LD_LIBRARY_PATH_ENV_TARGETDIR$(1)_T_$(2)_H_$(3))" \
10661070
$(1) \
1067-
$$(S)
1071+
$$(S) \
1072+
$(3)
10681073
@touch -r $$@.start_time $$@ && rm $$@.start_time
10691074
else
10701075
# FIXME #11094 - The above rule doesn't work right for multiple targets

src/etc/maketest.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import os
1313
import sys
1414

15+
target_triple = sys.argv[14]
1516

1617
def normalize_path(v):
1718
"""msys1/msys2 automatically converts `/abs/path1:/abs/path2` into
@@ -22,8 +23,11 @@ def normalize_path(v):
2223
windows paths so it is really error-prone. revert it for peace."""
2324
v = v.replace('\\', '/')
2425
# c:/path -> /c/path
25-
if ':/' in v:
26-
v = '/' + v.replace(':/', '/')
26+
# "c:/path" -> "/c/path"
27+
start = v.find(':/')
28+
while start != -1:
29+
v = v[:start - 1] + '/' + v[start - 1:start] + v[start + 1:]
30+
start = v.find(':/')
2731
return v
2832

2933

@@ -50,6 +54,10 @@ def convert_path_spec(name, value):
5054
putenv('RUST_BUILD_STAGE', sys.argv[12])
5155
putenv('S', os.path.abspath(sys.argv[13]))
5256
putenv('PYTHON', sys.executable)
57+
os.putenv('TARGET', target_triple)
58+
59+
if 'msvc' in target_triple:
60+
os.putenv('IS_MSVC', '1')
5361

5462
if filt not in sys.argv[1]:
5563
sys.exit(0)

src/test/run-make/archive-duplicate-names/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
all:
44
mkdir $(TMPDIR)/a
55
mkdir $(TMPDIR)/b
6-
$(CC) -c -o $(TMPDIR)/a/foo.o foo.c
7-
$(CC) -c -o $(TMPDIR)/b/foo.o bar.c
6+
$(call COMPILE_OBJ,$(TMPDIR)/a/foo.o,foo.c)
7+
$(call COMPILE_OBJ,$(TMPDIR)/b/foo.o,bar.c)
88
ar crus $(TMPDIR)/libfoo.a $(TMPDIR)/a/foo.o $(TMPDIR)/b/foo.o
99
$(RUSTC) foo.rs
1010
$(RUSTC) bar.rs
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
// ignore-license
2+
#ifdef _WIN32
3+
__declspec(dllexport)
4+
#endif
25
int foo() { return 0; }
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
// ignore-license
2+
3+
#ifdef _WIN32
4+
__declspec(dllexport)
5+
#endif
26
int foo() { return 0; }
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
-include ../tools.mk
22

3-
HOST_LIB_DIR=$(TMPDIR)/../../../stage$(RUST_BUILD_STAGE)/lib
4-
5-
all:
6-
$(RUSTC) foo.rs
7-
$(CC) bar.c -lfoo -o $(call RUN_BINFILE,bar) $(call RPATH_LINK_SEARCH,$(HOST_LIB_DIR)) -Wl,-rpath,$(TMPDIR) $(EXTRACFLAGS)
3+
all: $(TMPDIR)/$(call BIN,bar)
84
$(call RUN,bar)
95
$(call REMOVE_DYLIBS,foo)
106
$(call FAIL,bar)
7+
8+
ifdef IS_MSVC
9+
$(TMPDIR)/$(call BIN,bar): $(call DYLIB,foo)
10+
$(CC) bar.c $(TMPDIR)/foo.lib $(call OUT_EXE,bar)
11+
else
12+
$(TMPDIR)/$(call BIN,bar): $(call DYLIB,foo)
13+
$(CC) bar.c -lfoo -o $(call RUN_BINFILE,bar) -L $(TMPDIR)
14+
endif
15+
16+
$(call DYLIB,foo): foo.rs
17+
$(RUSTC) foo.rs

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
-include ../tools.mk
22

3-
EXTRAFLAGS := $(EXTRACFLAGS)
4-
53
# FIXME: ignore freebsd
64
ifneq ($(shell uname),FreeBSD)
75
all:
86
$(RUSTC) foo.rs
9-
$(CC) bar.c -lfoo -o $(call RUN_BINFILE,bar) $(EXTRAFLAGS) $(EXTRACXXFLAGS)
7+
$(CC) bar.c $(TMPDIR)/libfoo.a $(call OUT_EXE,bar) \
8+
$(EXTRACFLAGS) $(EXTRACXXFLAGS)
109
$(call RUN,bar)
1110
rm $(call STATICLIB,foo*)
1211
$(call RUN,bar)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
-include ../tools.mk
22

3-
all: $(call STATICLIB,cfoo)
3+
all: $(call NATIVE_STATICLIB,cfoo)
44
$(RUSTC) foo.rs -C prefer-dynamic
55
$(RUSTC) bar.rs
6-
rm $(TMPDIR)/$(call STATICLIB_GLOB,cfoo)
6+
rm $(call NATIVE_STATICLIB,cfoo)
77
$(call RUN,bar)
88
$(call REMOVE_DYLIBS,foo)
99
$(call FAIL,bar)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
-include ../tools.mk
22

3-
all: $(call STATICLIB,cfoo)
3+
all: $(call NATIVE_STATICLIB,cfoo)
44
$(RUSTC) foo.rs
55
$(RUSTC) bar.rs
66
$(call REMOVE_RLIBS,foo)
7-
rm $(TMPDIR)/$(call STATICLIB_GLOB,cfoo)
7+
rm $(call NATIVE_STATICLIB,cfoo)
88
$(call RUN,bar)

src/test/run-make/crate-name-priority/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ all:
77
rm $(TMPDIR)/$(call BIN,bar)
88
$(RUSTC) foo1.rs
99
rm $(TMPDIR)/$(call BIN,foo)
10-
$(RUSTC) foo1.rs -o $(TMPDIR)/bar1
10+
$(RUSTC) foo1.rs -o $(TMPDIR)/$(call BIN,bar1)
1111
rm $(TMPDIR)/$(call BIN,bar1)

0 commit comments

Comments
 (0)