rustc: Stop putting hashes in filenames by default
The compiler will no longer insert a hash or version into a filename by default. Instead, all output is simply based off the crate name being compiled. For example, a crate name of `foo` would produce the following outputs: * bin => foo * rlib => libfoo.rlib * dylib => libfoo.{so,dylib} or foo.dll * staticlib => libfoo.a The old behavior has been moved behind a new codegen flag, `-C extra-filename=<hash>`. For example, with the "extra filename" of `bar` and a crate name of `foo`, the following outputs would be generated: * bin => foo (same old behavior) * rlib => libfoobar.rlib * dylib => libfoobar.{so,dylib} or foobar.dll * staticlib => libfoobar.a The makefiles have been altered to pass a hash by default to invocations of `rustc` so all installed rust libraries will have a hash in their filename. This is done because the standard libraries are intended to be installed into privileged directories such as /usr/local. Additionally, it involves very few build system changes! RFC: 0035-remove-crate-id [breaking-change]
This commit is contained in:
parent
e44c2b9bbc
commit
df4ea9c39a
5 changed files with 19 additions and 20 deletions
|
@ -16,6 +16,8 @@
|
|||
CFG_RELEASE_NUM=0.11.0
|
||||
CFG_RELEASE_LABEL=
|
||||
|
||||
CFG_FILENAME_EXTRA=4e7c5e5c
|
||||
|
||||
ifndef CFG_ENABLE_NIGHTLY
|
||||
# This is the normal version string
|
||||
CFG_RELEASE=$(CFG_RELEASE_NUM)$(CFG_RELEASE_LABEL)
|
||||
|
|
11
mk/target.mk
11
mk/target.mk
|
@ -44,6 +44,13 @@ $(foreach host,$(CFG_HOST), \
|
|||
$(foreach crate,$(CRATES), \
|
||||
$(eval $(call RUST_CRATE_FULLDEPS,$(stage),$(target),$(host),$(crate)))))))
|
||||
|
||||
# NOTE: after a stage0 snap this should be just EXTRA_FILENAME, not with a stage
|
||||
# bound
|
||||
EXTRA_FILENAME_0 =
|
||||
EXTRA_FILENAME_1 = -C extra-filename=-$(CFG_FILENAME_EXTRA)
|
||||
EXTRA_FILENAME_2 = -C extra-filename=-$(CFG_FILENAME_EXTRA)
|
||||
EXTRA_FILENAME_3 = -C extra-filename=-$(CFG_FILENAME_EXTRA)
|
||||
|
||||
# RUST_TARGET_STAGE_N template: This defines how target artifacts are built
|
||||
# for all stage/target architecture combinations. This is one giant rule which
|
||||
# works as follows:
|
||||
|
@ -85,7 +92,9 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
|
|||
-L "$$(LLVM_LIBDIR_$(2))" \
|
||||
-L "$$(dir $$(LLVM_STDCPP_LOCATION_$(2)))" \
|
||||
$$(RUSTFLAGS_$(4)) \
|
||||
--out-dir $$(@D) $$<
|
||||
--out-dir $$(@D) \
|
||||
$$(EXTRA_FILENAME_$(1)) \
|
||||
$$<
|
||||
@touch $$@
|
||||
$$(call LIST_ALL_OLD_GLOB_MATCHES,\
|
||||
$$(dir $$@)$$(call CFG_LIB_GLOB_$(2),$(4)))
|
||||
|
|
|
@ -588,18 +588,6 @@ pub fn find_crate_name(sess: Option<&Session>,
|
|||
}), None)
|
||||
}
|
||||
|
||||
pub fn crate_name_hash(sess: &Session, crate_name: &str) -> String {
|
||||
// This calculates CMH as defined above. Note that we don't use the path of
|
||||
// the crate id in the hash because lookups are only done by (name/vers),
|
||||
// not by path.
|
||||
let mut s = Sha256::new();
|
||||
s.input_str(crate_name);
|
||||
for meta in sess.crate_metadata.borrow().iter() {
|
||||
s.input_str(meta.as_slice());
|
||||
}
|
||||
truncated_hash_result(&mut s).as_slice().slice_to(8).to_string()
|
||||
}
|
||||
|
||||
pub fn build_link_meta(krate: &ast::Crate, name: String) -> LinkMeta {
|
||||
let r = LinkMeta {
|
||||
crate_name: name,
|
||||
|
@ -880,7 +868,7 @@ pub fn filename_for_input(sess: &Session,
|
|||
crate_type: config::CrateType,
|
||||
name: &str,
|
||||
out_filename: &Path) -> Path {
|
||||
let libname = format!("{}-{}", name, crate_name_hash(sess, name));
|
||||
let libname = format!("{}{}", name, sess.opts.cg.extra_filename);
|
||||
match crate_type {
|
||||
config::CrateTypeRlib => {
|
||||
out_filename.with_filename(format!("lib{}.rlib", libname))
|
||||
|
|
|
@ -320,6 +320,8 @@ cgoptions!(
|
|||
"choose the relocation model to use (llc -relocation-model for details)"),
|
||||
metadata: Vec<String> = (Vec::new(), parse_list,
|
||||
"metadata to mangle symbol names with"),
|
||||
extra_filename: String = ("".to_string(), parse_string,
|
||||
"extra data to put in each output filename"),
|
||||
)
|
||||
|
||||
pub fn build_codegen_options(matches: &getopts::Matches) -> CodegenOptions
|
||||
|
|
|
@ -903,13 +903,11 @@ pub fn build_output_filenames(input: &Input,
|
|||
None => Path::new(".")
|
||||
};
|
||||
|
||||
let mut stem = input.filestem();
|
||||
|
||||
// If a crate name is present, we use it as the link name
|
||||
match attr::find_crate_name(attrs) {
|
||||
None => {}
|
||||
Some(name) => stem = name.get().to_string(),
|
||||
}
|
||||
let stem = match attr::find_crate_name(attrs) {
|
||||
None => input.filestem(),
|
||||
Some(name) => name.get().to_string(),
|
||||
};
|
||||
OutputFilenames {
|
||||
out_directory: dirpath,
|
||||
out_filestem: stem,
|
||||
|
|
Loading…
Add table
Reference in a new issue