rustc: build versioned library with hash in its name

Also updated build to install versioned libraries and added a few
missing actions for `make clean`.
This commit is contained in:
Haitao Li 2011-12-03 00:51:59 +08:00 committed by Graydon Hoare
parent b4f450a793
commit 6dbd4c21e9
10 changed files with 56 additions and 20 deletions

View File

@ -108,6 +108,10 @@ CFG_CORELIB :=$(call CFG_LIB_NAME,core)
CFG_STDLIB :=$(call CFG_LIB_NAME,std)
CFG_LIBRUSTC :=$(call CFG_LIB_NAME,rustc)
STDLIB_GLOB :=$(call CFG_LIB_GLOB,std)
CORELIB_GLOB :=$(call CFG_LIB_GLOB,core)
LIBRUSTC_GLOB :=$(call CFG_LIB_GLOB,rustc)
# version-string calculation
CFG_GIT_DIR := $(CFG_SRC_DIR).git
CFG_VERSION = prerelease

View File

@ -56,7 +56,12 @@ clean$(1)_H_$(2):
$(Q)rm -f $$(HBIN$(1)_H_$(2))/fuzzer$(X)
$(Q)rm -f $$(HBIN$(1)_H_$(2))/cargo$(X)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(CFG_RUNTIME)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(CFG_CORELIB)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(CFG_STDLIB)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(CFG_LIBRUSTC)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(CORELIB_GLOB)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(STDLIB_GLOB)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(LIBRUSTC_GLOB)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(CFG_RUSTLLVM)
$(Q)rm -f $$(HLIB$(1)_H_$(2))/libstd.rlib
@ -72,7 +77,12 @@ clean$(1)_T_$(2)_H_$(3):
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/rustc$(X)
$(Q)rm -f $$(TBIN$(1)_T_$(2)_H_$(3))/fuzzer$(X)
$(Q)rm -f $$(TLIB$(1)_T_$(2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$$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME)
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
$$(Q)cp $$(TLIB$(1)_T_$(4)_H_$(3))/$(STDLIB_GLOB) \
$$(HLIB$(2)_H_$(4))
$$(HLIB$(2)_H_$(4))/libcore.rlib: \
$$(TLIB$(1)_T_$(4)_H_$(3))/libcore.rlib \

View File

@ -3,11 +3,14 @@
# mirror of the installation directory structure.
# Installation macro. Call with source directory as arg 1,
# destination directory as arg 2, and filename as arg 3
# destination directory as arg 2, and filename/libname-glob as arg 3
ifdef VERBOSE
INSTALL = cp $(1)/$(3) $(2)/$(3)
INSTALL_LIB = cp `ls -rt1 $(1)/$(3) | tail -1` $(2)/
else
INSTALL = $(Q)$(call E, install: $(2)/$(3)) && cp $(1)/$(3) $(2)/$(3)
INSTALL_LIB = $(Q)$(call E, install_lib: $(2)/$(3)) && \
cp `ls -rt1 $(1)/$(3) | tail -1` $(2)/
endif
# The stage we install from
@ -33,8 +36,10 @@ PTL$(1)$(2) = $$(PTR$(1)$(2))/lib
install-target-$(1)-host-$(2): $$(SREQ$$(ISTAGE)_T_$(1)_H_$(2))
$$(Q)mkdir -p $$(PTL$(1)$(2))
$$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(CFG_RUNTIME))
$$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(CFG_CORELIB))
$$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(CFG_STDLIB))
$$(Q)$$(call INSTALL_LIB, \
$$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(CORELIB_GLOB))
$$(Q)$$(call INSTALL_LIB, \
$$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(STDLIB_GLOB))
$$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),intrinsics.bc)
$$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),libmorestack.a)
endef
@ -62,8 +67,8 @@ install-host: $(SREQ$(ISTAGE)_T_$(CFG_HOST_TRIPLE)_H_$(CFG_HOST_TRIPLE))
$(Q)mkdir -p $(PREFIX_ROOT)/share/man/man1
$(Q)$(call INSTALL,$(HB),$(PHB),rustc$(X))
$(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_RUNTIME))
$(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_CORELIB))
$(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_STDLIB))
$(Q)$(call INSTALL_LIB,$(HL),$(PHL),$(CORELIB_GLOB))
$(Q)$(call INSTALL_LIB,$(HL),$(PHL),$(STDLIB_GLOB))
$(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_RUSTLLVM))
$(Q)$(call INSTALL,$(S)/man, \
$(PREFIX_ROOT)/share/man/man1,rustc.1)

View File

@ -23,6 +23,7 @@ endif
ifneq ($(findstring freebsd,$(CFG_OSTYPE)),)
CFG_LIB_NAME=lib$(1).so
CFG_LIB_GLOB=lib$(1)-*.so
CFG_GCCISH_CFLAGS += -fPIC -march=i686 -I/usr/local/include
CFG_GCCISH_LINK_FLAGS += -shared -fPIC -lpthread -lrt
ifeq ($(CFG_CPUTYPE), x86_64)
@ -40,6 +41,7 @@ endif
ifneq ($(findstring linux,$(CFG_OSTYPE)),)
CFG_LIB_NAME=lib$(1).so
CFG_LIB_GLOB=lib$(1)-*.so
CFG_GCCISH_CFLAGS += -fPIC
CFG_GCCISH_LINK_FLAGS += -shared -fPIC -ldl -lpthread -lrt
CFG_GCCISH_DEF_FLAG := -Wl,--export-dynamic,--dynamic-list=
@ -71,6 +73,7 @@ endif
ifneq ($(findstring darwin,$(CFG_OSTYPE)),)
CFG_LIB_NAME=lib$(1).dylib
CFG_LIB_GLOB=lib$(1)-*.dylib
CFG_UNIXY := 1
CFG_LDENV := DYLD_LIBRARY_PATH
CFG_GCCISH_LINK_FLAGS += -dynamiclib -lpthread -framework CoreServices
@ -156,6 +159,7 @@ ifdef CFG_WINDOWSY
CFG_EXE_SUFFIX := .exe
CFG_LIB_NAME=$(1).dll
CFG_LIB_GLOB=$(1)-*.dll
CFG_DEF_SUFFIX := .def
CFG_LDPATH :=$(CFG_LDPATH):$$PATH
CFG_RUN=PATH="$(CFG_LDPATH):$(1)" $(2)

