Skip to content

Commit eef6030

Browse files
committed
Don't ICE if an archive isn't actually an archive
1 parent 8fe79bd commit eef6030

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/librustc_trans/back/archive.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,13 @@ impl<'a> ArchiveBuilder<'a> {
145145

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

154157
/// Adds all of the contents of the rlib at the specified path to this

src/librustc_trans/back/link.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ fn link_rlib<'a>(sess: &'a Session,
616616

617617
for &(ref l, kind) in sess.cstore.get_used_libraries().borrow().iter() {
618618
match kind {
619-
cstore::NativeStatic => ab.add_native_library(&l).unwrap(),
619+
cstore::NativeStatic => ab.add_native_library(&l),
620620
cstore::NativeFramework | cstore::NativeUnknown => {}
621621
}
622622
}
@@ -792,7 +792,7 @@ fn link_staticlib(sess: &Session, objects: &[PathBuf], out_filename: &Path,
792792
ab.build();
793793
}
794794
if !sess.target.target.options.no_compiler_rt {
795-
ab.add_native_library("compiler-rt").unwrap();
795+
ab.add_native_library("compiler-rt");
796796
}
797797

798798
let mut all_native_libs = vec![];
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-include ../tools.mk
2+
3+
all:
4+
touch $(TMPDIR)/libfoo.a
5+
echo | $(RUSTC) - --crate-type=rlib -lstatic=foo 2>&1 | grep "failed to add native library"

0 commit comments

Comments
 (0)