Reorganize structure of build directory
Each stage is organized more according to Unix standards and to accommodate multiple target architectures. stageN/ bin - rustc lives here lib - libraries that rustc needs lib/rustc/$(target_triple/ - target libraries
This commit is contained in:
parent
79e4961c7f
commit
0148daa058
42
Makefile.in
42
Makefile.in
@ -56,7 +56,7 @@ CFG_LIBRUSTC :=$(call CFG_LIB_NAME,rustc)
|
||||
ifdef CFG_DISABLE_SHAREDSTD
|
||||
CFG_STDLIB_DEFAULT = $(1)/lib/libstd.rlib
|
||||
else
|
||||
CFG_STDLIB_DEFAULT = $(2)/$(CFG_STDLIB)
|
||||
CFG_STDLIB_DEFAULT = $(2)/lib/$(CFG_STDLIB)
|
||||
endif
|
||||
|
||||
# version-string calculation
|
||||
@ -168,21 +168,24 @@ LLC := $(CFG_LLVM_BINDIR)/llc$(X)
|
||||
|
||||
define SREQ
|
||||
ifdef CFG_DISABLE_SHAREDSTD
|
||||
SREQ$(1) = stage$(1)/rustc$(X) \
|
||||
stage$(1)/$$(CFG_RUNTIME) \
|
||||
SREQ$(1)$(2) = stage$(1)/bin/rustc$(X) \
|
||||
stage$(1)/lib/$$(CFG_RUNTIME) \
|
||||
$$(call CFG_STDLIB_DEFAULT,stage$(1),stage$(1)) \
|
||||
stage$(1)/$$(CFG_RUSTLLVM) \
|
||||
stage$(1)/lib/main.o \
|
||||
stage$(1)/lib/$$(CFG_RUNTIME) \
|
||||
stage$(1)/lib/$$(CFG_RUSTLLVM) \
|
||||
stage$(1)/lib/rustc/$(2)/$$(CFG_RUNTIME) \
|
||||
stage$(1)/lib/rustc/$(2)/$$(CFG_STDLIB) \
|
||||
stage$(1)/lib/rustc/$(2)/intrinsics.bc \
|
||||
stage$(1)/lib/rustc/$(2)/main.o \
|
||||
$$(MKFILES)
|
||||
else
|
||||
SREQ$(1) = stage$(1)/rustc$(X) \
|
||||
stage$(1)/$$(CFG_RUNTIME) \
|
||||
SREQ$(1)$(2) = stage$(1)/bin/rustc$(X) \
|
||||
stage$(1)/lib/$$(CFG_RUNTIME) \
|
||||
$$(call CFG_STDLIB_DEFAULT,stage$(1),stage$(1)) \
|
||||
stage$(1)/$$(CFG_RUSTLLVM) \
|
||||
stage$(1)/lib/main.o \
|
||||
stage$(1)/lib/$$(CFG_RUNTIME) \
|
||||
stage$(1)/lib/$$(CFG_STDLIB) \
|
||||
stage$(1)/lib/$$(CFG_RUSTLLVM) \
|
||||
stage$(1)/lib/rustc/$(2)/$$(CFG_RUNTIME) \
|
||||
stage$(1)/lib/rustc/$(2)/$$(CFG_STDLIB) \
|
||||
stage$(1)/lib/rustc/$(2)/intrinsics.bc \
|
||||
stage$(1)/lib/rustc/$(2)/main.o \
|
||||
$$(MKFILES)
|
||||
endif
|
||||
|
||||
@ -194,16 +197,17 @@ CFG_VALGRIND_COMPILE$(1) = $$(CFG_VALGRIND_COMPILE)
|
||||
endif
|
||||
|
||||
STAGE$(1) := $$(Q)$$(call CFG_RUN_TARG,stage$(1), \
|
||||
$$(CFG_VALGRIND_COMPILE$(1)) stage$(1)/rustc$$(X) \
|
||||
$$(CFG_RUSTC_FLAGS))
|
||||
$$(CFG_VALGRIND_COMPILE$(1)) stage$(1)/bin/rustc$$(X) \
|
||||
$$(CFG_RUSTC_FLAGS) --target=$(2))
|
||||
endef
|
||||
|
||||
FUZZ := stage1/fuzzer$(X)
|
||||
FUZZ := stage1/bin/fuzzer$(X)
|
||||
|
||||
$(eval $(call SREQ,0))
|
||||
$(eval $(call SREQ,1))
|
||||
$(eval $(call SREQ,2))
|
||||
$(eval $(call SREQ,3))
|
||||
$(foreach target,$(CFG_TARGET_TRIPLES), \
|
||||
$(eval $(call SREQ,0,$(target))) \
|
||||
$(eval $(call SREQ,1,$(target))) \
|
||||
$(eval $(call SREQ,2,$(target))) \
|
||||
$(eval $(call SREQ,3,$(target))))
|
||||
|
||||
######################################################################
|
||||
# Entrypoint rule
|
||||
|
@ -3,7 +3,7 @@
|
||||
FUZZER_CRATE := $(S)src/fuzzer/fuzzer.rc
|
||||
FUZZER_INPUTS := $(wildcard $(addprefix $(S)src/fuzzer/, *.rs))
|
||||
|
||||
stage1/fuzzer$(X): $(FUZZER_CRATE) $(FUZZER_INPUTS) $(SREQ1) \
|
||||
stage1/lib/$(CFG_LIBRUSTC)
|
||||
stage1/bin/fuzzer$(X): $(FUZZER_CRATE) $(FUZZER_INPUTS) $(SREQ1) \
|
||||
stage1/lib/rustc/$(CFG_HOST_TRIPLE)/$(CFG_LIBRUSTC)
|
||||
@$(call E, compile_and_link: $@)
|
||||
$(STAGE1) -o $@ $<
|
||||
|
@ -98,7 +98,7 @@ ifdef CFG_UNIXY
|
||||
CFG_EXE_SUFFIX :=
|
||||
CFG_LDPATH :=
|
||||
CFG_RUN=$(CFG_LDENV)=$(1) $(2)
|
||||
CFG_RUN_TARG=$(call CFG_RUN,$(CFG_BUILD_DIR)/$(1),$(2))
|
||||
CFG_RUN_TARG=$(call CFG_RUN,$(CFG_BUILD_DIR)/$(1)/lib,$(2))
|
||||
CFG_RUN_TEST=$(call CFG_RUN,$(call CFG_TESTLIB,$(1)),\
|
||||
$(CFG_VALGRIND) $(1))
|
||||
CFG_LIBUV_LINK_FLAGS=-lpthread
|
||||
|
18
mk/stage0.mk
18
mk/stage0.mk
@ -1,25 +1,31 @@
|
||||
# FIXME: temporary hack: stdlib and rustrt come in the lib/ directory,
|
||||
# but we want them in the base directory, so we move them out.
|
||||
stage0/rustc$(X): $(S)src/snapshots.txt $(S)src/etc/get-snapshot.py $(MKFILES)
|
||||
stage0/bin/rustc$(X): $(S)src/snapshots.txt $(S)src/etc/get-snapshot.py $(MKFILES)
|
||||
@$(call E, fetch: $@)
|
||||
$(Q)$(S)src/etc/get-snapshot.py
|
||||
$(Q)mv stage0/lib/$(CFG_STDLIB) stage0/$(CFG_STDLIB)
|
||||
$(Q)cp stage0/rustc$(X) stage0/bin/rustc$(X)
|
||||
$(Q)cp stage0/$(CFG_RUNTIME) stage0/lib/$(CFG_RUNTIME)
|
||||
$(Q)cp stage0/$(CFG_RUSTLLVM) stage0/lib/$(CFG_RUSTLLVM)
|
||||
$(Q)mkdir -p stage0/bin/lib
|
||||
$(Q)cp stage0/lib/intrinsics.bc stage0/bin/lib/intrinsics.bc
|
||||
$(Q)cp stage0/lib/glue.o stage0/bin/lib/glue.o
|
||||
$(Q)cp stage0/lib/main.o stage0/bin/lib/main.o
|
||||
$(Q)touch $@
|
||||
|
||||
# Host libs will be made in the process of making rustc above.
|
||||
|
||||
stage0/$(CFG_RUNTIME): stage0/rustc$(X)
|
||||
stage0/lib/$(CFG_RUNTIME): stage0/bin/rustc$(X)
|
||||
$(Q)touch $@
|
||||
|
||||
stage0/$(CFG_STDLIB): stage0/rustc$(X)
|
||||
stage0/lib/$(CFG_STDLIB): stage0/bin/rustc$(X)
|
||||
$(Q)touch $@
|
||||
|
||||
stage0/$(CFG_RUSTLLVM): stage0/rustc$(X)
|
||||
stage0/lib/$(CFG_RUSTLLVM): stage0/bin/rustc$(X)
|
||||
$(Q)touch $@
|
||||
|
||||
# Instantiate template (in stageN.mk) for building
|
||||
# target libraries.
|
||||
|
||||
SREQpre = stage0/lib/main.o $(MKFILES)
|
||||
SREQpre = stage0/lib/$(CFG_HOST_TRIPLE)/main.o $(MKFILES)
|
||||
$(eval $(call TARGET_LIBS,pre,0,$(CFG_HOST_TRIPLE)))
|
||||
|
||||
|
96
mk/stageN.mk
96
mk/stageN.mk
@ -20,34 +20,41 @@ define STAGE_N
|
||||
# compiler that relies on a .o file.
|
||||
|
||||
STAGE$(2) := $$(Q)$$(call CFG_RUN_TARG,stage$(2), \
|
||||
$$(CFG_VALGRIND_COMPILE) stage$(2)/rustc$$(X) \
|
||||
$$(CFG_RUSTC_FLAGS))
|
||||
$$(CFG_VALGRIND_COMPILE) stage$(2)/bin/rustc$$(X) \
|
||||
$$(CFG_RUSTC_FLAGS) --target=$(3))
|
||||
|
||||
PERF_STAGE$(2) := $$(Q)$$(call CFG_RUN_TARG,stage$(2), \
|
||||
$$(CFG_PERF_TOOL) stage$(2)/rustc$$(X) \
|
||||
$$(CFG_RUSTC_FLAGS))
|
||||
$$(CFG_PERF_TOOL) stage$(2)/bin/rustc$$(X) \
|
||||
$$(CFG_RUSTC_FLAGS) --target=$(3))
|
||||
|
||||
stage$(2)/%.o: stage$(2)/%.s
|
||||
stage$(2)/bin/%.o: stage$(2)/bin/%.s
|
||||
@$$(call E, assemble [gcc]: $$@)
|
||||
$$(Q)gcc $$(CFG_GCCISH_CFLAGS) -o $$@ -c $$<
|
||||
|
||||
stage$(2)/rustc$$(X): $$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
|
||||
stage$(2)/$$(CFG_RUNTIME) \
|
||||
$$(call CFG_STDLIB_DEFAULT,stage$(1),stage$(2)) \
|
||||
stage$(2)/$$(CFG_RUSTLLVM) \
|
||||
$$(SREQ$(1))
|
||||
stage$(2)/lib/%.o: stage$(2)/lib/%.s
|
||||
@$$(call E, assemble [gcc]: $$@)
|
||||
$$(Q)gcc $$(CFG_GCCISH_CFLAGS) -o $$@ -c $$<
|
||||
|
||||
# FIXME: the bin/lib/libstd.so dep is transitional
|
||||
|
||||
stage$(2)/bin/rustc$$(X): $$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
|
||||
stage$(2)/lib/$$(CFG_RUNTIME) \
|
||||
$$(call CFG_STDLIB_DEFAULT,stage$(1),stage$(2)) \
|
||||
stage$(2)/lib/$$(CFG_RUSTLLVM) \
|
||||
stage$(1)/bin/lib/$$(CFG_STDLIB) \
|
||||
$$(SREQ$(1)$(3))
|
||||
@$$(call E, compile_and_link: $$@)
|
||||
$$(STAGE$(1)) -L stage$(2) -o $$@ $$<
|
||||
|
||||
stage$(2)/$$(CFG_RUNTIME): rt/$$(CFG_RUNTIME)
|
||||
stage$(2)/lib/$$(CFG_RUNTIME): rt/$$(CFG_RUNTIME)
|
||||
@$$(call E, cp: $$@)
|
||||
$$(Q)cp $$< $$@
|
||||
|
||||
stage$(2)/$$(CFG_STDLIB): stage$(1)/lib/$$(CFG_STDLIB)
|
||||
stage$(2)/lib/$$(CFG_STDLIB): stage$(1)/lib/rustc/$$(CFG_HOST_TRIPLE)/$$(CFG_STDLIB)
|
||||
@$$(call E, cp: $$@)
|
||||
$$(Q)cp $$< $$@
|
||||
|
||||
stage$(2)/$$(CFG_RUSTLLVM): rustllvm/$$(CFG_RUSTLLVM)
|
||||
stage$(2)/lib/$$(CFG_RUSTLLVM): rustllvm/$$(CFG_RUSTLLVM)
|
||||
@$$(call E, cp: $$@)
|
||||
$$(Q)cp $$< $$@
|
||||
|
||||
@ -59,41 +66,6 @@ endef
|
||||
|
||||
|
||||
define TARGET_LIBS
|
||||
stage$(2)/lib/intrinsics.bc: $$(INTRINSICS_BC)
|
||||
@$$(call E, cp: $$@)
|
||||
$$(Q)cp $$< $$@
|
||||
|
||||
stage$(2)/lib/main.o: rt/main.o
|
||||
@$$(call E, cp: $$@)
|
||||
$$(Q)cp $$< $$@
|
||||
|
||||
stage$(2)/lib/$$(CFG_LIBRUSTC): $$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
|
||||
$$(SREQ$(2))
|
||||
@$$(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/intrinsics.bc \
|
||||
$$(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/intrinsics.bc \
|
||||
$$(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
|
||||
@ -109,30 +81,36 @@ stage$(2)/lib/rustc/$(3)/main.o: rt/main.o
|
||||
|
||||
stage$(2)/lib/rustc/$(3)/$$(CFG_LIBRUSTC): \
|
||||
$$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
|
||||
$$(SREQ$(2))
|
||||
$$(SREQ$(2)$(3))
|
||||
@$$(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/intrinsics.bc \
|
||||
$$(SREQ$(1))
|
||||
stage$(2)/bin/rustc$$(X) \
|
||||
stage$(2)/lib/$$(CFG_RUNTIME) \
|
||||
stage$(2)/lib/$$(CFG_RUSTLLVM) \
|
||||
stage$(2)/lib/rustc/$(3)/intrinsics.bc \
|
||||
$$(SREQ$(1)$(3))
|
||||
@$$(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/intrinsics.bc \
|
||||
$$(SREQ$(1))
|
||||
stage$(2)/bin/rustc$$(X) \
|
||||
stage$(2)/lib/$$(CFG_RUNTIME) \
|
||||
stage$(2)/lib/$$(CFG_RUSTLLVM) \
|
||||
stage$(2)/lib/rustc/$(3)/intrinsics.bc \
|
||||
$$(SREQ$(1)$(3))
|
||||
@$$(call E, compile_and_link: $$@)
|
||||
$$(STAGE$(2)) --lib --static -o $$@ $$<
|
||||
|
||||
# FIXME: Transitional so that stage0 can find std when building stage1/rustc
|
||||
stage$(2)/bin/lib/$$(CFG_STDLIB): stage$(2)/lib/rustc/$(3)/$$(CFG_STDLIB)
|
||||
@$$(call E, cp: $$@)
|
||||
$$(Q)mkdir -p stage$(2)/bin/lib
|
||||
$$(Q)cp $$< $$@
|
||||
|
||||
stage$(2)/lib/rustc/$(3)/$$(CFG_RUNTIME): rt/$$(CFG_RUNTIME)
|
||||
@$$(call E, cp: $$@)
|
||||
$$(Q)cp $$< $$@
|
||||
|
26
mk/tests.mk
26
mk/tests.mk
@ -131,7 +131,7 @@ check-stage$(2): tidy \
|
||||
check-stage$(2)-std: test/stdtest.stage$(2).out \
|
||||
|
||||
test/stdtest.stage$(2)$$(X): $$(STDTEST_CRATE) $$(STDTEST_INPUTS) \
|
||||
$$(SREQ$(2))
|
||||
$$(SREQ$(2)$(CFG_HOST_TRIPLE))
|
||||
@$$(call E, compile_and_link: $$@)
|
||||
$$(STAGE$(2)) -o $$@ $$< --test
|
||||
|
||||
@ -146,16 +146,16 @@ test/stdtest.stage$(2).out.tmp: test/stdtest.stage$(2)$$(X)
|
||||
check-stage$(2)-rustc: test/rustctest.stage$(2).out \
|
||||
|
||||
test/rustctest.stage$(2)$$(X): $$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
|
||||
stage$(2)/$$(CFG_RUNTIME) \
|
||||
stage$(2)/lib/$$(CFG_RUNTIME) \
|
||||
$$(call CFG_STDLIB_DEFAULT,stage$(1),stage$(2)) \
|
||||
stage$(2)/$$(CFG_RUSTLLVM) \
|
||||
$$(SREQ$(1))
|
||||
stage$(2)/lib/$$(CFG_RUSTLLVM) \
|
||||
$$(SREQ$(1)$(CFG_HOST_TRIPLE))
|
||||
@$$(call E, compile_and_link: $$@)
|
||||
$$(STAGE$(1)) -o $$@ $$< --test
|
||||
|
||||
test/rustctest.stage$(2).out.tmp: test/rustctest.stage$(2)$$(X)
|
||||
@$$(call E, run: $$<)
|
||||
$$(Q)$$(call CFG_RUN,stage$(2),$$(CFG_VALGRIND) $$<) \
|
||||
$$(Q)$$(call CFG_RUN,$(CFG_BUILD_DIR)/stage$(2)/lib,$$(CFG_VALGRIND) $$<) \
|
||||
$$(TESTARGS)
|
||||
$$(Q)touch $$@
|
||||
|
||||
@ -185,11 +185,11 @@ check-stage$(2)-pretty: check-stage$(2)-pretty-rpass \
|
||||
check-stage$(2)-pretty-bench \
|
||||
check-stage$(2)-pretty-pretty \
|
||||
|
||||
CTEST_COMMON_ARGS$(2) := --compile-lib-path stage$(2) \
|
||||
--run-lib-path stage$(2)/lib \
|
||||
--rustc-path stage$(2)/rustc$$(X) \
|
||||
CTEST_COMMON_ARGS$(2) := --compile-lib-path stage$(2)/lib \
|
||||
--run-lib-path stage$(2)/lib/$$(CFG_HOST_TRIPLE) \
|
||||
--rustc-path stage$(2)/bin/rustc$$(X) \
|
||||
--stage-id stage$(2) \
|
||||
--rustcflags "$$(CFG_RUSTC_FLAGS)" \
|
||||
--rustcflags "--target=$$(CFG_HOST_TRIPLE) $$(CFG_RUSTC_FLAGS)" \
|
||||
$$(CTEST_TESTARGS) \
|
||||
|
||||
CFAIL_ARGS$(2) := $$(CTEST_COMMON_ARGS$(2)) \
|
||||
@ -243,7 +243,7 @@ PRETTY_PRETTY_ARGS$(2) := $$(CTEST_COMMON_ARGS$(2)) \
|
||||
|
||||
test/compiletest.stage$(2)$$(X): $$(COMPILETEST_CRATE) \
|
||||
$$(COMPILETEST_INPUTS) \
|
||||
$$(SREQ$(2))
|
||||
$$(SREQ$(2)$(CFG_HOST_TRIPLE))
|
||||
@$$(call E, compile_and_link: $$@)
|
||||
$$(STAGE$(2)) -o $$@ $$<
|
||||
|
||||
@ -320,13 +320,13 @@ test/$(FT).rc test/$(FT_DRIVER).rs: $(TEST_RPASS_SOURCES_STAGE2) \
|
||||
@$(call E, check: building combined stage2 test runner)
|
||||
$(Q)$(S)src/etc/combine-tests.py
|
||||
|
||||
stage2/lib/$(FT_LIB): test/$(FT).rc $(SREQ2)
|
||||
stage2/lib/$(FT_LIB): test/$(FT).rc $(SREQ2$(CFG_HOST_TRIPLE))
|
||||
@$(call E, compile_and_link: $@)
|
||||
$(STAGE2) --lib -o $@ $<
|
||||
|
||||
test/$(FT_DRIVER)$(X): test/$(FT_DRIVER).rs stage2/lib/$(FT_LIB) $(SREQ2)
|
||||
test/$(FT_DRIVER)$(X): test/$(FT_DRIVER).rs stage2/lib/$(FT_LIB) $(SREQ2$(CFG_HOST_TRIPLE))
|
||||
@$(call E, compile_and_link: $@)
|
||||
$(STAGE2) -o $@ $<
|
||||
|
||||
test/$(FT_DRIVER).out: test/$(FT_DRIVER)$(X) $(SREQ2)
|
||||
test/$(FT_DRIVER).out: test/$(FT_DRIVER)$(X) $(SREQ2$(CFG_HOST_TRIPLE))
|
||||
$(Q)$(call CFG_RUN_TEST, $<)
|
||||
|
@ -39,8 +39,23 @@ fn llvm_err(sess: session::session, msg: str) {
|
||||
} else { sess.fatal(msg + ": " + str::str_from_cstr(buf)); }
|
||||
}
|
||||
|
||||
fn get_target_lib_path(sess: session::session) -> fs::path {
|
||||
let path = [
|
||||
sess.get_opts().sysroot,
|
||||
"lib/rustc",
|
||||
sess.get_opts().target_triple];
|
||||
check vec::is_not_empty(path);
|
||||
let path = fs::connect_many(path);
|
||||
ret path;
|
||||
}
|
||||
|
||||
fn get_target_lib_file_path(sess: session::session,
|
||||
file: fs::path) -> fs::path {
|
||||
fs::connect(get_target_lib_path(sess), file)
|
||||
}
|
||||
|
||||
fn link_intrinsics(sess: session::session, llmod: ModuleRef) {
|
||||
let path = fs::connect(sess.get_opts().sysroot, "lib/intrinsics.bc");
|
||||
let path = get_target_lib_file_path(sess, "intrinsics.bc");
|
||||
let membuf = str::as_buf(path, {|buf|
|
||||
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf)
|
||||
});
|
||||
@ -495,10 +510,9 @@ fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: str) -> str {
|
||||
// If the user wants an exe generated we need to invoke
|
||||
// gcc to link the object file with some libs
|
||||
fn link_binary(sess: session::session,
|
||||
binary_dir: str,
|
||||
saved_out_filename: str) {
|
||||
let main: str = binary_dir + "/lib/main.o";
|
||||
let stage: str = "-L" + binary_dir + "/lib";
|
||||
let main: str = get_target_lib_file_path(sess, "main.o");
|
||||
let stage: str = "-L" + get_target_lib_path(sess);
|
||||
let prog: str = "gcc";
|
||||
// The invocations of gcc share some flags across platforms
|
||||
|
||||
|
@ -294,8 +294,8 @@ fn get_arch(triple: str) -> session::arch {
|
||||
|
||||
fn get_default_sysroot(binary: str) -> str {
|
||||
let dirname = fs::dirname(binary);
|
||||
if str::eq(dirname, binary) { ret "."; }
|
||||
ret dirname;
|
||||
if str::eq(dirname, binary) { ret "../"; }
|
||||
ret fs::connect(dirname, "../");
|
||||
}
|
||||
|
||||
fn build_target_config(sopts: @session::options) -> @session::config {
|
||||
@ -312,7 +312,7 @@ fn host_triple() -> str {
|
||||
str::str_from_cstr(llvm::llvm::LLVMRustGetHostTriple())
|
||||
}
|
||||
|
||||
fn build_session_options(binary: str, match: getopts::match, binary_dir: str)
|
||||
fn build_session_options(binary: str, match: getopts::match)
|
||||
-> @session::options {
|
||||
let library = opt_present(match, "lib");
|
||||
let static = opt_present(match, "static");
|
||||
@ -370,8 +370,9 @@ fn build_session_options(binary: str, match: getopts::match, binary_dir: str)
|
||||
some(s) { s }
|
||||
};
|
||||
|
||||
let library_search_paths = [binary_dir + "/lib", // FIXME: legacy
|
||||
binary_dir + "/lib/rustc/" + target ];
|
||||
let library_search_paths = [
|
||||
fs::connect(sysroot, "lib"), // FIXME: legacy
|
||||
fs::connect(sysroot, "lib/rustc/" + target )];
|
||||
let lsp_vec = getopts::opt_strs(match, "L");
|
||||
for lsp: str in lsp_vec { library_search_paths += [lsp]; }
|
||||
|
||||
@ -436,7 +437,6 @@ fn opts() -> [getopts::opt] {
|
||||
|
||||
fn main(args: [str]) {
|
||||
let binary = vec::shift(args);
|
||||
let binary_dir = fs::dirname(binary);
|
||||
let match =
|
||||
alt getopts::getopts(args, opts()) {
|
||||
getopts::success(m) { m }
|
||||
@ -453,7 +453,7 @@ fn main(args: [str]) {
|
||||
version(binary);
|
||||
ret;
|
||||
}
|
||||
let sopts = build_session_options(binary, match, binary_dir);
|
||||
let sopts = build_session_options(binary, match);
|
||||
let sess = build_session(sopts);
|
||||
let n_inputs = vec::len::<str>(match.free);
|
||||
let output_file = getopts::opt_maybe_str(match, "o");
|
||||
@ -521,7 +521,7 @@ fn main(args: [str]) {
|
||||
|
||||
if stop_after_codegen { ret; }
|
||||
|
||||
link::link_binary(sess, binary_dir, saved_out_filename);
|
||||
link::link_binary(sess, saved_out_filename);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@ -534,7 +534,7 @@ mod test {
|
||||
alt getopts::getopts(["--test"], opts()) {
|
||||
getopts::success(m) { m }
|
||||
};
|
||||
let sessopts = build_session_options("whatever", match, "whatever");
|
||||
let sessopts = build_session_options("whatever", match);
|
||||
let sess = build_session(sessopts);
|
||||
let cfg = build_configuration(sess, "whatever", "whatever");
|
||||
assert (attr::contains_name(cfg, "test"));
|
||||
@ -548,7 +548,7 @@ mod test {
|
||||
alt getopts::getopts(["--test", "--cfg=test"], opts()) {
|
||||
getopts::success(m) { m }
|
||||
};
|
||||
let sessopts = build_session_options("whatever", match, "whatever");
|
||||
let sessopts = build_session_options("whatever", match);
|
||||
let sess = build_session(sessopts);
|
||||
let cfg = build_configuration(sess, "whatever", "whatever");
|
||||
let test_items = attr::find_meta_items_by_name(cfg, "test");
|
||||
|
@ -41,6 +41,16 @@ fn connect(pre: path, post: path) -> path {
|
||||
} else { pre + path_sep() + post };
|
||||
}
|
||||
|
||||
fn connect_many(paths: [path]) : vec::is_not_empty(paths) -> path {
|
||||
ret if vec::len(paths) == 1u {
|
||||
paths[0]
|
||||
} else {
|
||||
let rest = vec::slice(paths, 1u, vec::len(paths));
|
||||
check vec::is_not_empty(rest);
|
||||
connect(paths[0], connect_many(rest))
|
||||
}
|
||||
}
|
||||
|
||||
fn file_is_dir(p: path) -> bool {
|
||||
ret str::as_buf(p, {|buf| rustrt::rust_file_is_dir(buf) != 0 });
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user