Define _RUST_STAGEN when building rustrt.

This lets us use #ifdefs to determine which stage of the build we happen
to be in, which is useful in the event we need to make changes to rustrt
that are incompatible with the code generated by stage0.

This should help pave the way to completing #6575, which will likely
require changes to type signatures for spawn_fn & glue_fn in rustrt.
This commit is contained in:
Tom Lee
2013-05-23 23:49:20 -07:00
parent a776d65b4d
commit e69e80938b
3 changed files with 64 additions and 54 deletions

14
configure vendored
View File

@@ -665,12 +665,16 @@ make_dir rt
for t in $CFG_TARGET_TRIPLES for t in $CFG_TARGET_TRIPLES
do do
make_dir rt/$t make_dir rt/$t
for i in \ for s in 0 1 2 3
isaac linenoise sync test \
arch/i386 arch/x86_64 arch/arm arch/mips \
libuv libuv/src/ares libuv/src/eio libuv/src/ev
do do
make_dir rt/$t/$i make_dir rt/$t/stage$s
for i in \
isaac linenoise sync test \
arch/i386 arch/x86_64 arch/arm arch/mips \
libuv libuv/src/ares libuv/src/eio libuv/src/ev
do
make_dir rt/$t/stage$s/$i
done
done done
done done

100
mk/rt.mk
View File

