extension: Upgrade wasmtime
to v21 (#15210)
This PR upgrades the version of `wasmtime` and `wasmtime-wasi` in use to
v21.0.1.
We have to skip v20 because Tree-sitter also skipped it.
Here are the changes that had to be made:
### v19 -> v20
After upgrading the `wasmtime` packages to v20, I also had to run `cargo
update -p mach2` to pull in
[v0.4.2](https://github.com/JohnTitor/mach2/releases/tag/0.4.2) to fix
some compile errors.
There were a few minor API changes in `wasmtime-wasi` from
https://github.com/bytecodealliance/wasmtime/pull/8228 that we needed to
account for.
### v20 -> v21
Since there isn't a Tree-sitter version that depends on `wasmtime@v20`,
we're jumping straight to v21.
The published version of Tree-sitter (v0.22.6) still depends on
`wasmtime@v19`, but there was a commit
(7f4a57817d
)
later that month that upgrades the `wasmtime` dependency to v21.
We're patching Tree-sitter to that commit so we can get the new
`wasmtime` version.
The main change in v21 is that imports generated by `bindgen!` are no
longer automatically trapped
(https://github.com/bytecodealliance/wasmtime/pull/8310), so we need to
add `trappable_imports: true` to our `bindgen!` calls.
Release Notes:
- N/A
This commit is contained in:
parent
ab3c9f0678
commit
d755d29577
9 changed files with 215 additions and 185 deletions
|
@ -21,7 +21,6 @@ assistant_slash_command.workspace = true
|
|||
async-compression.workspace = true
|
||||
async-tar.workspace = true
|
||||
async-trait.workspace = true
|
||||
cap-std.workspace = true
|
||||
client.workspace = true
|
||||
collections.workspace = true
|
||||
fs.workspace = true
|
||||
|
|
|
@ -159,29 +159,25 @@ impl WasmHost {
|
|||
}
|
||||
|
||||
async fn build_wasi_ctx(&self, manifest: &Arc<ExtensionManifest>) -> Result<wasi::WasiCtx> {
|
||||
use cap_std::{ambient_authority, fs::Dir};
|
||||
|
||||
let extension_work_dir = self.work_dir.join(manifest.id.as_ref());
|
||||
self.fs
|
||||
.create_dir(&extension_work_dir)
|
||||
.await
|
||||
.context("failed to create extension work dir")?;
|
||||
|
||||
let work_dir_preopen = Dir::open_ambient_dir(&extension_work_dir, ambient_authority())
|
||||
.context("failed to preopen extension work directory")?;
|
||||
let current_dir_preopen = work_dir_preopen
|
||||
.try_clone()
|
||||
.context("failed to preopen extension current directory")?;
|
||||
let extension_work_dir = extension_work_dir.to_string_lossy();
|
||||
|
||||
let perms = wasi::FilePerms::all();
|
||||
let file_perms = wasi::FilePerms::all();
|
||||
let dir_perms = wasi::DirPerms::all();
|
||||
|
||||
Ok(wasi::WasiCtxBuilder::new()
|
||||
.inherit_stdio()
|
||||
.preopened_dir(current_dir_preopen, dir_perms, perms, ".")
|
||||
.preopened_dir(work_dir_preopen, dir_perms, perms, &extension_work_dir)
|
||||
.env("PWD", &extension_work_dir)
|
||||
.preopened_dir(&extension_work_dir, ".", dir_perms, file_perms)?
|
||||
.preopened_dir(
|
||||
&extension_work_dir,
|
||||
&extension_work_dir.to_string_lossy(),
|
||||
dir_perms,
|
||||
file_perms,
|
||||
)?
|
||||
.env("PWD", &extension_work_dir.to_string_lossy())
|
||||
.env("RUST_BACKTRACE", "full")
|
||||
.build())
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ pub fn new_linker(
|
|||
f: impl Fn(&mut Linker<WasmState>, fn(&mut WasmState) -> &mut WasmState) -> Result<()>,
|
||||
) -> Linker<WasmState> {
|
||||
let mut linker = Linker::new(&wasm_engine());
|
||||
wasmtime_wasi::command::add_to_linker(&mut linker).unwrap();
|
||||
wasmtime_wasi::add_to_linker_async(&mut linker).unwrap();
|
||||
f(&mut linker, wasi_view).unwrap();
|
||||
linker
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ pub const MIN_VERSION: SemanticVersion = SemanticVersion::new(0, 0, 1);
|
|||
|
||||
wasmtime::component::bindgen!({
|
||||
async: true,
|
||||
trappable_imports: true,
|
||||
path: "../extension_api/wit/since_v0.0.1",
|
||||
with: {
|
||||
"worktree": ExtensionWorktree,
|
||||
|
|
|
@ -11,6 +11,7 @@ pub const MIN_VERSION: SemanticVersion = SemanticVersion::new(0, 0, 4);
|
|||
|
||||
wasmtime::component::bindgen!({
|
||||
async: true,
|
||||
trappable_imports: true,
|
||||
path: "../extension_api/wit/since_v0.0.4",
|
||||
with: {
|
||||
"worktree": ExtensionWorktree,
|
||||
|
|
|
@ -12,6 +12,7 @@ pub const MAX_VERSION: SemanticVersion = SemanticVersion::new(0, 0, 6);
|
|||
|
||||
wasmtime::component::bindgen!({
|
||||
async: true,
|
||||
trappable_imports: true,
|
||||
path: "../extension_api/wit/since_v0.0.6",
|
||||
with: {
|
||||
"worktree": ExtensionWorktree,
|
||||
|
|
|
@ -26,6 +26,7 @@ pub const MAX_VERSION: SemanticVersion = SemanticVersion::new(0, 0, 7);
|
|||
|
||||
wasmtime::component::bindgen!({
|
||||
async: true,
|
||||
trappable_imports: true,
|
||||
path: "../extension_api/wit/since_v0.0.7",
|
||||
with: {
|
||||
"worktree": ExtensionWorktree,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue