Merge pull request #1311 from bytecodealliance/pch/cranelift_module_errors
cranelift-{module, faerie}: minor improvements to error reporting
This commit is contained in:
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -499,6 +499,7 @@ dependencies = [
|
|||||||
name = "cranelift-module"
|
name = "cranelift-module"
|
||||||
version = "0.59.0"
|
version = "0.59.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
"cranelift-codegen",
|
"cranelift-codegen",
|
||||||
"cranelift-entity",
|
"cranelift-entity",
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
@@ -843,11 +844,10 @@ version = "0.1.0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "faerie"
|
name = "faerie"
|
||||||
version = "0.14.0"
|
version = "0.15.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "74b9ed6159e4a6212c61d9c6a86bee01876b192a64accecf58d5b5ae3b667b52"
|
checksum = "dfef65b0e94693295c5d2fe2506f0ee6f43465342d4b5331659936aee8b16084"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
|
||||||
"goblin",
|
"goblin",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"log",
|
"log",
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ wasmtime-wast = { path = "crates/wast" }
|
|||||||
wasmtime-wasi = { path = "crates/wasi" }
|
wasmtime-wasi = { path = "crates/wasi" }
|
||||||
wasi-common = { path = "crates/wasi-common" }
|
wasi-common = { path = "crates/wasi-common" }
|
||||||
structopt = { version = "0.3.5", features = ["color", "suggestions"] }
|
structopt = { version = "0.3.5", features = ["color", "suggestions"] }
|
||||||
faerie = "0.14.0"
|
faerie = "0.15.0"
|
||||||
anyhow = "1.0.19"
|
anyhow = "1.0.19"
|
||||||
target-lexicon = { version = "0.10.0", default-features = false }
|
target-lexicon = { version = "0.10.0", default-features = false }
|
||||||
pretty_env_logger = "0.3.0"
|
pretty_env_logger = "0.3.0"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ edition = "2018"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cranelift-module = { path = "../module", version = "0.59.0" }
|
cranelift-module = { path = "../module", version = "0.59.0" }
|
||||||
faerie = "0.14.0"
|
faerie = "0.15.0"
|
||||||
goblin = "0.1.0"
|
goblin = "0.1.0"
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
target-lexicon = "0.10"
|
target-lexicon = "0.10"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use crate::container;
|
use crate::container;
|
||||||
use crate::traps::{FaerieTrapManifest, FaerieTrapSink};
|
use crate::traps::{FaerieTrapManifest, FaerieTrapSink};
|
||||||
use anyhow::Error;
|
use anyhow::anyhow;
|
||||||
use cranelift_codegen::binemit::{
|
use cranelift_codegen::binemit::{
|
||||||
Addend, CodeOffset, NullStackmapSink, NullTrapSink, Reloc, RelocSink, Stackmap, StackmapSink,
|
Addend, CodeOffset, NullStackmapSink, NullTrapSink, Reloc, RelocSink, Stackmap, StackmapSink,
|
||||||
};
|
};
|
||||||
@@ -57,9 +57,9 @@ impl FaerieBuilder {
|
|||||||
libcall_names: Box<dyn Fn(ir::LibCall) -> String>,
|
libcall_names: Box<dyn Fn(ir::LibCall) -> String>,
|
||||||
) -> ModuleResult<Self> {
|
) -> ModuleResult<Self> {
|
||||||
if !isa.flags().is_pic() {
|
if !isa.flags().is_pic() {
|
||||||
return Err(ModuleError::Backend(
|
return Err(ModuleError::Backend(anyhow!(
|
||||||
"faerie requires TargetIsa be PIC".to_owned(),
|
"faerie requires TargetIsa be PIC"
|
||||||
));
|
)));
|
||||||
}
|
}
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
isa,
|
isa,
|
||||||
@@ -257,7 +257,7 @@ impl Backend for FaerieBackend {
|
|||||||
to,
|
to,
|
||||||
at: u64::from(offset),
|
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 {
|
for &(offset, id, addend) in data_relocs {
|
||||||
debug_assert_eq!(
|
debug_assert_eq!(
|
||||||
@@ -271,7 +271,7 @@ impl Backend for FaerieBackend {
|
|||||||
to,
|
to,
|
||||||
at: u64::from(offset),
|
at: u64::from(offset),
|
||||||
})
|
})
|
||||||
.map_err(|e| ModuleError::Backend(e.to_string()))?;
|
.map_err(|e| ModuleError::Backend(e.into()))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
match *init {
|
match *init {
|
||||||
@@ -369,12 +369,12 @@ impl FaerieProduct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Call `emit` on the faerie `Artifact`, producing bytes in memory.
|
/// 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()
|
self.artifact.emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Call `write` on the faerie `Artifact`, writing to a file.
|
/// 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)
|
self.artifact.write(sink)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ cranelift-entity = { path = "../entity", version = "0.59.0" }
|
|||||||
hashbrown = { version = "0.6", optional = true }
|
hashbrown = { version = "0.6", optional = true }
|
||||||
log = { version = "0.4.6", default-features = false }
|
log = { version = "0.4.6", default-features = false }
|
||||||
thiserror = "1.0.4"
|
thiserror = "1.0.4"
|
||||||
|
anyhow = "1.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ pub enum ModuleError {
|
|||||||
Compilation(#[from] CodegenError),
|
Compilation(#[from] CodegenError),
|
||||||
/// Wraps a generic error from a backend
|
/// Wraps a generic error from a backend
|
||||||
#[error("Backend error: {0}")]
|
#[error("Backend error: {0}")]
|
||||||
Backend(String),
|
Backend(#[source] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A convenient alias for a `Result` that uses `ModuleError` as the error type.
|
/// A convenient alias for a `Result` that uses `ModuleError` as the error type.
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ edition = "2018"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
gimli = "0.20.0"
|
gimli = "0.20.0"
|
||||||
wasmparser = "0.51.2"
|
wasmparser = "0.51.2"
|
||||||
faerie = "0.14.0"
|
faerie = "0.15.0"
|
||||||
wasmtime-environ = { path = "../environ", version = "0.12.0" }
|
wasmtime-environ = { path = "../environ", version = "0.12.0" }
|
||||||
target-lexicon = { version = "0.10.0", default-features = false }
|
target-lexicon = { version = "0.10.0", default-features = false }
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ pub fn emit_dwarf(
|
|||||||
id.name(),
|
id.name(),
|
||||||
Decl::section(SectionKind::Debug),
|
Decl::section(SectionKind::Debug),
|
||||||
s.writer.take(),
|
s.writer.take(),
|
||||||
)
|
)?;
|
||||||
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
sections.for_each_mut(|id, s| -> anyhow::Result<()> {
|
sections.for_each_mut(|id, s| -> anyhow::Result<()> {
|
||||||
for reloc in &s.relocs {
|
for reloc in &s.relocs {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ edition = "2018"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
wasmtime-environ = { path = "../environ", version = "0.12.0" }
|
wasmtime-environ = { path = "../environ", version = "0.12.0" }
|
||||||
faerie = "0.14.0"
|
faerie = "0.15.0"
|
||||||
more-asserts = "0.2.1"
|
more-asserts = "0.2.1"
|
||||||
|
|
||||||
[badges]
|
[badges]
|
||||||
|
|||||||
Reference in New Issue
Block a user