View File

@ -26,14 +26,14 @@ $$(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)) --no-core --lib -o $$@ $$<
$$(STAGE$(1)_T_$(2)_H_$(3)) --no-core --lib -o $$@ $$< && touch $$@
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB): \
$$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
$$(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)) --lib -o $$@ $$<
$$(STAGE$(1)_T_$(2)_H_$(3)) --lib -o $$@ $$< && touch $$@
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUNTIME): \
rt/$(2)/$$(CFG_RUNTIME)
@ -59,7 +59,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC): \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUSTLLVM) \
$$(TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) --lib -o $$@ $$<
$$(STAGE$(1)_T_$(2)_H_$(3)) --lib -o $$@ $$< && touch $$@
endef

View File

@ -551,7 +551,8 @@ fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: str) -> str {
// gcc to link the object file with some libs
fn link_binary(sess: session::session,
obj_filename: str,
out_filename: str) {
out_filename: str,
lm: link_meta) {
// The default library location, we need this to find the runtime.
// The location of crates will be determined as needed.
let stage: str = "-L" + sess.filesearch().get_target_lib_path();
@ -611,14 +612,17 @@ fn link_binary(sess: session::session,
let used_libs = cstore::get_used_libraries(cstore);
for l: str in used_libs { gcc_args += ["-l" + l]; }
let long_libname =
std::os::dylib_filename(#fmt("%s-%s-%s",
lm.name, lm.extras_hash, lm.vers));
if sess.building_library() {
gcc_args += [lib_cmd];
// On mac we need to tell the linker to let this library
// be rpathed
if sess.get_targ_cfg().os == session::os_macos {
gcc_args += ["-Wl,-install_name,@rpath/"
+ fs::basename(out_filename)];
gcc_args += ["-Wl,-install_name,@rpath/" + long_libname];
}
} else {
// FIXME: why do we hardcode -lm?
@ -651,19 +655,22 @@ fn link_binary(sess: session::session,
sess.note(prog.err + prog.out);
sess.abort_if_errors();
}
// Clean up on Darwin
// Clean up on Darwin
if sess.get_targ_cfg().os == session::os_macos {
run::run_program("dsymutil", [out_filename]);
}
// Remove the temporary object file if we aren't saving temps
if !sess.get_opts().save_temps {
run::run_program("rm", [obj_filename]);
}
}
if sess.building_library() {
let fullname = fs::connect(fs::dirname(out_filename), long_libname);
run::run_program("mv", [out_filename, fullname]);
}
}
//
// Local Variables:
// mode: rust

View File

@ -10,7 +10,7 @@ import middle::{trans, resolve, freevars, kind, ty, typeck, fn_usage,
import syntax::print::{pp, pprust};
import util::{ppaux, filesearch};
import back::link;
import std::{option, str, vec, int, io, getopts, result};
import std::{fs, option, str, vec, int, io, getopts, result};
import std::option::{some, none};
import std::getopts::{optopt, optmulti, optflag, optflagopt, opt_present};
import back::{x86, x86_64};
@ -193,7 +193,7 @@ fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
let outputs = build_output_filenames(input, output, sess);
let llmod =
let (llmod, link_meta) =
time(time_passes, "translation",
bind trans::trans_crate(sess, crate, ty_cx,
outputs.obj_filename, ast_map,
@ -209,7 +209,7 @@ fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
time(time_passes, "Linking",
bind link::link_binary(sess, outputs.obj_filename,
outputs.out_filename));
outputs.out_filename, link_meta));
}
fn pretty_print_input(sess: session::session, cfg: ast::crate_cfg, input: str,

View File

@ -157,7 +157,7 @@ fn find_library_crate_aux(sess: session::session,
metas: [@ast::meta_item],
filesearch: filesearch::filesearch) ->
option::t<{ident: str, data: @[u8]}> {
let prefix: str = nn.prefix + crate_name;
let prefix: str = nn.prefix + crate_name + "-";
let suffix: str = nn.suffix;
ret filesearch::search(filesearch, { |path|

View File

@ -6020,7 +6020,7 @@ fn write_abi_version(ccx: @crate_ctxt) {
fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
output: str, amap: ast_map::map, mut_map: mut::mut_map,
copy_map: alias::copy_map, last_uses: last_use::last_uses)
-> ModuleRef {
-> (ModuleRef, link::link_meta) {
let sha = std::sha1::mk_sha1();
let link_meta = link::build_link_meta(sess, *crate, output, sha);
@ -6138,7 +6138,7 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
log_err #fmt["time: %s took %d ms", timing.ident, timing.time];
}
}
ret llmod;
ret (llmod, link_meta);
}
//
// Local Variables: