Skip to content

Commit fa5d8a8

Browse files
committed
---
yaml --- r: 103417 b: refs/heads/auto c: 311ac8f h: refs/heads/master i: 103415: 162be0a v: v3
1 parent fd57901 commit fa5d8a8

37 files changed

+556
-556
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 58ea029db2fd9da6eac85456191481b4cbdb9e58
16+
refs/heads/auto: 311ac8f480917f2dccb98b0dd08342b18208e477
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/mk/clean.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ clean-generic-$(2)-$(1):
5858
-name '*.[odasS]' -o \
5959
-name '*.so' -o \
6060
-name '*.dylib' -o \
61-
-name '*.rlib' -o \
6261
-name 'stamp.*' -o \
6362
-name '*.lib' -o \
6463
-name '*.dll' -o \

branches/auto/src/librustc/back/link.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
1112
use back::archive::{Archive, METADATA_FILENAME};
1213
use back::rpath;
13-
use back::svh::Svh;
1414
use driver::driver::{CrateTranslation, OutputFilenames};
1515
use driver::session::Session;
1616
use driver::session;
@@ -499,31 +499,28 @@ pub mod write {
499499
* system linkers understand.
500500
*/
501501

502-
pub fn find_crate_id(attrs: &[ast::Attribute],
503-
output: &OutputFilenames) -> CrateId {
504-
match attr::find_crateid(attrs) {
502+
pub fn build_link_meta(attrs: &[ast::Attribute],
503+
output: &OutputFilenames,
504+
symbol_hasher: &mut Sha256)
505+
-> LinkMeta {
506+
// This calculates CMH as defined above
507+
fn crate_hash(symbol_hasher: &mut Sha256, crateid: &CrateId) -> ~str {
508+
symbol_hasher.reset();
509+
symbol_hasher.input_str(crateid.to_str());
510+
truncated_hash_result(symbol_hasher)
511+
}
512+
513+
let crateid = match attr::find_crateid(attrs) {
505514
None => from_str(output.out_filestem).unwrap(),
506515
Some(s) => s,
507-
}
508-
}
516+
};
509517

510-
pub fn crate_id_hash(crate_id: &CrateId) -> ~str {
511-
// This calculates CMH as defined above. Note that we don't use the path of
512-
// the crate id in the hash because lookups are only done by (name/vers),
513-
// not by path.
514-
let mut s = Sha256::new();
515-
s.input_str(crate_id.short_name_with_version());
516-
truncated_hash_result(&mut s).slice_to(8).to_owned()
517-
}
518+
let hash = crate_hash(symbol_hasher, &crateid);
518519

519-
pub fn build_link_meta(krate: &ast::Crate,
520-
output: &OutputFilenames) -> LinkMeta {
521-
let r = LinkMeta {
522-
crateid: find_crate_id(krate.attrs, output),
523-
crate_hash: Svh::calculate(krate),
524-
};
525-
info!("{}", r);
526-
return r;
520+
LinkMeta {
521+
crateid: crateid,
522+
crate_hash: hash,
523+
}
527524
}
528525

529526
fn truncated_hash_result(symbol_hasher: &mut Sha256) -> ~str {
@@ -542,7 +539,7 @@ fn symbol_hash(tcx: ty::ctxt, symbol_hasher: &mut Sha256,
542539
symbol_hasher.reset();
543540
symbol_hasher.input_str(link_meta.crateid.name);
544541
symbol_hasher.input_str("-");
545-
symbol_hasher.input_str(link_meta.crate_hash.as_str());
542+
symbol_hasher.input_str(link_meta.crate_hash);
546543
symbol_hasher.input_str("-");
547544
symbol_hasher.input_str(encoder::encoded_ty(tcx, t));
548545
let mut hash = truncated_hash_result(symbol_hasher);
@@ -715,8 +712,11 @@ pub fn mangle_internal_name_by_path_and_seq(path: PathElems, flav: &str) -> ~str
715712
mangle(path.chain(Some(gensym_name(flav)).move_iter()), None, None)
716713
}
717714

718-
pub fn output_lib_filename(id: &CrateId) -> ~str {
719-
format!("{}-{}-{}", id.name, crate_id_hash(id), id.version_or_default())
715+
pub fn output_lib_filename(lm: &LinkMeta) -> ~str {
716+
format!("{}-{}-{}",
717+
lm.crateid.name,
718+
lm.crate_hash.slice_chars(0, 8),
719+
lm.crateid.version_or_default())
720720
}
721721

722722
pub fn get_cc_prog(sess: Session) -> ~str {
@@ -779,11 +779,11 @@ fn remove(sess: Session, path: &Path) {
779779
pub fn link_binary(sess: Session,
780780
trans: &CrateTranslation,
781781
outputs: &OutputFilenames,
782-
id: &CrateId) -> ~[Path] {
782+
lm: &LinkMeta) -> ~[Path] {
783783
let mut out_filenames = ~[];
784784
let crate_types = sess.crate_types.borrow();
785785
for &crate_type in crate_types.get().iter() {
786-
let out_file = link_binary_output(sess, trans, crate_type, outputs, id);
786+
let out_file = link_binary_output(sess, trans, crate_type, outputs, lm);
787787
out_filenames.push(out_file);
788788
}
789789

@@ -807,8 +807,8 @@ fn is_writeable(p: &Path) -> bool {
807807
}
808808

809809
pub fn filename_for_input(sess: &Session, crate_type: session::CrateType,
810-
id: &CrateId, out_filename: &Path) -> Path {
811-
let libname = output_lib_filename(id);
810+
lm: &LinkMeta, out_filename: &Path) -> Path {
811+
let libname = output_lib_filename(lm);
812812
match crate_type {
813813
session::CrateTypeRlib => {
814814
out_filename.with_filename(format!("lib{}.rlib", libname))
@@ -834,13 +834,13 @@ fn link_binary_output(sess: Session,
834834
trans: &CrateTranslation,
835835
crate_type: session::CrateType,
836836
outputs: &OutputFilenames,
837-
id: &CrateId) -> Path {
837+
lm: &LinkMeta) -> Path {
838838
let obj_filename = outputs.temp_path(OutputTypeObject);
839839
let out_filename = match outputs.single_output_file {
840840
Some(ref file) => file.clone(),
841841
None => {
842842
let out_filename = outputs.path(OutputTypeExe);
843-
filename_for_input(&sess, crate_type, id, &out_filename)
843+
filename_for_input(&sess, crate_type, lm, &out_filename)
844844
}
845845
};
846846

branches/auto/src/librustc/back/svh.rs

Lines changed: 0 additions & 112 deletions
This file was deleted.

branches/auto/src/librustc/driver/driver.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ pub fn phase_6_link_output(sess: Session,
433433
link::link_binary(sess,
434434
trans,
435435
outputs,
436-
&trans.link.crateid));
436+
&trans.link));
437437
}
438438

439439
pub fn stop_after_phase_3(sess: Session) -> bool {
@@ -472,7 +472,8 @@ fn write_out_deps(sess: Session,
472472
input: &Input,
473473
outputs: &OutputFilenames,
474474
krate: &ast::Crate) -> io::IoResult<()> {
475-
let id = link::find_crate_id(krate.attrs, outputs);
475+
let lm = link::build_link_meta(krate.attrs, outputs,
476+
&mut ::util::sha2::Sha256::new());
476477

477478
let mut out_filenames = ~[];
478479
for output_type in sess.opts.output_types.iter() {
@@ -481,7 +482,7 @@ fn write_out_deps(sess: Session,
481482
link::OutputTypeExe => {
482483
let crate_types = sess.crate_types.borrow();
483484
for output in crate_types.get().iter() {
484-
let p = link::filename_for_input(&sess, *output, &id, &file);
485+
let p = link::filename_for_input(&sess, *output, &lm, &file);
485486
out_filenames.push(p);
486487
}
487488
}

branches/auto/src/librustc/lib.rs

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ use std::str;
5555
use std::task;
5656
use std::vec;
5757
use syntax::ast;
58+
use syntax::attr;
5859
use syntax::diagnostic::Emitter;
5960
use syntax::diagnostic;
6061
use syntax::parse;
@@ -103,17 +104,16 @@ pub mod front {
103104
}
104105

105106
pub mod back {
106-
pub mod abi;
107107
pub mod archive;
108-
pub mod arm;
109108
pub mod link;
110-
pub mod lto;
109+
pub mod abi;
110+
pub mod arm;
111111
pub mod mips;
112-
pub mod rpath;
113-
pub mod svh;
114-
pub mod target_strs;
115112
pub mod x86;
116113
pub mod x86_64;
114+
pub mod rpath;
115+
pub mod target_strs;
116+
pub mod lto;
117117
}
118118

119119
pub mod metadata;
@@ -312,18 +312,28 @@ pub fn run_compiler(args: &[~str]) {
312312
let attrs = parse_crate_attrs(sess, &input);
313313
let t_outputs = d::build_output_filenames(&input, &odir, &ofile,
314314
attrs, sess);
315-
let id = link::find_crate_id(attrs, &t_outputs);
316-
317-
if crate_id {
318-
println!("{}", id.to_str());
319-
}
320-
if crate_name {
321-
println!("{}", id.name);
315+
if crate_id || crate_name {
316+
let crateid = match attr::find_crateid(attrs) {
317+
Some(crateid) => crateid,
318+
None => {
319+
sess.fatal("No crate_id and --crate-id or \
320+
--crate-name requested")
321+
}
322+
};
323+
if crate_id {
324+
println!("{}", crateid.to_str());
325+
}
326+
if crate_name {
327+
println!("{}", crateid.name);
328+
}
322329
}
330+
323331
if crate_file_name {
332+
let lm = link::build_link_meta(attrs, &t_outputs,
333+
&mut ::util::sha2::Sha256::new());
324334
let crate_types = session::collect_crate_types(&sess, attrs);
325335
for &style in crate_types.iter() {
326-
let fname = link::filename_for_input(&sess, style, &id,
336+
let fname = link::filename_for_input(&sess, style, &lm,
327337
&t_outputs.with_extension(""));
328338
println!("{}", fname.filename_display());
329339
}

branches/auto/src/librustc/metadata/common.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
use std::cast;
1414
use syntax::crateid::CrateId;
15-
use back::svh::Svh;
1615

1716
// EBML enum definitions and utils shared by the encoder and decoder
1817

@@ -71,12 +70,12 @@ pub static tag_crate_deps: uint = 0x18;
7170
pub static tag_crate_dep: uint = 0x19;
7271

7372
pub static tag_crate_hash: uint = 0x1a;
74-
pub static tag_crate_crateid: uint = 0x1b;
7573

76-
pub static tag_parent_item: uint = 0x1c;
74+
pub static tag_parent_item: uint = 0x1b;
7775

78-
pub static tag_crate_dep_crateid: uint = 0x1d;
79-
pub static tag_crate_dep_hash: uint = 0x1e;
76+
pub static tag_crate_dep_name: uint = 0x1c;
77+
pub static tag_crate_dep_hash: uint = 0x1d;
78+
pub static tag_crate_dep_vers: uint = 0x1e;
8079

8180
pub static tag_mod_impl: uint = 0x1f;
8281

@@ -208,8 +207,8 @@ pub static tag_macro_registrar_fn: uint = 0x63;
208207
pub static tag_exported_macros: uint = 0x64;
209208
pub static tag_macro_def: uint = 0x65;
210209

211-
#[deriving(Clone, Show)]
210+
#[deriving(Clone)]
212211
pub struct LinkMeta {
213212
crateid: CrateId,
214-
crate_hash: Svh,
213+
crate_hash: ~str,
215214
}

0 commit comments

Comments
 (0)