Skip to content

Commit

Permalink
Rollup merge of rust-lang#28673 - wthrowe:bad-archive, r=alexcrichton
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Sep 27, 2015
2 parents 8c47cfe + eef6030 commit 5f90904
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/librustc_trans/back/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,13 @@ impl<'a> ArchiveBuilder<'a> {

/// Adds all of the contents of a native library to this archive. This will
/// search in the relevant locations for a library named `name`.
pub fn add_native_library(&mut self, name: &str) -> io::Result<()> {
pub fn add_native_library(&mut self, name: &str) {
let location = find_library(name, &self.config.lib_search_paths,
self.config.sess);
self.add_archive(&location, name, |_| false)
self.add_archive(&location, name, |_| false).unwrap_or_else(|e| {
self.config.sess.fatal(&format!("failed to add native library {}: {}",
location.to_string_lossy(), e));
});
}

/// Adds all of the contents of the rlib at the specified path to this
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_trans/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ fn link_rlib<'a>(sess: &'a Session,

for &(ref l, kind) in sess.cstore.get_used_libraries().borrow().iter() {
match kind {
cstore::NativeStatic => ab.add_native_library(&l).unwrap(),
cstore::NativeStatic => ab.add_native_library(&l),
cstore::NativeFramework | cstore::NativeUnknown => {}
}
}
Expand Down Expand Up @@ -792,7 +792,7 @@ fn link_staticlib(sess: &Session, objects: &[PathBuf], out_filename: &Path,
ab.build();
}
if !sess.target.target.options.no_compiler_rt {
ab.add_native_library("compiler-rt").unwrap();
ab.add_native_library("compiler-rt");
}

let mut all_native_libs = vec![];
Expand Down
5 changes: 5 additions & 0 deletions src/test/run-make/invalid-staticlib/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-include ../tools.mk

all:
touch $(TMPDIR)/libfoo.a
echo | $(RUSTC) - --crate-type=rlib -lstatic=foo 2>&1 | grep "failed to add native library"

0 comments on commit 5f90904

Please sign in to comment.