Skip to content

Commit

Permalink
make it possible to use snapshot core lib
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Mar 16, 2012
1 parent 15a325f commit 140d194
Showing 1 changed file with 51 additions and 17 deletions.
68 changes: 51 additions & 17 deletions mk/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)) \
Expand Down Expand Up @@ -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))) \
Expand All @@ -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))) \
))

0 comments on commit 140d194

Please sign in to comment.