cranelift-faerie: upgrade to faerie 0.15.0, fix error reporting

the `FaerieProduct` exposes faerie-specific types, so we can give
the `faerie::ArtifactError` on those methods.

`ModuleError::Backend` now expects an `anyhow::Error`, so we change
a .to_string into .into() and retain better error information.
This commit is contained in:
Pat Hickey
2020-03-13 11:52:40 -07:00
parent fdfda89d59
commit 2b87db3f55
3 changed files with 29 additions and 13 deletions

24
Cargo.lock generated
View File

@@ -461,7 +461,7 @@ dependencies = [
"anyhow",
"cranelift-codegen",
"cranelift-module",
"faerie",
"faerie 0.15.0",
"goblin",
"target-lexicon",
]
@@ -499,6 +499,7 @@ dependencies = [
name = "cranelift-module"
version = "0.59.0"
dependencies = [
"anyhow",
"cranelift-codegen",
"cranelift-entity",
"hashbrown",
@@ -857,6 +858,21 @@ dependencies = [
"thiserror",
]
[[package]]
name = "faerie"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfef65b0e94693295c5d2fe2506f0ee6f43465342d4b5331659936aee8b16084"
dependencies = [
"goblin",
"indexmap",
"log",
"scroll",
"string-interner",
"target-lexicon",
"thiserror",
]
[[package]]
name = "failure"
version = "0.1.6"
@@ -2424,7 +2440,7 @@ name = "wasmtime-cli"
version = "0.12.0"
dependencies = [
"anyhow",
"faerie",
"faerie 0.14.0",
"file-per-thread-logger",
"filecheck",
"libc",
@@ -2453,7 +2469,7 @@ name = "wasmtime-debug"
version = "0.12.0"
dependencies = [
"anyhow",
"faerie",
"faerie 0.14.0",
"gimli",
"more-asserts",
"target-lexicon",
@@ -2553,7 +2569,7 @@ name = "wasmtime-obj"
version = "0.12.0"
dependencies = [
"anyhow",
"faerie",
"faerie 0.14.0",
"more-asserts",
"wasmtime-environ",
]

View File

@@ -11,7 +11,7 @@ edition = "2018"
[dependencies]
cranelift-module = { path = "../module", version = "0.59.0" }
faerie = "0.14.0"
faerie = "0.15.0"
goblin = "0.1.0"
anyhow = "1.0"
target-lexicon = "0.10"

View File

@@ -2,7 +2,7 @@
use crate::container;
use crate::traps::{FaerieTrapManifest, FaerieTrapSink};
use anyhow::Error;
use anyhow::anyhow;
use cranelift_codegen::binemit::{
Addend, CodeOffset, NullStackmapSink, NullTrapSink, Reloc, RelocSink, Stackmap, StackmapSink,
};
@@ -57,9 +57,9 @@ impl FaerieBuilder {
libcall_names: Box<dyn Fn(ir::LibCall) -> String>,
) -> ModuleResult<Self> {
if !isa.flags().is_pic() {
return Err(ModuleError::Backend(
"faerie requires TargetIsa be PIC".to_owned(),
));
return Err(ModuleError::Backend(anyhow!(
"faerie requires TargetIsa be PIC"
)));
}
Ok(Self {
isa,
@@ -257,7 +257,7 @@ impl Backend for FaerieBackend {
to,
at: u64::from(offset),
})
.map_err(|e| ModuleError::Backend(e.to_string()))?;
.map_err(|e| ModuleError::Backend(e.into()))?;
}
for &(offset, id, addend) in data_relocs {
debug_assert_eq!(
@@ -271,7 +271,7 @@ impl Backend for FaerieBackend {
to,
at: u64::from(offset),
})
.map_err(|e| ModuleError::Backend(e.to_string()))?;
.map_err(|e| ModuleError::Backend(e.into()))?;
}
match *init {
@@ -369,12 +369,12 @@ impl FaerieProduct {
}
/// Call `emit` on the faerie `Artifact`, producing bytes in memory.
pub fn emit(&self) -> Result<Vec<u8>, Error> {
pub fn emit(&self) -> Result<Vec<u8>, faerie::ArtifactError> {
self.artifact.emit()
}
/// Call `write` on the faerie `Artifact`, writing to a file.
pub fn write(&self, sink: File) -> Result<(), Error> {
pub fn write(&self, sink: File) -> Result<(), faerie::ArtifactError> {
self.artifact.write(sink)
}
}