diff --git a/src/librustc_trans/back/archive.rs b/src/librustc_trans/back/archive.rs index 76bbce00f19dc..1b3242eb97d33 100644 --- a/src/librustc_trans/back/archive.rs +++ b/src/librustc_trans/back/archive.rs @@ -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 diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index f25132e1856e8..4e493e6779c66 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -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![]; diff --git a/src/test/run-make/invalid-staticlib/Makefile b/src/test/run-make/invalid-staticlib/Makefile new file mode 100644 index 0000000000000..d4aa6d5e72098 --- /dev/null +++ b/src/test/run-make/invalid-staticlib/Makefile @@ -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"