Skip to content

Commit eb50ffd

Browse files
committed
rustc_trans: Clean up some style in back::link
* Add some logging here and there * Move some `err` + `abort_if_errors` to just using `fatal` * Clean up some line-lengths
1 parent e2854b3 commit eb50ffd

File tree

1 file changed

+18
-30
lines changed

1 file changed

+18
-30
lines changed

src/librustc_trans/back/link.rs

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ fn link_rlib<'a>(sess: &'a Session,
546546
trans: Option<&CrateTranslation>, // None == no metadata/bytecode
547547
obj_filename: &Path,
548548
out_filename: &Path) -> ArchiveBuilder<'a> {
549+
info!("preparing rlib from {:?} to {:?}", obj_filename, out_filename);
549550
let handler = &sess.diagnostic().handler;
550551
let config = ArchiveConfig {
551552
handler: handler,
@@ -560,9 +561,7 @@ fn link_rlib<'a>(sess: &'a Session,
560561

561562
for &(ref l, kind) in &*sess.cstore.get_used_libraries().borrow() {
562563
match kind {
563-
cstore::NativeStatic => {
564-
ab.add_native_library(&l[..]).unwrap();
565-
}
564+
cstore::NativeStatic => ab.add_native_library(&l).unwrap(),
566565
cstore::NativeFramework | cstore::NativeUnknown => {}
567566
}
568567
}
@@ -613,10 +612,8 @@ fn link_rlib<'a>(sess: &'a Session,
613612
}) {
614613
Ok(..) => {}
615614
Err(e) => {
616-
sess.err(&format!("failed to write {}: {}",
617-
metadata.display(),
618-
e));
619-
sess.abort_if_errors();
615+
sess.fatal(&format!("failed to write {}: {}",
616+
metadata.display(), e));
620617
}
621618
}
622619
ab.add_file(&metadata).unwrap();
@@ -658,9 +655,8 @@ fn link_rlib<'a>(sess: &'a Session,
658655
&bc_data_deflated) {
659656
Ok(()) => {}
660657
Err(e) => {
661-
sess.err(&format!("failed to write compressed bytecode: \
662-
{}", e));
663-
sess.abort_if_errors()
658+
sess.fatal(&format!("failed to write compressed \
659+
bytecode: {}", e));
664660
}
665661
};
666662

@@ -794,6 +790,8 @@ fn link_staticlib(sess: &Session, obj_filename: &Path, out_filename: &Path) {
794790
// links to all upstream files as well.
795791
fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool,
796792
obj_filename: &Path, out_filename: &Path) {
793+
info!("preparing dylib? ({}) from {:?} to {:?}", dylib, obj_filename,
794+
out_filename);
797795
let tmpdir = TempDir::new("rustc").ok().expect("needs a temp dir");
798796

799797
// The invocations of cc share some flags across platforms
@@ -827,7 +825,7 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool,
827825
sess.abort_if_errors();
828826

829827
// Invoke the system linker
830-
debug!("{:?}", &cmd);
828+
info!("{:?}", &cmd);
831829
let prog = time(sess.time_passes(), "running linker", (), |()| cmd.output());
832830
match prog {
833831
Ok(prog) => {
@@ -841,14 +839,11 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool,
841839
sess.note(str::from_utf8(&output[..]).unwrap());
842840
sess.abort_if_errors();
843841
}
844-
debug!("linker stderr:\n{}", String::from_utf8(prog.stderr).unwrap());
845-
debug!("linker stdout:\n{}", String::from_utf8(prog.stdout).unwrap());
842+
info!("linker stderr:\n{}", String::from_utf8(prog.stderr).unwrap());
843+
info!("linker stdout:\n{}", String::from_utf8(prog.stdout).unwrap());
846844
},
847845
Err(e) => {
848-
sess.err(&format!("could not exec the linker `{}`: {}",
849-
pname,
850-
e));
851-
sess.abort_if_errors();
846+
sess.fatal(&format!("could not exec the linker `{}`: {}", pname, e));
852847
}
853848
}
854849

@@ -858,10 +853,7 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool,
858853
if sess.target.target.options.is_like_osx && sess.opts.debuginfo != NoDebugInfo {
859854
match Command::new("dsymutil").arg(out_filename).output() {
860855
Ok(..) => {}
861-
Err(e) => {
862-
sess.err(&format!("failed to run dsymutil: {}", e));
863-
sess.abort_if_errors();
864-
}
856+
Err(e) => sess.fatal(&format!("failed to run dsymutil: {}", e)),
865857
}
866858
}
867859
}
@@ -1157,11 +1149,9 @@ fn add_upstream_rust_crates(cmd: &mut Linker, sess: &Session,
11571149
match fs::copy(&cratepath, &dst) {
11581150
Ok(..) => {}
11591151
Err(e) => {
1160-
sess.err(&format!("failed to copy {} to {}: {}",
1161-
cratepath.display(),
1162-
dst.display(),
1163-
e));
1164-
sess.abort_if_errors();
1152+
sess.fatal(&format!("failed to copy {} to {}: {}",
1153+
cratepath.display(),
1154+
dst.display(), e));
11651155
}
11661156
}
11671157
// Fix up permissions of the copy, as fs::copy() preserves
@@ -1174,10 +1164,8 @@ fn add_upstream_rust_crates(cmd: &mut Linker, sess: &Session,
11741164
}) {
11751165
Ok(..) => {}
11761166
Err(e) => {
1177-
sess.err(&format!("failed to chmod {} when preparing \
1178-
for LTO: {}", dst.display(),
1179-
e));
1180-
sess.abort_if_errors();
1167+
sess.fatal(&format!("failed to chmod {} when preparing \
1168+
for LTO: {}", dst.display(), e));
11811169
}
11821170
}
11831171
let handler = &sess.diagnostic().handler;

0 commit comments

Comments
 (0)