Permalink
Browse files

virtualize rustllvm construction per target triple

  • Loading branch information...
1 parent 54af489 commit 2bfa72ea42493c3337737cd35c5cd366502031c3 @nikomatsakis nikomatsakis committed with brson Nov 2, 2011
Showing with 32 additions and 19 deletions.
  1. +7 −1 configure
  2. +23 −16 mk/rustllvm.mk
  3. +2 −2 mk/target.mk
View
8 configure
@@ -394,13 +394,19 @@ step_msg "making directories"
for i in \
doc doc/std \
nd nd/std \
- rustllvm dl \
+ dl \
test/run-pass test/run-fail test/compile-fail \
test/bench test/perf test/pretty
do
make_dir $i
done
+make_dir rustllvm
+for t in $CFG_TARGET_TRIPLES
+do
+ make_dir rustllvm/$t
+done
+
make_dir rt
for t in $CFG_TARGET_TRIPLES
do
View
39 mk/rustllvm.mk
@@ -2,29 +2,36 @@
# rustc LLVM-extensions (C++) library variables and rules
######################################################################
-RUSTLLVM_OBJS_CS := $(addprefix rustllvm/, RustGCMetadataPrinter.cpp \
+define DEF_RUSTLLVM_TARGETS
+
+RUSTLLVM_OBJS_CS_$(1) := $$(addprefix rustllvm/, RustGCMetadataPrinter.cpp \
RustGCStrategy.cpp RustWrapper.cpp)
# Behind an ifdef for now since this requires a patched LLVM.
ifdef CFG_STACK_GROWTH
-RUSTLLVM_OBJS_CS += rustllvm/RustPrologHook.cpp
+RUSTLLVM_OBJS_CS_$(1) += rustllvm/RustPrologHook.cpp
endif
-RUSTLLVM_DEF := rustllvm/rustllvm$(CFG_DEF_SUFFIX)
+RUSTLLVM_DEF_$(1) := rustllvm/rustllvm$$(CFG_DEF_SUFFIX)
+
+RUSTLLVM_INCS_$(1) := -iquote $$(CFG_LLVM_INCDIR) \
+ -iquote $$(S)src/rustllvm/include
+RUSTLLVM_OBJS_OBJS_$(1) := $$(RUSTLLVM_OBJS_CS_$(1):rustllvm/%.cpp=rustllvm/$(1)/%.o)
-RUSTLLVM_INCS := -iquote $(CFG_LLVM_INCDIR) \
- -iquote $(S)src/rustllvm/include
-RUSTLLVM_OBJS_OBJS := $(RUSTLLVM_OBJS_CS:.cpp=.o)
+rustllvm/$(1)/$(CFG_RUSTLLVM): $$(RUSTLLVM_OBJS_OBJS_$(1)) \
+ $$(MKFILES) $$(RUSTLLVM_DEF_$(1))
+ @$$(call E, link: $$@)
+ $$(Q)$$(call CFG_LINK_C_$(1),$$@,$$(RUSTLLVM_OBJS_OBJS_$(1)) \
+ $$(CFG_GCCISH_PRE_LIB_FLAGS) $$(CFG_LLVM_LIBS) \
+ $$(CFG_GCCISH_POST_LIB_FLAGS) \
+ $$(CFG_LLVM_LDFLAGS),$$(RUSTLLVM_DEF_$(1)),$$(CFG_RUSTLLVM))
-rustllvm/$(CFG_RUSTLLVM): $(RUSTLLVM_OBJS_OBJS) \
- $(MKFILES) $(RUSTLLVM_DEF)
- @$(call E, link: $@)
- $(Q)$(call CFG_LINK_C,$@,$(RUSTLLVM_OBJS_OBJS) \
- $(CFG_GCCISH_PRE_LIB_FLAGS) $(CFG_LLVM_LIBS) \
- $(CFG_GCCISH_POST_LIB_FLAGS) \
- $(CFG_LLVM_LDFLAGS),$(RUSTLLVM_DEF),$(CFG_RUSTLLVM))
+rustllvm/$(1)/%.o: rustllvm/%.cpp $$(MKFILES)
+ @$$(call E, compile: $$@)
+ $$(Q)$$(call CFG_COMPILE_C_$(1), $$@, $$(CFG_LLVM_CXXFLAGS) $$(RUSTLLVM_INCS_$(1))) $$<
-rustllvm/%.o: rustllvm/%.cpp $(MKFILES)
- @$(call E, compile: $@)
- $(Q)$(call CFG_COMPILE_C, $@, $(CFG_LLVM_CXXFLAGS) $(RUSTLLVM_INCS)) $<
+endef
+# Instantiate template for all stages
+$(foreach target,$(CFG_TARGET_TRIPLES), \
+ $(eval $(call DEF_RUSTLLVM_TARGETS,$(target))))
View
4 mk/target.mk
@@ -35,11 +35,11 @@ $$(TARGET_LIB$(1)$(2))/libstd.rlib: \
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_$(2)) --lib --static -o $$@ $$<
-$$(TARGET_LIB$(1)$(2))/$$(CFG_RUNTIME): rt/$(2)/$(CFG_RUNTIME)
+$$(TARGET_LIB$(1)$(2))/$$(CFG_RUNTIME): rt/$(2)/$$(CFG_RUNTIME)
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
-$$(TARGET_LIB$(1)$(2))/$$(CFG_RUSTLLVM): rustllvm/$$(CFG_RUSTLLVM)
+$$(TARGET_LIB$(1)$(2))/$$(CFG_RUSTLLVM): rustllvm/$(2)/$$(CFG_RUSTLLVM)
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@

0 comments on commit 2bfa72e

Please sign in to comment.