Don't ICE if an archive isn't actually an archive

This commit is contained in:
William Throwe 2015-09-25 00:46:33 -04:00
parent 8fe79bdfda
commit eef6030c92
3 changed files with 12 additions and 4 deletions

View File

@ -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

View File

@ -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 => {}
}
}
@ -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![];

View File

@ -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"