Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"