cli-support: Ignore missing descriptor functions

This can happen when a nested dependency crate exports things but the root crate
doesn't use them. In these cases, it is fine to ignore the missing descriptor,
because the thing it describes was removed as dead code.
This commit is contained in:
Nick Fitzgerald
2018-06-18 13:48:57 -07:00
parent e4dcb8f85e
commit 132103eb06
2 changed files with 37 additions and 13 deletions

View File

@ -140,11 +140,19 @@ impl Bindgen {
module_versions: Default::default(),
run_descriptor: &|name| {
let mut v = MyExternals(Vec::new());
let ret = instance
.invoke_export(name, &[], &mut v)
.expect("failed to run export");
assert!(ret.is_none());
v.0
match instance.invoke_export(name, &[], &mut v) {
Ok(None) => Some(v.0),
Ok(Some(_)) => {
unreachable!(
"there is only one export, and we only return None from it"
)
},
// Allow missing exported describe functions. This can
// happen when a nested dependency crate exports things
// but the root crate doesn't use them.
Err(wasmi::Error::Function(_)) => None,
Err(e) => panic!("unexpected error running descriptor: {}", e),
}
},
};
for program in programs.iter() {
@ -342,6 +350,7 @@ impl wasmi::ImportResolver for MyResolver {
}
struct MyExternals(Vec<u32>);
#[derive(Debug)]
struct MyError(String);