1 # TARGET_STAGE_N template: This defines how target artifacts are built
2 # for all stage/target architecture combinations. The arguments:
4 # $(2) is the target triple
5 # $(3) is the host triple
7 # If you are making non-backwards compatible changes to the runtime
8 # (resp. corelib), set this flag to 1. It will cause stage1 to use
9 # the snapshot runtime (resp. corelib) rather than the runtime
10 # (resp. corelib) from the working directory.
11 USE_SNAPSHOT_RUNTIME=0
12 USE_SNAPSHOT_CORELIB=0
17 $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a: \
18 rt/$(2)/arch/$$(HOST_$(2))/libmorestack.a
22 $$(TLIB$(1)_T_$(2)_H_$(3))/liblinenoise.a: \
23 linenoise/$(2)/liblinenoise.a
27 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUSTLLVM): \
28 rustllvm/$(2)/$$(CFG_RUSTLLVM)
32 $$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X): \
34 $$(TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3))
35 @$$(call E, compile_and_link: $$@)
36 $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$<
37 ifdef CFG_ENABLE_PAX_FLAGS
38 @$$(call E, apply PaX flags: $$@)
39 @"$(CFG_PAXCTL)" -cm "$$@"
42 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC): \
43 $$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
44 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX)
45 @$$(call E, compile_and_link: $$@)
46 $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< && touch $$@
48 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX): \
49 $$(LIBSYNTAX_CRATE) $$(LIBSYNTAX_INPUTS) \
50 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
51 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUSTLLVM) \
52 $$(TCORELIB_DEFAULT$(1)_T_$(2)_H_$(3)) \
53 $$(TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3))
54 @$$(call E, compile_and_link: $$@)
55 $$(STAGE$(1)_T_$(2)_H_$(3)) $(BORROWCK) -o $$@ $$< && touch $$@
59 # The stage0 (snapshot) compiler produces binaries that expect the
60 # snapshot runtime. Normally the working directory runtime and
61 # snapshot runtime are compatible, so this is no problem. But
62 # sometimes we want to make non-backwards-compatible changes. In
63 # those cases, the stage1 compiler and libraries (which are produced
64 # by stage0) should use the runtime from the snapshot. The stage2
65 # compiler and libraries (which are produced by stage1) will be the
66 # first that are expecting to run against the runtime as defined in
67 # the working directory.
69 # The catch is that you may not add new functions to the runtime
72 # Arguments are the same as for TARGET_BASE_STAGE_N
73 define TARGET_RT_FROM_SNAPSHOT
75 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUNTIME): \
76 $$(HLIB$(1)_H_$(3))/$$(CFG_RUNTIME)
82 # This rule copies from the runtime for the working directory. It
83 # applies to targets produced by stage1 or later. See comment on
86 # Arguments are the same as for TARGET_BASE_STAGE_N
87 define TARGET_RT_FROM_WD
89 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUNTIME): \
90 rt/$(2)/$$(CFG_RUNTIME)
96 # As above, but builds the corelib either by taking it out of the
97 # snapshot or from the working directory.
99 define TARGET_CORELIB_FROM_SNAPSHOT
101 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB): \
102 $$(HLIB$(1)_H_$(3))/$$(CFG_CORELIB) \
104 $$(TSREQ$(1)_T_$(2)_H_$(3))
107 $$(Q)cp $$(HLIB$(1)_H_$(3))/$$(CORELIB_GLOB) \
108 $$(TLIB$(1)_T_$(2)_H_$(3))
112 define TARGET_CORELIB_FROM_WD
114 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB): \
115 $$(CORELIB_CRATE) $$(CORELIB_INPUTS) \
116 $$(TSREQ$(1)_T_$(2)_H_$(3))
117 @$$(call E, compile_and_link: $$@)
118 $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< && touch $$@
122 define TARGET_STDLIB_FROM_SNAPSHOT
124 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB): \
125 $$(HLIB$(1)_H_$(3))/$$(CFG_STDLIB) \
127 $$(TSREQ$(1)_T_$(2)_H_$(3))
130 $$(Q)cp $$(HLIB$(1)_H_$(3))/$$(STDLIB_GLOB) \
131 $$(TLIB$(1)_T_$(2)_H_$(3))
135 define TARGET_STDLIB_FROM_WD
137 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB): \
138 $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
139 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \
140 $$(TSREQ$(1)_T_$(2)_H_$(3))
141 @$$(call E, compile_and_link: $$@)
142 $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< && touch $$@
146 # In principle, each host can build each target:
147 $(foreach source,$(CFG_TARGET_TRIPLES), \
148 $(foreach target,$(CFG_TARGET_TRIPLES), \
149 $(eval $(call TARGET_STAGE_N,0,$(target),$(source))) \
150 $(eval $(call TARGET_STAGE_N,1,$(target),$(source))) \
151 $(eval $(call TARGET_STAGE_N,2,$(target),$(source))) \
152 $(eval $(call TARGET_STAGE_N,3,$(target),$(source)))))
154 # Host triple either uses the snapshot runtime or runtime from
155 # working directory, depending on the USE_SNAPSHOT_RUNTIME var.
156 ifeq ($(USE_SNAPSHOT_RUNTIME),1)
157 $(foreach src,$(CFG_HOST_TRIPLE),\
158 $(eval $(call TARGET_RT_FROM_SNAPSHOT,0,$(src),$(src))))
160 $(foreach src,$(CFG_HOST_TRIPLE),\
161 $(eval $(call TARGET_RT_FROM_WD,0,$(src),$(src))))
164 ifeq ($(USE_SNAPSHOT_CORELIB),1)
165 $(foreach src,$(CFG_HOST_TRIPLE),\
166 $(eval $(call TARGET_CORELIB_FROM_SNAPSHOT,0,$(src),$(src))))
168 $(foreach src,$(CFG_HOST_TRIPLE),\
169 $(eval $(call TARGET_CORELIB_FROM_WD,0,$(src),$(src))))
172 ifeq ($(USE_SNAPSHOT_STDLIB),1)
173 $(foreach src,$(CFG_HOST_TRIPLE),\
174 $(eval $(call TARGET_STDLIB_FROM_SNAPSHOT,0,$(src),$(src))))
176 $(foreach src,$(CFG_HOST_TRIPLE),\
177 $(eval $(call TARGET_STDLIB_FROM_WD,0,$(src),$(src))))
180 # Non-host triples build the stage0 runtime from the working directory
181 $(foreach source,$(CFG_TARGET_TRIPLES), \
182 $(foreach target,$(NON_HOST_TRIPLES), \
183 $(eval $(call TARGET_RT_FROM_WD,0,$(target),$(source))) \
184 $(eval $(call TARGET_CORELIB_FROM_WD,0,$(target),$(source))) \
185 $(eval $(call TARGET_STDLIB_FROM_WD,0,$(target),$(source))) \
188 # After stage0, always build the stage0 runtime from the working directory
189 $(foreach source,$(CFG_TARGET_TRIPLES), \
190 $(foreach target,$(CFG_TARGET_TRIPLES), \
191 $(eval $(call TARGET_RT_FROM_WD,1,$(target),$(source))) \
192 $(eval $(call TARGET_RT_FROM_WD,2,$(target),$(source))) \
193 $(eval $(call TARGET_RT_FROM_WD,3,$(target),$(source))) \
194 $(eval $(call TARGET_CORELIB_FROM_WD,1,$(target),$(source))) \
195 $(eval $(call TARGET_CORELIB_FROM_WD,2,$(target),$(source))) \
196 $(eval $(call TARGET_CORELIB_FROM_WD,3,$(target),$(source))) \
197 $(eval $(call TARGET_STDLIB_FROM_WD,1,$(target),$(source))) \
198 $(eval $(call TARGET_STDLIB_FROM_WD,2,$(target),$(source))) \
199 $(eval $(call TARGET_STDLIB_FROM_WD,3,$(target),$(source))) \