Skip to content

Commit 005e319

Browse files
committed
make use of snapshot runtime predicated on variable USE_SNAPSHOT_RUNTIME
1 parent 55edb4a commit 005e319

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

mk/target.mk

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
# $(2) is the target triple
55
# $(3) is the host triple
66

7+
# If you are making non-backwards compatible changes to the runtime,
8+
# set this flag to 1. It will cause stage1 to use the snapshot
9+
# runtime rather than the runtime from the working directory.
10+
USE_SNAPSHOT_RUNTIME=0
11+
712
define TARGET_STAGE_N
813

914
$$(TLIB$(1)_T_$(2)_H_$(3))/intrinsics.ll: \
@@ -58,11 +63,17 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC): \
5863
endef
5964

6065
# The stage0 (snapshot) compiler produces binaries that expect the
61-
# snapshot runtime. Therefore, the stage1 compiler and libraries
62-
# (which are produced by stage0) should use the runtime from the
63-
# snapshot. The stage2 compiler and libraries (which are produced by
64-
# stage1) will be the first that are expecting to run against the
65-
# runtime as defined in the working directory.
66+
# snapshot runtime. Normally the working directory runtime and
67+
# snapshot runtime are compatible, so this is no problem. But
68+
# sometimes we want to make non-backwards-compatible changes. In
69+
# those cases, the stage1 compiler and libraries (which are produced
70+
# by stage0) should use the runtime from the snapshot. The stage2
71+
# compiler and libraries (which are produced by stage1) will be the
72+
# first that are expecting to run against the runtime as defined in
73+
# the working directory.
74+
#
75+
# The catch is that you may not add new functions to the runtime
76+
# in this case!
6677
#
6778
# Arguments are the same as for TARGET_BASE_STAGE_N
6879
define TARGET_RT_FROM_SNAPSHOT
@@ -96,15 +107,25 @@ $(foreach source,$(CFG_TARGET_TRIPLES), \
96107
$(eval $(call TARGET_STAGE_N,2,$(target),$(source))) \
97108
$(eval $(call TARGET_STAGE_N,3,$(target),$(source)))))
98109

99-
$(eval $(call TARGET_RT_FROM_SNAPSHOT,0,$(CFG_HOST_TRIPLE),$(CFG_HOST_TRIPLE)))
110+
# Host triple either uses the snapshot runtime or runtime from
111+
# working directory, depending on the USE_SNAPSHOT_RUNTIME var.
112+
ifeq ($(USE_SNAPSHOT_RUNTIME),1)
113+
$(foreach src,$(CFG_HOST_TRIPLE),\
114+
$(eval $(call TARGET_RT_FROM_SNAPSHOT,0,$(src),$(src))))
115+
else
116+
$(foreach src,$(CFG_HOST_TRIPLE),\
117+
$(eval $(call TARGET_RT_FROM_WD,0,$(src),$(src))))
118+
endif
100119

120+
# Non-host triples build the stage0 runtime from the working directory
121+
$(foreach source,$(CFG_TARGET_TRIPLES), \
122+
$(foreach target,$(NON_HOST_TRIPLES), \
123+
$(eval $(call TARGET_RT_FROM_WD,0,$(target),$(source)))))
124+
125+
# After stage0, always build the stage0 runtime from the working directory
101126
$(foreach source,$(CFG_TARGET_TRIPLES), \
102127
$(foreach target,$(CFG_TARGET_TRIPLES), \
103128
$(eval $(call TARGET_RT_FROM_WD,1,$(target),$(source))) \
104129
$(eval $(call TARGET_RT_FROM_WD,2,$(target),$(source))) \
105130
$(eval $(call TARGET_RT_FROM_WD,3,$(target),$(source)))))
106131

107-
# Non-host triples build the stage0 runtime from the working directory
108-
$(foreach source,$(CFG_TARGET_TRIPLES), \
109-
$(foreach target,$(NON_HOST_TRIPLES), \
110-
$(eval $(call TARGET_RT_FROM_WD,0,$(target),$(source)))))

0 commit comments

Comments
 (0)