Don't ICE if an archive isn't actually an archive
This commit is contained in:
parent
8fe79bdfda
commit
eef6030c92
3 changed files with 12 additions and 4 deletions
|
@ -145,10 +145,13 @@ impl<'a> ArchiveBuilder<'a> {
|
||||||
|
|
||||||
/// Adds all of the contents of a native library to this archive. This will
|
/// Adds all of the contents of a native library to this archive. This will
|
||||||
/// search in the relevant locations for a library named `name`.
|
/// 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,
|
let location = find_library(name, &self.config.lib_search_paths,
|
||||||
self.config.sess);
|
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
|
/// Adds all of the contents of the rlib at the specified path to this
|
||||||
|
|
|
@ -616,7 +616,7 @@ fn link_rlib<'a>(sess: &'a Session,
|
||||||
|
|
||||||
for &(ref l, kind) in sess.cstore.get_used_libraries().borrow().iter() {
|
for &(ref l, kind) in sess.cstore.get_used_libraries().borrow().iter() {
|
||||||
match kind {
|
match kind {
|
||||||
cstore::NativeStatic => ab.add_native_library(&l).unwrap(),
|
cstore::NativeStatic => ab.add_native_library(&l),
|
||||||
cstore::NativeFramework | cstore::NativeUnknown => {}
|
cstore::NativeFramework | cstore::NativeUnknown => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -792,7 +792,7 @@ fn link_staticlib(sess: &Session, objects: &[PathBuf], out_filename: &Path,
|
||||||
ab.build();
|
ab.build();
|
||||||
}
|
}
|
||||||
if !sess.target.target.options.no_compiler_rt {
|
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![];
|
let mut all_native_libs = vec![];
|
||||||
|
|
5
src/test/run-make/invalid-staticlib/Makefile
Normal file
5
src/test/run-make/invalid-staticlib/Makefile
Normal 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"
|
Loading…
Add table
Add a link
Reference in a new issue