Detect components in wasmtime compile more robustly (#5592)
The binary version of component is going to change over time so use a more robust method than checking for a fixed 8 bytes.
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -3491,6 +3491,7 @@ dependencies = [
|
|||||||
"tempfile",
|
"tempfile",
|
||||||
"test-programs",
|
"test-programs",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
"wasmparser",
|
||||||
"wasmtime",
|
"wasmtime",
|
||||||
"wasmtime-cache",
|
"wasmtime-cache",
|
||||||
"wasmtime-cli-flags",
|
"wasmtime-cli-flags",
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ listenfd = "1.0.0"
|
|||||||
wat = { workspace = true }
|
wat = { workspace = true }
|
||||||
serde = "1.0.94"
|
serde = "1.0.94"
|
||||||
serde_json = "1.0.26"
|
serde_json = "1.0.26"
|
||||||
|
wasmparser = { workspace = true }
|
||||||
|
|
||||||
[target.'cfg(unix)'.dependencies]
|
[target.'cfg(unix)'.dependencies]
|
||||||
rustix = { workspace = true, features = ["mm", "param"] }
|
rustix = { workspace = true, features = ["mm", "param"] }
|
||||||
|
|||||||
@@ -90,7 +90,15 @@ impl CompileCommand {
|
|||||||
// bytes with the current component model proposal.
|
// bytes with the current component model proposal.
|
||||||
#[cfg(feature = "component-model")]
|
#[cfg(feature = "component-model")]
|
||||||
{
|
{
|
||||||
if input.starts_with(b"\0asm\x0a\0\x01\0") {
|
if let Ok(wasmparser::Chunk::Parsed {
|
||||||
|
payload:
|
||||||
|
wasmparser::Payload::Version {
|
||||||
|
encoding: wasmparser::Encoding::Component,
|
||||||
|
..
|
||||||
|
},
|
||||||
|
..
|
||||||
|
}) = wasmparser::Parser::new(0).parse(&input, true)
|
||||||
|
{
|
||||||
fs::write(output, engine.precompile_component(&input)?)?;
|
fs::write(output, engine.precompile_component(&input)?)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user