@@ -41,14 +41,19 @@ ifneq ($(strip $(findstring snap,$(MAKECMDGOALS))),)
SNAP_DEFINES=-DRUST_SNAPSHOT SNAP_DEFINES=-DRUST_SNAPSHOT
endif endif
define DEF_RUNTIME_TARGETS define DEF_RUNTIME_TARGETS
###################################################################### ######################################################################
# Runtime (C++) library variables # Runtime (C++) library variables
###################################################################### ######################################################################
RUNTIME_CXXS_$(1) := \ # $(1) is the target triple
# $(2) is the stage number
RUNTIME_CFLAGS_$(1)_$(2) = -D_RUST_STAGE$(2)
RUNTIME_CXXFLAGS_$(1)_$(2) = -D_RUST_STAGE$(2)
RUNTIME_CXXS_$(1)_$(2) := \
rt/sync/timer.cpp \ rt/sync/timer.cpp \
rt/sync/lock_and_signal.cpp \ rt/sync/lock_and_signal.cpp \
rt/sync/rust_thread.cpp \ rt/sync/rust_thread.cpp \
@@ -83,70 +88,70 @@ RUNTIME_CXXS_$(1) := \
rt/rust_android_dummy.cpp \ rt/rust_android_dummy.cpp \
rt/rust_test_helpers.cpp rt/rust_test_helpers.cpp
RUNTIME_CS_$(1) := rt/linenoise/linenoise.c rt/linenoise/utf8.c RUNTIME_CS_$(1)_$(2) := rt/linenoise/linenoise.c rt/linenoise/utf8.c
RUNTIME_S_$(1) := rt/arch/$$(HOST_$(1))/_context.S \ RUNTIME_S_$(1)_$(2) := rt/arch/$$(HOST_$(1))/_context.S \
rt/arch/$$(HOST_$(1))/ccall.S \ rt/arch/$$(HOST_$(1))/ccall.S \
rt/arch/$$(HOST_$(1))/record_sp.S rt/arch/$$(HOST_$(1))/record_sp.S
ifeq ($$(CFG_WINDOWSY_$(1)), 1) ifeq ($$(CFG_WINDOWSY_$(1)), 1)
LIBUV_OSTYPE_$(1) := win LIBUV_OSTYPE_$(1)_$(2) := win
LIBUV_LIB_$(1) := rt/$(1)/libuv/libuv.a LIBUV_LIB_$(1)_$(2) := rt/$(1)/stage$(2)/libuv/libuv.a
else ifeq ($(OSTYPE_$(1)), apple-darwin) else ifeq ($(OSTYPE_$(1)), apple-darwin)
LIBUV_OSTYPE_$(1) := mac LIBUV_OSTYPE_$(1)_$(2) := mac
LIBUV_LIB_$(1) := rt/$(1)/libuv/libuv.a LIBUV_LIB_$(1)_$(2) := rt/$(1)/stage$(2)/libuv/libuv.a
else ifeq ($(OSTYPE_$(1)), unknown-freebsd) else ifeq ($(OSTYPE_$(1)), unknown-freebsd)
LIBUV_OSTYPE_$(1) := unix/freebsd LIBUV_OSTYPE_$(1)_$(2) := unix/freebsd
LIBUV_LIB_$(1) := rt/$(1)/libuv/libuv.a LIBUV_LIB_$(1)_$(2) := rt/$(1)/stage$(2)/libuv/libuv.a
else ifeq ($(OSTYPE_$(1)), linux-androideabi) else ifeq ($(OSTYPE_$(1)), linux-androideabi)
LIBUV_OSTYPE_$(1) := unix/android LIBUV_OSTYPE_$(1)_$(2) := unix/android
LIBUV_LIB_$(1) := rt/$(1)/libuv/libuv.a LIBUV_LIB_$(1)_$(2) := rt/$(1)/stage$(2)/libuv/libuv.a
else else
LIBUV_OSTYPE_$(1) := unix/linux LIBUV_OSTYPE_$(1)_$(2) := unix/linux
LIBUV_LIB_$(1) := rt/$(1)/libuv/libuv.a LIBUV_LIB_$(1)_$(2) := rt/$(1)/stage$(2)/libuv/libuv.a
endif endif
RUNTIME_DEF_$(1) := rt/rustrt$(CFG_DEF_SUFFIX_$(1)) RUNTIME_DEF_$(1)_$(2) := rt/rustrt$(CFG_DEF_SUFFIX_$(1))
RUNTIME_INCS_$(1) := -I $$(S)src/rt -I $$(S)src/rt/isaac -I $$(S)src/rt/uthash \ RUNTIME_INCS_$(1)_$(2) := -I $$(S)src/rt -I $$(S)src/rt/isaac -I $$(S)src/rt/uthash \
-I $$(S)src/rt/arch/$$(HOST_$(1)) \ -I $$(S)src/rt/arch/$$(HOST_$(1)) \
-I $$(S)src/rt/linenoise \ -I $$(S)src/rt/linenoise \
-I $$(S)src/libuv/include -I $$(S)src/libuv/include
RUNTIME_OBJS_$(1) := $$(RUNTIME_CXXS_$(1):rt/%.cpp=rt/$(1)/%.o) \ RUNTIME_OBJS_$(1)_$(2) := $$(RUNTIME_CXXS_$(1)_$(2):rt/%.cpp=rt/$(1)/stage$(2)/%.o) \
$$(RUNTIME_CS_$(1):rt/%.c=rt/$(1)/%.o) \ $$(RUNTIME_CS_$(1)_$(2):rt/%.c=rt/$(1)/stage$(2)/%.o) \
$$(RUNTIME_S_$(1):rt/%.S=rt/$(1)/%.o) $$(RUNTIME_S_$(1)_$(2):rt/%.S=rt/$(1)/stage$(2)/%.o)
ALL_OBJ_FILES += $$(RUNTIME_OBJS_$(1)) ALL_OBJ_FILES += $$(RUNTIME_OBJS_$(1)_$(2))
MORESTACK_OBJ_$(1) := rt/$(1)/arch/$$(HOST_$(1))/morestack.o MORESTACK_OBJ_$(1)_$(2) := rt/$(1)/stage$(2)/arch/$$(HOST_$(1))/morestack.o
ALL_OBJ_FILES += $$(MORESTACK_OBJS_$(1)) ALL_OBJ_FILES += $$(MORESTACK_OBJS_$(1)_$(2))
RUNTIME_LIBS_$(1) := $$(LIBUV_LIB_$(1)) RUNTIME_LIBS_$(1)_$(2) := $$(LIBUV_LIB_$(1)_$(2))
rt/$(1)/%.o: rt/%.cpp $$(MKFILE_DEPS) rt/$(1)/stage$(2)/%.o: rt/%.cpp $$(MKFILE_DEPS)
@$$(call E, compile: $$@) @$$(call E, compile: $$@)
$$(Q)$$(call CFG_COMPILE_CXX_$(1), $$@, $$(RUNTIME_INCS_$(1)) \ $$(Q)$$(call CFG_COMPILE_CXX_$(1), $$@, $$(RUNTIME_INCS_$(1)_$(2)) \
$$(SNAP_DEFINES)) $$< $$(SNAP_DEFINES) $$(RUNTIME_CXXFLAGS_$(1)_$(2))) $$<
rt/$(1)/%.o: rt/%.c $$(MKFILE_DEPS) rt/$(1)/stage$(2)/%.o: rt/%.c $$(MKFILE_DEPS)
@$$(call E, compile: $$@) @$$(call E, compile: $$@)
$$(Q)$$(call CFG_COMPILE_C_$(1), $$@, $$(RUNTIME_INCS_$(1)) \ $$(Q)$$(call CFG_COMPILE_C_$(1), $$@, $$(RUNTIME_INCS_$(1)_$(2)) \
$$(SNAP_DEFINES)) $$< $$(SNAP_DEFINES) $$(RUNTIME_CFLAGS_$(1)_$(2))) $$<
rt/$(1)/%.o: rt/%.S $$(MKFILE_DEPS) \ rt/$(1)/stage$(2)/%.o: rt/%.S $$(MKFILE_DEPS) \
$$(LLVM_CONFIG_$$(CFG_BUILD_TRIPLE)) $$(LLVM_CONFIG_$$(CFG_BUILD_TRIPLE))
@$$(call E, compile: $$@) @$$(call E, compile: $$@)
$$(Q)$$(call CFG_ASSEMBLE_$(1),$$@,$$<) $$(Q)$$(call CFG_ASSEMBLE_$(1),$$@,$$<)
rt/$(1)/arch/$$(HOST_$(1))/libmorestack.a: $$(MORESTACK_OBJ_$(1)) rt/$(1)/stage$(2)/arch/$$(HOST_$(1))/libmorestack.a: $$(MORESTACK_OBJ_$(1)_$(2))
@$$(call E, link: $$@) @$$(call E, link: $$@)
$$(Q)$(AR_$(1)) rcs $$@ $$< $$(Q)$(AR_$(1)) rcs $$@ $$<
rt/$(1)/$(CFG_RUNTIME_$(1)): $$(RUNTIME_OBJS_$(1)) $$(MKFILE_DEPS) \ rt/$(1)/stage$(2)/$(CFG_RUNTIME_$(1)): $$(RUNTIME_OBJS_$(1)_$(2)) $$(MKFILE_DEPS) \
$$(RUNTIME_DEF_$(1)) \ $$(RUNTIME_DEF_$(1)_$(2)) \
$$(RUNTIME_LIBS_$(1)) $$(RUNTIME_LIBS_$(1)_$(2))
@$$(call E, link: $$@) @$$(call E, link: $$@)
$$(Q)$$(call CFG_LINK_CXX_$(1),$$@, $$(RUNTIME_OBJS_$(1)) \ $$(Q)$$(call CFG_LINK_CXX_$(1),$$@, $$(RUNTIME_OBJS_$(1)_$(2)) \
$$(CFG_GCCISH_POST_LIB_FLAGS_$(1)) $$(RUNTIME_LIBS_$(1)) \ $$(CFG_GCCISH_POST_LIB_FLAGS_$(1)) $$(RUNTIME_LIBS_$(1)_$(2)) \
$$(CFG_LIBUV_LINK_FLAGS_$(1)),$$(RUNTIME_DEF_$(1)),$$(CFG_RUNTIME_$(1))) $$(CFG_LIBUV_LINK_FLAGS_$(1)),$$(RUNTIME_DEF_$(1)_$(2)),$$(CFG_RUNTIME_$(1)))
# FIXME: For some reason libuv's makefiles can't figure out the # FIXME: For some reason libuv's makefiles can't figure out the
# correct definition of CC on the mingw I'm using, so we are # correct definition of CC on the mingw I'm using, so we are
@@ -165,13 +170,13 @@ endif
# XXX: Shouldn't need platform-specific conditions here # XXX: Shouldn't need platform-specific conditions here
ifdef CFG_WINDOWSY_$(1) ifdef CFG_WINDOWSY_$(1)
$$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS) $$(LIBUV_LIB_$(1)_$(2)): $$(LIBUV_DEPS)
$$(Q)$$(MAKE) -C $$(S)src/libuv/ \ $$(Q)$$(MAKE) -C $$(S)src/libuv/ \
builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/libuv" \ builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/stage$(2)/libuv" \
OS=mingw \ OS=mingw \
V=$$(VERBOSE) V=$$(VERBOSE)
else ifeq ($(OSTYPE_$(1)), linux-androideabi) else ifeq ($(OSTYPE_$(1)), linux-androideabi)
$$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS) $$(LIBUV_LIB_$(1)_$(2)): $$(LIBUV_DEPS)
$$(Q)$$(MAKE) -C $$(S)src/libuv/ \ $$(Q)$$(MAKE) -C $$(S)src/libuv/ \
CFLAGS="$$(CFG_GCCISH_CFLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1))) $$(SNAP_DEFINES)" \ CFLAGS="$$(CFG_GCCISH_CFLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1))) $$(SNAP_DEFINES)" \
LDFLAGS="$$(CFG_GCCISH_LINK_FLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1)))" \ LDFLAGS="$$(CFG_GCCISH_LINK_FLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1)))" \
@@ -179,18 +184,18 @@ $$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS)
CXX="$$(CXX_$(1))" \ CXX="$$(CXX_$(1))" \
AR="$$(AR_$(1))" \ AR="$$(AR_$(1))" \
BUILDTYPE=Release \ BUILDTYPE=Release \
builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/libuv" \ builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/stage$(2)/libuv" \
host=android OS=linux \ host=android OS=linux \
V=$$(VERBOSE) V=$$(VERBOSE)
else else
$$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS) $$(LIBUV_LIB_$(1)_$(2)): $$(LIBUV_DEPS)
$$(Q)$$(MAKE) -C $$(S)src/libuv/ \ $$(Q)$$(MAKE) -C $$(S)src/libuv/ \
CFLAGS="$$(CFG_GCCISH_CFLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1))) $$(SNAP_DEFINES)" \ CFLAGS="$$(CFG_GCCISH_CFLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1))) $$(SNAP_DEFINES)" \
LDFLAGS="$$(CFG_GCCISH_LINK_FLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1)))" \ LDFLAGS="$$(CFG_GCCISH_LINK_FLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1)))" \
CC="$$(CC_$(1))" \ CC="$$(CC_$(1))" \
CXX="$$(CXX_$(1))" \ CXX="$$(CXX_$(1))" \
AR="$$(AR_$(1))" \ AR="$$(AR_$(1))" \
builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/libuv" \ builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/stage$(2)/libuv" \
V=$$(VERBOSE) V=$$(VERBOSE)
endif endif
@@ -229,5 +234,6 @@ endif
endef endef
# Instantiate template for all stages # Instantiate template for all stages
$(foreach target,$(CFG_TARGET_TRIPLES), \ $(foreach stage,$(STAGES), \
$(eval $(call DEF_RUNTIME_TARGETS,$(target)))) $(foreach target,$(CFG_TARGET_TRIPLES), \
$(eval $(call DEF_RUNTIME_TARGETS,$(target),$(stage)))))

View File

@@ -18,13 +18,13 @@
define TARGET_STAGE_N define TARGET_STAGE_N
$$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a: \ $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a: \
rt/$(2)/arch/$$(HOST_$(2))/libmorestack.a \ rt/$(2)/stage$(1)/arch/$$(HOST_$(2))/libmorestack.a \
| $$(TLIB$(1)_T_$(2)_H_$(3))/ | $$(TLIB$(1)_T_$(2)_H_$(3))/
@$$(call E, cp: $$@) @$$(call E, cp: $$@)
$$(Q)cp $$< $$@ $$(Q)cp $$< $$@
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUNTIME_$(2)): \ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUNTIME_$(2)): \
rt/$(2)/$(CFG_RUNTIME_$(2)) \ rt/$(2)/stage$(1)/$(CFG_RUNTIME_$(2)) \
| $$(TLIB$(1)_T_$(2)_H_$(3))/ | $$(TLIB$(1)_T_$(2)_H_$(3))/
@$$(call E, cp: $$@) @$$(call E, cp: $$@)
$$(Q)cp $$< $$@ $$(Q)cp $$< $$@