Skip to content

Commit 9f15237

Browse files
committed
Attempt to fix tools.mk under cross-compile
1 parent 0fc9523 commit 9f15237

File tree

1 file changed

+68
-57
lines changed

1 file changed

+68
-57
lines changed

mk/tools.mk

Lines changed: 68 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ RUSTI_INPUTS := $(wildcard $(S)src/librusti/*.rs)
2222

2323
# FIXME: These are only built for the host arch. Eventually we'll
2424
# have tools that need to built for other targets.
25-
define TOOLS_STAGE_N
25+
define TOOLS_STAGE_N_TARGET
2626

2727
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBFUZZER): \
2828
$$(FUZZER_LIB) $$(FUZZER_INPUTS) \
@@ -39,6 +39,64 @@ $$(TBIN$(1)_T_$(4)_H_$(3))/fuzzer$$(X): \
3939
@$$(call E, compile_and_link: $$@)
4040
$$(STAGE$(1)_T_$(4)_H_$(3)) --cfg fuzzer -o $$@ $$<
4141

42+
$$(TBIN$(1)_T_$(4)_H_$(3))/compiletest$$(X): \
43+
$$(COMPILETEST_CRATE) $$(COMPILETEST_INPUTS) \
44+
$$(TSREQ$(1)_T_$(4)_H_$(3)) \
45+
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_CORELIB) \
46+
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB)
47+
@$$(call E, compile_and_link: $$@)
48+
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$<
49+
50+
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBCARGO): \
51+
$$(CARGO_LIB) $$(CARGO_INPUTS) \
52+
$$(TSREQ$(1)_T_$(4)_H_$(3)) \
53+
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_CORELIB) \
54+
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB) \
55+
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTC)
56+
@$$(call E, compile_and_link: $$@)
57+
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< && touch $$@
58+
59+
$$(TBIN$(1)_T_$(4)_H_$(3))/cargo$$(X): \
60+
$$(DRIVER_CRATE) \
61+
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBCARGO)
62+
@$$(call E, compile_and_link: $$@)
63+
$$(STAGE$(1)_T_$(4)_H_$(3)) --cfg cargo -o $$@ $$<
64+
65+
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTDOC): \
66+
$$(RUSTDOC_LIB) $$(RUSTDOC_INPUTS) \
67+
$$(TSREQ$(1)_T_$(4)_H_$(3)) \
68+
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_CORELIB) \
69+
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB) \
70+
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTC)
71+
@$$(call E, compile_and_link: $$@)
72+
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< && touch $$@
73+
74+
$$(TBIN$(1)_T_$(4)_H_$(3))/rustdoc$$(X): \
75+
$$(DRIVER_CRATE) \
76+
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTDOC)
77+
@$$(call E, compile_and_link: $$@)
78+
$$(STAGE$(1)_T_$(4)_H_$(3)) --cfg rustdoc -o $$@ $$<
79+
80+
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTI): \
81+
$$(RUSTI_LIB) $$(RUSTI_INPUTS) \
82+
$$(TSREQ$(1)_T_$(4)_H_$(3)) \
83+
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_CORELIB) \
84+
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB) \
85+
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTC)
86+
@$$(call E, compile_and_link: $$@)
87+
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< && touch $$@
88+
89+
$$(TBIN$(1)_T_$(4)_H_$(3))/rusti$$(X): \
90+
$$(DRIVER_CRATE) \
91+
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTI)
92+
@$$(call E, compile_and_link: $$@)
93+
$$(STAGE$(1)_T_$(4)_H_$(3)) --cfg rusti -o $$@ $$<
94+
95+
endef
96+
97+
define TOOLS_STAGE_N_HOST
98+
99+
42100
# Promote the stageN target to stageN+1 host
43101
# FIXME: Shouldn't need to depend on host/librustc.so once
44102
# rpath is working
@@ -59,34 +117,12 @@ $$(HBIN$(2)_H_$(4))/fuzzer$$(X): \
59117
@$$(call E, cp: $$@)
60118
$$(Q)cp $$< $$@
61119

62-
$$(TBIN$(1)_T_$(4)_H_$(3))/compiletest$$(X): \
63-
$$(COMPILETEST_CRATE) $$(COMPILETEST_INPUTS) \
64-
$$(TSREQ$(1)_T_$(4)_H_$(3)) \
65-
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_CORELIB) \
66-
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB)
67-
@$$(call E, compile_and_link: $$@)
68-
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$<
69-
70120
$$(HBIN$(2)_H_$(4))/compiletest$$(X): \
71121
$$(TBIN$(1)_T_$(4)_H_$(3))/compiletest$$(X) \
72122
$$(HSREQ$(2)_H_$(4))
73123
@$$(call E, cp: $$@)
74124
$$(Q)cp $$< $$@
75125

76-
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBCARGO): \
77-
$$(CARGO_LIB) $$(CARGO_INPUTS) \
78-
$$(TSREQ$(1)_T_$(4)_H_$(3)) \
79-
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_CORELIB) \
80-
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB) \
81-
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTC)
82-
@$$(call E, compile_and_link: $$@)
83-
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< && touch $$@
84-
85-
$$(TBIN$(1)_T_$(4)_H_$(3))/cargo$$(X): \
86-
$$(DRIVER_CRATE) \
87-
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBCARGO)
88-
@$$(call E, compile_and_link: $$@)
89-
$$(STAGE$(1)_T_$(4)_H_$(3)) --cfg cargo -o $$@ $$<
90126

91127
$$(HLIB$(2)_H_$(4))/$$(CFG_LIBCARGO): \
92128
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBCARGO) \
@@ -105,21 +141,6 @@ $$(HBIN$(2)_H_$(4))/cargo$$(X): \
105141
@$$(call E, cp: $$@)
106142
$$(Q)cp $$< $$@
107143

108-
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTDOC): \
109-
$$(RUSTDOC_LIB) $$(RUSTDOC_INPUTS) \
110-
$$(TSREQ$(1)_T_$(4)_H_$(3)) \
111-
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_CORELIB) \
112-
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB) \
113-
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTC)
114-
@$$(call E, compile_and_link: $$@)
115-
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< && touch $$@
116-
117-
$$(TBIN$(1)_T_$(4)_H_$(3))/rustdoc$$(X): \
118-
$$(DRIVER_CRATE) \
119-
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTDOC)
120-
@$$(call E, compile_and_link: $$@)
121-
$$(STAGE$(1)_T_$(4)_H_$(3)) --cfg rustdoc -o $$@ $$<
122-
123144
$$(HLIB$(2)_H_$(4))/$$(CFG_LIBRUSTDOC): \
124145
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTDOC) \
125146
$$(HLIB$(2)_H_$(4))/$$(CFG_LIBRUSTC) \
@@ -137,21 +158,6 @@ $$(HBIN$(2)_H_$(4))/rustdoc$$(X): \
137158
@$$(call E, cp: $$@)
138159
$$(Q)cp $$< $$@
139160

140-
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTI): \
141-
$$(RUSTI_LIB) $$(RUSTI_INPUTS) \
142-
$$(TSREQ$(1)_T_$(4)_H_$(3)) \
143-
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_CORELIB) \
144-
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_STDLIB) \
145-
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTC)
146-
@$$(call E, compile_and_link: $$@)
147-
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< && touch $$@
148-
149-
$$(TBIN$(1)_T_$(4)_H_$(3))/rusti$$(X): \
150-
$$(DRIVER_CRATE) \
151-
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTI)
152-
@$$(call E, compile_and_link: $$@)
153-
$$(STAGE$(1)_T_$(4)_H_$(3)) --cfg rusti -o $$@ $$<
154-
155161
$$(HLIB$(2)_H_$(4))/$$(CFG_LIBRUSTI): \
156162
$$(TLIB$(1)_T_$(4)_H_$(3))/$$(CFG_LIBRUSTI) \
157163
$$(HLIB$(2)_H_$(4))/$$(CFG_LIBRUSTC) \
@@ -169,10 +175,15 @@ $$(HBIN$(2)_H_$(4))/rusti$$(X): \
169175
@$$(call E, cp: $$@)
170176
$$(Q)cp $$< $$@
171177

172-
173178
endef
174179

175180
$(foreach host,$(CFG_TARGET_TRIPLES), \
176-
$(eval $(call TOOLS_STAGE_N,0,1,$(host),$(host))) \
177-
$(eval $(call TOOLS_STAGE_N,1,2,$(host),$(host))) \
178-
$(eval $(call TOOLS_STAGE_N,2,3,$(host),$(host))))
181+
$(foreach target,$(CFG_TARGET_TRIPLES), \
182+
$(eval $(call TOOLS_STAGE_N_TARGET,0,1,$(target),$(host))) \
183+
$(eval $(call TOOLS_STAGE_N_TARGET,1,2,$(target),$(host))) \
184+
$(eval $(call TOOLS_STAGE_N_TARGET,2,3,$(target),$(host)))))
185+
186+
$(foreach host,$(CFG_TARGET_TRIPLES), \
187+
$(eval $(call TOOLS_STAGE_N_HOST,0,1,$(host),$(host))) \
188+
$(eval $(call TOOLS_STAGE_N_HOST,1,2,$(host),$(host))) \
189+
$(eval $(call TOOLS_STAGE_N_HOST,2,3,$(host),$(host))))

0 commit comments

Comments
 (0)