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
|
|
@ -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
Add a link
Reference in a new issue