From 140d194007bbb427ab694807782b3a41bb43b27d Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 16 Mar 2012 10:14:33 -0400 Subject: [PATCH] make it possible to use snapshot core lib --- mk/target.mk | 68 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 17 deletions(-) diff --git a/mk/target.mk b/mk/target.mk index d61477368ac..34470e99f64 100644 --- a/mk/target.mk +++ b/mk/target.mk @@ -4,10 +4,12 @@ # $(2) is the target triple # $(3) is the host triple -# If you are making non-backwards compatible changes to the runtime, -# set this flag to 1. It will cause stage1 to use the snapshot -# runtime rather than the runtime from the working directory. +# If you are making non-backwards compatible changes to the runtime +# (resp. corelib), set this flag to 1. It will cause stage1 to use +# the snapshot runtime (resp. corelib) rather than the runtime +# (resp. corelib) from the working directory. USE_SNAPSHOT_RUNTIME=0 +USE_SNAPSHOT_CORELIB=0 # Do not use --enforce-mut-vars in stage0, for now, as the snapshot # has an older version of the check. @@ -34,15 +36,9 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a: \ @$$(call E, cp: $$@) $$(Q)cp $$< $$@ -$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB): \ - $$(CORELIB_CRATE) $$(CORELIB_INPUTS) \ - $$(TSREQ$(1)_T_$(2)_H_$(3)) - @$$(call E, compile_and_link: $$@) - $$(STAGE$(1)_T_$(2)_H_$(3)) --enforce-mut-vars -o $$@ $$< && touch $$@ - $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB): \ $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \ - $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \ + $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \ $$(TSREQ$(1)_T_$(2)_H_$(3)) @$$(call E, compile_and_link: $$@) $$(STAGE$(1)_T_$(2)_H_$(3)) $$(ENFORCE_MUT_VARS_$(1)) \ @@ -107,9 +103,35 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUNTIME): \ endef +# As above, but builds the corelib either by taking it out of the +# snapshot or from the working directory. + +define TARGET_CORELIB_FROM_SNAPSHOT + +$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB): \ + $$(HLIB$(1)_H_$(3))/$$(CFG_CORELIB) \ + $$(CORELIB_INPUTS) \ + $$(TSREQ$(1)_T_$(2)_H_$(3)) + @$$(call E, cp: $$@) + $$(Q)cp $$< $$@ + $$(Q)cp $$(HLIB$(1)_H_$(3))/$$(CORELIB_GLOB) \ + $$(TLIB$(1)_T_$(2)_H_$(3)) + +endef + +define TARGET_CORELIB_FROM_WD + +$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB): \ + $$(CORELIB_CRATE) $$(CORELIB_INPUTS) \ + $$(TSREQ$(1)_T_$(2)_H_$(3)) + @$$(call E, compile_and_link: $$@) + $$(STAGE$(1)_T_$(2)_H_$(3)) --enforce-mut-vars -o $$@ $$< && touch $$@ + +endef + # In principle, each host can build each target: -$(foreach source,$(CFG_TARGET_TRIPLES), \ - $(foreach target,$(CFG_TARGET_TRIPLES), \ +$(foreach source,$(CFG_TARGET_TRIPLES), \ + $(foreach target,$(CFG_TARGET_TRIPLES), \ $(eval $(call TARGET_STAGE_N,0,$(target),$(source))) \ $(eval $(call TARGET_STAGE_N,1,$(target),$(source))) \ $(eval $(call TARGET_STAGE_N,2,$(target),$(source))) \ @@ -125,15 +147,27 @@ else $(eval $(call TARGET_RT_FROM_WD,0,$(src),$(src)))) endif +ifeq ($(USE_SNAPSHOT_CORELIB),1) + $(foreach src,$(CFG_HOST_TRIPLE),\ + $(eval $(call TARGET_CORELIB_FROM_SNAPSHOT,0,$(src),$(src)))) +else + $(foreach src,$(CFG_HOST_TRIPLE),\ + $(eval $(call TARGET_CORELIB_FROM_WD,0,$(src),$(src)))) +endif + # Non-host triples build the stage0 runtime from the working directory -$(foreach source,$(CFG_TARGET_TRIPLES), \ - $(foreach target,$(NON_HOST_TRIPLES), \ +$(foreach source,$(CFG_TARGET_TRIPLES), \ + $(foreach target,$(NON_HOST_TRIPLES), \ $(eval $(call TARGET_RT_FROM_WD,0,$(target),$(source))))) # After stage0, always build the stage0 runtime from the working directory -$(foreach source,$(CFG_TARGET_TRIPLES), \ - $(foreach target,$(CFG_TARGET_TRIPLES), \ +$(foreach source,$(CFG_TARGET_TRIPLES), \ + $(foreach target,$(CFG_TARGET_TRIPLES), \ $(eval $(call TARGET_RT_FROM_WD,1,$(target),$(source))) \ $(eval $(call TARGET_RT_FROM_WD,2,$(target),$(source))) \ - $(eval $(call TARGET_RT_FROM_WD,3,$(target),$(source))))) + $(eval $(call TARGET_RT_FROM_WD,3,$(target),$(source))) \ + $(eval $(call TARGET_CORELIB_FROM_WD,1,$(target),$(source))) \ + $(eval $(call TARGET_CORELIB_FROM_WD,2,$(target),$(source))) \ + $(eval $(call TARGET_CORELIB_FROM_WD,3,$(target),$(source))) \ +))