More steps to arch-specific target libs (#474)

This commit is contained in:
Graydon Hoare 2011-09-23 10:50:06 -07:00
parent 5310cf4f30
commit 18c6cc6371
5 changed files with 140 additions and 50 deletions

View File

@ -13,6 +13,7 @@ endif
CFG_INFO := $(info cfg: shell host triple $(CFG_HOST_TRIPLE))
CFG_INFO := $(info cfg: llvm host triple $(CFG_LLVM_TRIPLE))
CFG_INFO := $(info cfg: llvm target triples $(CFG_LLVM_TRIPLES))
ifdef CFG_DISABLE_OPTIMIZE
$(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))

46
configure vendored
View File

@ -10,6 +10,10 @@ step_msg() {
msg
}
warn() {
echo "configure: WARNING: $1"
}
err() {
echo "configure: error: $1"
exit 1
@ -228,7 +232,6 @@ putvar CFG_SRC_DIR
putvar CFG_BUILD_DIR
putvar CFG_OSTYPE
putvar CFG_CPUTYPE
putvar CFG_HOST_TRIPLE
putvar CFG_CONFIGURE_ARGS
step_msg "looking for build programs"
@ -335,6 +338,26 @@ then
else
CFG_C_COMPILER="gcc"
fi
if [ ! -z "$CFG_LLVM_TRIPLE" ]
then
if [ $CFG_HOST_TRIPLE != $CFG_LLVM_TRIPLE ]
then
warn "LLVM host-triple $CFG_LLVM_TRIPLE differs from"
warn "detected host triple $CFG_HOST_TRIPLE"
warn "choosing LLVM host-triple instead"
msg ""
CFG_HOST_TRIPLE=$CFG_LLVM_TRIPLE
fi
fi
# FIXME: add support for extending the target-triples list
CFG_TARGET_TRIPLES="${CFG_HOST_TRIPLE}"
putvar CFG_HOST_TRIPLE
putvar CFG_TARGET_TRIPLES
putvar CFG_C_COMPILER
putvar CFG_LLVM_ROOT
@ -356,14 +379,31 @@ for i in \
doc \
rt rt/isaac rt/bigint rt/sync rt/test rt/arch/i386 \
rt/libuv rt/libuv/src/ares rt/libuv/src/eio rt/libuv/src/ev \
rustllvm \
dl stage{0,1,2,3}{,/lib,/lib/$CFG_LLVM_TRIPLE} \
rustllvm dl \
test/run-pass test/run-fail test/compile-fail \
test/bench test/perf test/pretty
do
make_dir $i
done
for t in $CFG_TARGET_TRIPLES
do
for i in 0 1 2 3
do
# old-style "bin" dir
make_dir stage$i
# new-style bin dir, not yet used
make_dir stage$i/bin
# old-style non-arch libs
make_dir stage$i/lib
# new-style arch-prefixed libs, not yet used
make_dir stage$i/lib/rustc/$t
done
done
copy ${CFG_SRC_DIR}Makefile.in ./Makefile
copy ${CFG_SRC_DIR}src/rt/libuv/Makefile rt/libuv/Makefile

View File

@ -17,16 +17,9 @@ stage0/$(CFG_STDLIB): stage0/rustc$(X)
stage0/$(CFG_RUSTLLVM): stage0/rustc$(X)
$(Q)touch $@
# Target libs will be made in the process of making rustc above.
stage0/lib/glue.o: stage0/rustc$(X)
$(Q)touch $@
stage0/lib/main.o: stage0/rustc$(X)
$(Q)touch $@
# Instantiate template (in stageN.mk) for building
# stage0/lib/$(CFG_STDLIB) and stage0/lib/libstd.rlib.
SREQpre = stage0/lib/main.o $(MKFILES)
$(eval $(call LIBGEN,pre,0))
# target libraries.
SREQpre = stage0/lib/main.o $(MKFILES)
$(eval $(call TARGET_LIBS,pre,0,$(CFG_HOST_TRIPLE)))

View File

@ -1,38 +1,15 @@
# StageN template: arg 1 is the N we're building *from*, arg 2 is N+1.
# STAGE_N template: arg 1 is the N we're building *from*, arg 2 is N+1, arg 3
# is the target triple we're building for. You have to invoke this for each
# target triple.
#
# The easiest way to read this template is to assume we're building stage2
# using stage1, and mentally gloss $(1) as 1, $(2) as 2.
#
# LIBGEN is pulled out seperately because we need to specially invoke
# TARGET_LIBS is pulled out seperately because we need to specially invoke
# it to build stage0/lib/libstd using stage0/rustc and to use the
# new rustrt in stage0/lib/.
define LIBGEN
stage$(2)/lib/$$(CFG_STDLIB): $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
stage$(2)/rustc$$(X) \
stage$(2)/$$(CFG_RUNTIME) \
stage$(2)/$$(CFG_RUSTLLVM) \
stage$(2)/lib/glue.o \
$$(SREQ$(1))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(2)) --lib -o $$@ $$<
stage$(2)/lib/libstd.rlib: $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
stage$(2)/rustc$$(X) \
stage$(2)/$$(CFG_RUNTIME) \
stage$(2)/$$(CFG_RUSTLLVM) \
stage$(2)/lib/glue.o \
$$(SREQ$(1))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(2)) --lib --static -o $$@ $$<
stage$(2)/lib/$$(CFG_RUNTIME): rt/$$(CFG_RUNTIME)
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
endef
define STAGEN
define STAGE_N
# Host libraries and executables (stage$(2)/rustc and its runtime needs)
#
@ -74,9 +51,14 @@ stage$(2)/$$(CFG_RUSTLLVM): rustllvm/$$(CFG_RUSTLLVM)
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
# Expand out target libraries
# Target libraries (for binaries generated by stage$(2)/rustc)
$(eval $(call TARGET_LIBS,$(1),$(2),$(3)))
endef
define TARGET_LIBS
stage$(2)/lib/intrinsics.bc: $$(INTRINSICS_BC)
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
@ -89,8 +71,6 @@ stage$(2)/lib/glue.o: stage$(2)/rustc$$(X) \
@$$(call E, generate: $$@)
$$(STAGE$(2)) -c -o $$@ --glue
$(eval $(call LIBGEN,$(1),$(2)))
stage$(2)/lib/main.o: rt/main.o
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
@ -100,10 +80,86 @@ stage$(2)/lib/$$(CFG_LIBRUSTC): $$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
@$$(call E, compile_and_link: $$@)
$$(STAGE$(2)) --lib -o $$@ $$<
stage$(2)/lib/$$(CFG_STDLIB): $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
stage$(2)/rustc$$(X) \
stage$(2)/$$(CFG_RUNTIME) \
stage$(2)/$$(CFG_RUSTLLVM) \
stage$(2)/lib/glue.o \
$$(SREQ$(1))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(2)) --lib -o $$@ $$<
stage$(2)/lib/libstd.rlib: $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
stage$(2)/rustc$$(X) \
stage$(2)/$$(CFG_RUNTIME) \
stage$(2)/$$(CFG_RUSTLLVM) \
stage$(2)/lib/glue.o \
$$(SREQ$(1))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(2)) --lib --static -o $$@ $$<
stage$(2)/lib/$$(CFG_RUNTIME): rt/$$(CFG_RUNTIME)
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
# New per-target-arch target libraries; when we've transitioned to
# using these exclusively, you should delete the non-arch-prefixed
# rules above. They're duplicates, redundant.
stage$(2)/lib/rustc/$(3)/intrinsics.bc: $$(INTRINSICS_BC)
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
stage$(2)/lib/rustc/$(3)/glue.o: \
stage$(2)/rustc$$(X) \
stage$(2)/$$(CFG_RUNTIME) \
stage$(2)/$$(CFG_RUSTLLVM) \
stage$(2)/lib/intrinsics.bc \
$$(SREQ$(1))
@$$(call E, generate: $$@)
$$(STAGE$(2)) -c -o $$@ --glue
stage$(2)/lib/rustc/$(3)/main.o: rt/main.o
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
stage$(2)/lib/rustc/$(3)/$$(CFG_LIBRUSTC): \
$$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
$$(SREQ$(2))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(2)) --lib -o $$@ $$<
stage$(2)/lib/rustc/$(3)/$$(CFG_STDLIB): \
$$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
stage$(2)/rustc$$(X) \
stage$(2)/$$(CFG_RUNTIME) \
stage$(2)/$$(CFG_RUSTLLVM) \
stage$(2)/lib/rustc/$(3)/glue.o \
$$(SREQ$(1))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(2)) --lib -o $$@ $$<
stage$(2)/lib/rustc/$(3)/libstd.rlib: \
$$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
stage$(2)/rustc$$(X) \
stage$(2)/$$(CFG_RUNTIME) \
stage$(2)/$$(CFG_RUSTLLVM) \
stage$(2)/lib/rustc/$(3)/glue.o \
$$(SREQ$(1))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(2)) --lib --static -o $$@ $$<
stage$(2)/lib/rustc/$(3)/$$(CFG_RUNTIME): rt/$$(CFG_RUNTIME)
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
endef
# Instantiate template for 0->1, 1->2, 2->3 build dirs
$(eval $(call STAGEN,0,1))
$(eval $(call STAGEN,1,2))
$(eval $(call STAGEN,2,3))
# Instantiate template for 0->1, 1->2, 2->3 build dirs
$(foreach target,$(CFG_TARGET_TRIPLES), \
$(eval $(call STAGE_N,0,1,$(target))) \
$(eval $(call STAGE_N,1,2,$(target))) \
$(eval $(call STAGE_N,2,3,$(target))))

View File

@ -372,7 +372,7 @@ fn build_session_options(binary: str, match: getopts::match, binary_dir: str)
};
let library_search_paths = [binary_dir + "/lib", // FIXME: legacy
binary_dir + "/lib/" + target ];
binary_dir + "/lib/rustc/" + target ];
let lsp_vec = getopts::opt_strs(match, "L");
for lsp: str in lsp_vec { library_search_paths += [lsp]; }