Repository: bytecodealliance/wasmtime
Pull request #8911 (2024-07-08 16:11:06)

Update dependency on `wit-bindgen`
Updating to the latest released version.

<!--
Please make sure you include the following information:

- If this work has been discussed elsewhere, please include a link to that
  conversation. If it was discussed in an issue, just mention "issue #...".

- Explain why this change is needed. If the details are in an issue already,
  this can be brief.

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->



Patch:
diff --git a/.github/actions/build-adapter-provider/action.yml b/.github/actions/build-adapter-provider/action.yml
new file mode 100644
index 000000000..60b9d08a3
--- /dev/null
+++ b/.github/actions/build-adapter-provider/action.yml
@@ -0,0 +1,25 @@
+name: 'Build wasi component adapter provider'
+description: 'Build the wasi-preview1-component-adapter provider using the adapter artefacts'
+
+inputs:
+  run-id:
+    description: 'run id of the main.yml action that produced the adapter artefacts'
+    required: true
+
+runs:
+  using: composite
+  steps:
+    - uses: actions/download-artifact@v4
+      with:
+        name: bins-wasi-preview1-component-adapter
+        path: crates/wasi-preview1-component-adapter/provider/artefacts
+        github-token: ${{ github.token }}
+        run-id: ${{ inputs.run-id }}
+
+    - name: Install required Rust components
+      shell: bash
+      run: rustup component add rustfmt clippy
+
+    - name: Build and checl the adapter provider
+      shell: bash
+      run: ./ci/build-wasi-preview1-component-adapter-provider.sh
diff --git a/.github/actions/fetch-run-id/action.yml b/.github/actions/fetch-run-id/action.yml
new file mode 100644
index 000000000..614f2e37c
--- /dev/null
+++ b/.github/actions/fetch-run-id/action.yml
@@ -0,0 +1,18 @@
+name: 'Fetch run id for commit'
+description: 'Fetch the main.yml run id for the current commit'
+
+runs:
+  using: composite
+  steps:
+    - name: Fetch run id
+      shell: bash
+      run: |
+        run_id=$(
+          gh api -H 'Accept: application/vnd.github+json' \
+              /repos/${{ github.repository }}/actions/workflows/main.yml/runs\?exclude_pull_requests=true \
+              | jq '.workflow_runs' \
+              | jq "map(select(.head_commit.id == \"${{ github.sha }}\"))[0].id" \
+        )
+        echo COMMIT_RUN_ID=${run_id} >> "$GITHUB_ENV"
+      env:
+        GH_TOKEN: ${{ github.token }}
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 42ba5f770..8a1f38fe5 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -813,6 +813,26 @@ jobs:
         path: target/wasm32-unknown-unknown/release/wasi_snapshot_preview1.*.wasm
 
 
+    # common logic to cancel the entire run if this job fails
+    - run: gh run cancel ${{ github.run_id }}
+      if: failure() && github.event_name != 'pull_request'
+      env:
+        GH_TOKEN: ${{ github.token }}
+  
+  build-preview1-component-adapter-provider:
+    name: Build wasi-preview1-component-adapter-provider
+    needs: build-preview1-component-adapter
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v4
+      with:
+        submodules: true
+    - uses: ./.github/actions/install-rust
+    - uses: ./.github/actions/build-adapter-provider
+      with:
+        run-id: ${{ github.run_id }}
+    
+
     # common logic to cancel the entire run if this job fails
     - run: gh run cancel ${{ github.run_id }}
       if: failure() && github.event_name != 'pull_request'
@@ -1080,6 +1100,7 @@ jobs:
       - determine
       - miri
       - build-preview1-component-adapter
+      - build-preview1-component-adapter-provider
       - build-wasmtime-target-wasm32
       - test-min-platform-example
       - check_js
diff --git a/.github/workflows/publish-artifacts.yml b/.github/workflows/publish-artifacts.yml
index 9ef7e2bcb..4a108ff08 100644
--- a/.github/workflows/publish-artifacts.yml
+++ b/.github/workflows/publish-artifacts.yml
@@ -14,15 +14,9 @@ jobs:
     if: github.repository == 'bytecodealliance/wasmtime'
     steps:
     - uses: actions/checkout@v4
+    - uses: ./.github/actions/fetch-run-id
     - run: |
-        sha=${{ github.sha }}
-        run_id=$(
-          gh api -H 'Accept: application/vnd.github+json' \
-              /repos/${{ github.repository }}/actions/workflows/main.yml/runs\?exclude_pull_requests=true \
-              | jq '.workflow_runs' \
-              | jq "map(select(.head_commit.id == \"$sha\"))[0].id" \
-        )
-        gh run download $run_id
+        gh run download ${COMMIT_RUN_ID}
         ls
         find bins-*
       env:
diff --git a/.github/workflows/publish-to-cratesio.yml b/.github/workflows/publish-to-cratesio.yml
index 23af15a85..46d3611a3 100644
--- a/.github/workflows/publish-to-cratesio.yml
+++ b/.github/workflows/publish-to-cratesio.yml
@@ -23,3 +23,12 @@ jobs:
         ./publish publish
       env:
         CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
+    
+    # Manifest and publish the wasi-preview1-component-adapter-provider
+    - uses: ./.github/actions/fetch-run-id
+    - uses: ./.github/actions/build-adapter-provider
+      with:
+        run-id: ${{ env.COMMIT_RUN_ID }}
+    - run: cargo publish -p wasi-preview1-component-adapter-provider --allow-dirty
+      env:
+        CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
diff --git a/Cargo.lock b/Cargo.lock
index 3166cb2b4..d431f5789 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -841,7 +841,7 @@ dependencies = [
  "serde_derive",
  "smallvec",
  "target-lexicon",
- "wasmparser 0.212.0",
+ "wasmparser",
  "wasmtime-types",
  "wat",
 ]
@@ -2094,9 +2094,9 @@ dependencies = [
 
 [[package]]
 name = "prettyplease"
-version = "0.2.19"
+version = "0.2.20"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5ac2cf0f2e4f42b49f5ffd07dae8d746508ef7526c13940e5f524012ae6c6550"
+checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e"
 dependencies = [
  "proc-macro2",
  "syn 2.0.60",
@@ -2752,7 +2752,7 @@ dependencies = [
  "cargo_metadata",
  "heck 0.4.0",
  "wasmtime",
- "wit-component 0.212.0",
+ "wit-component",
 ]
 
 [[package]]
@@ -3082,7 +3082,7 @@ name = "verify-component-adapter"
 version = "24.0.0"
 dependencies = [
  "anyhow",
- "wasmparser 0.212.0",
+ "wasmparser",
  "wat",
 ]
 
@@ -3175,7 +3175,7 @@ dependencies = [
  "byte-array-literals",
  "object 0.36.0",
  "wasi",
- "wasm-encoder 0.212.0",
+ "wasm-encoder",
  "wit-bindgen-rust-macro",
 ]
 
@@ -3233,15 +3233,6 @@ version = "0.2.87"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1"
 
-[[package]]
-name = "wasm-encoder"
-version = "0.209.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b4a05336882dae732ce6bd48b7e11fe597293cb72c13da4f35d7d5f8d53b2a7"
-dependencies = [
- "leb128",
-]
-
 [[package]]
 name = "wasm-encoder"
 version = "0.212.0"
@@ -3249,23 +3240,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "501940df4418b8929eb6d52f1aade1fdd15a5b86c92453cb696e3c906bd3fc33"
 dependencies = [
  "leb128",
- "wasmparser 0.212.0",
-]
-
-[[package]]
-name = "wasm-metadata"
-version = "0.209.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4d32029ce424f6d3c2b39b4419fb45a0e2d84fb0751e0c0a32b7ce8bd5d97f46"
-dependencies = [
- "anyhow",
- "indexmap 2.2.6",
- "serde",
- "serde_derive",
- "serde_json",
- "spdx",
- "wasm-encoder 0.209.1",
- "wasmparser 0.209.1",
+ "wasmparser",
 ]
 
 [[package]]
@@ -3280,8 +3255,8 @@ dependencies = [
  "serde_derive",
  "serde_json",
  "spdx",
- "wasm-encoder 0.212.0",
- "wasmparser 0.212.0",
+ "wasm-encoder",
+ "wasmparser",
 ]
 
 [[package]]
@@ -3294,8 +3269,8 @@ dependencies = [
  "log",
  "rand",
  "thiserror",
- "wasm-encoder 0.212.0",
- "wasmparser 0.212.0",
+ "wasm-encoder",
+ "wasmparser",
 ]
 
 [[package]]
@@ -3309,7 +3284,7 @@ dependencies = [
  "flagset",
  "indexmap 2.2.6",
  "leb128",
- "wasm-encoder 0.212.0",
+ "wasm-encoder",
 ]
 
 [[package]]
@@ -3352,19 +3327,6 @@ dependencies = [
  "paste",
 ]
 
-[[package]]
-name = "wasmparser"
-version = "0.209.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "07035cc9a9b41e62d3bb3a3815a66ab87c993c06fe1cf6b2a3f2a18499d937db"
-dependencies = [
- "ahash",
- "bitflags 2.4.1",
- "hashbrown 0.14.3",
- "indexmap 2.2.6",
- "semver",
-]
-
 [[package]]
 name = "wasmparser"
 version = "0.212.0"
@@ -3396,7 +3358,7 @@ checksum = "dfac65326cc561112af88c3028f6dfdb140acff67ede33a8e86be2dc6b8956f7"
 dependencies = [
  "anyhow",
  "termcolor",
- "wasmparser 0.212.0",
+ "wasmparser",
 ]
 
 [[package]]
@@ -3440,8 +3402,8 @@ dependencies = [
  "target-lexicon",
  "tempfile",
  "wasi-common",
- "wasm-encoder 0.212.0",
- "wasmparser 0.212.0",
+ "wasm-encoder",
+ "wasmparser",
  "wasmtime-asm-macros",
  "wasmtime-cache",
  "wasmtime-component-macro",
@@ -3583,7 +3545,7 @@ dependencies = [
  "tracing",
  "walkdir",
  "wasi-common",
- "wasmparser 0.212.0",
+ "wasmparser",
  "wasmtime",
  "wasmtime-cache",
  "wasmtime-cli-flags",
@@ -3600,7 +3562,7 @@ dependencies = [
  "wast 212.0.0",
  "wat",
  "windows-sys 0.52.0",
- "wit-component 0.212.0",
+ "wit-component",
 ]
 
 [[package]]
@@ -3633,7 +3595,7 @@ dependencies = [
  "wasmtime",
  "wasmtime-component-util",
  "wasmtime-wit-bindgen",
- "wit-parser 0.212.0",
+ "wit-parser",
 ]
 
 [[package]]
@@ -3657,7 +3619,7 @@ dependencies = [
  "object 0.36.0",
  "target-lexicon",
  "thiserror",
- "wasmparser 0.212.0",
+ "wasmparser",
  "wasmtime-environ",
  "wasmtime-versioned-export-macros",
 ]
@@ -3682,8 +3644,8 @@ dependencies = [
  "serde",
  "serde_derive",
  "target-lexicon",
- "wasm-encoder 0.212.0",
- "wasmparser 0.212.0",
+ "wasm-encoder",
+ "wasmparser",
  "wasmprinter",
  "wasmtime-component-util",
  "wasmtime-types",
@@ -3698,7 +3660,7 @@ dependencies = [
  "component-fuzz-util",
  "env_logger",
  "libfuzzer-sys",
- "wasmparser 0.212.0",
+ "wasmparser",
  "wasmprinter",
  "wasmtime-environ",
  "wat",
@@ -3756,7 +3718,7 @@ dependencies = [
  "rand",
  "smallvec",
  "target-lexicon",
- "wasmparser 0.212.0",
+ "wasmparser",
  "wasmtime",
  "wasmtime-fuzzing",
 ]
@@ -3777,12 +3739,12 @@ dependencies = [
  "target-lexicon",
  "tempfile",
  "v8",
- "wasm-encoder 0.212.0",
+ "wasm-encoder",
  "wasm-mutate",
  "wasm-smith",
  "wasm-spec-interpreter",
  "wasmi",
- "wasmparser 0.212.0",
+ "wasmparser",
  "wasmprinter",
  "wasmtime",
  "wasmtime-wast",
@@ -3832,7 +3794,7 @@ dependencies = [
  "serde",
  "serde_derive",
  "smallvec",
- "wasmparser 0.212.0",
+ "wasmparser",
 ]
 
 [[package]]
@@ -3953,7 +3915,7 @@ dependencies = [
  "gimli",
  "object 0.36.0",
  "target-lexicon",
- "wasmparser 0.212.0",
+ "wasmparser",
  "wasmtime-cranelift",
  "wasmtime-environ",
  "winch-codegen",
@@ -3966,7 +3928,7 @@ dependencies = [
  "anyhow",
  "heck 0.4.0",
  "indexmap 2.2.6",
- "wit-parser 0.212.0",
+ "wit-parser",
 ]
 
 [[package]]
@@ -3992,7 +3954,7 @@ dependencies = [
  "leb128",
  "memchr",
  "unicode-width",
- "wasm-encoder 0.212.0",
+ "wasm-encoder",
 ]
 
 [[package]]
@@ -4131,7 +4093,7 @@ dependencies = [
  "regalloc2",
  "smallvec",
  "target-lexicon",
- "wasmparser 0.212.0",
+ "wasmparser",
  "wasmtime-cranelift",
  "wasmtime-environ",
 ]
@@ -4308,9 +4270,9 @@ dependencies = [
 
 [[package]]
 name = "wit-bindgen"
-version = "0.26.0"
+version = "0.27.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a84376ff4f74ed07674a1157c0bd19e6627ab01fc90952a27ccefb52a24530f0"
+checksum = "fabce76bbb8938536c437da0c3e1d4dda9065453f72a68f797c0cb3d67356a28"
 dependencies = [
  "wit-bindgen-rt",
  "wit-bindgen-rust-macro",
@@ -4318,45 +4280,48 @@ dependencies = [
 
 [[package]]
 name = "wit-bindgen-core"
-version = "0.26.0"
+version = "0.27.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "36d4706efb67fadfbbde77955b299b111dd096e6776d8c6561d92f6147941880"
+checksum = "1b43fbdd3497c471bbfb6973b1fb9ffe6949f158248cb43171d6f1cf3de7eaa3"
 dependencies = [
  "anyhow",
  "heck 0.5.0",
- "wit-parser 0.209.1",
+ "wit-parser",
 ]
 
 [[package]]
 name = "wit-bindgen-rt"
-version = "0.26.0"
+version = "0.27.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9"
+checksum = "75956ff0a04a87ca0526b07199ce3b9baee899f2e4723b5b63aa296ab172ec52"
 dependencies = [
  "bitflags 2.4.1",
 ]
 
 [[package]]
 name = "wit-bindgen-rust"
-version = "0.26.0"
+version = "0.27.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "514295193d1a2f42e6a948cd7d9fd81e2b8fadc319667dcf19fd7aceaf2113a2"
+checksum = "bf509c4ef97b18ec0218741c8318706ac30ff16bc1731f990319a42bbbcfe8e3"
 dependencies = [
  "anyhow",
  "heck 0.5.0",
  "indexmap 2.2.6",
- "wasm-metadata 0.209.1",
+ "prettyplease",
+ "syn 2.0.60",
+ "wasm-metadata",
  "wit-bindgen-core",
- "wit-component 0.209.1",
+ "wit-component",
 ]
 
 [[package]]
 name = "wit-bindgen-rust-macro"
-version = "0.26.0"
+version = "0.27.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f0409a3356ca02599aff78f717968fd7f12df4bf879f325e2a97b45c84c90fff"
+checksum = "88d6f2e025e38395d71fc1bf064e581b2ad275ce322d6f8d87ddc5e76a7b8c42"
 dependencies = [
  "anyhow",
+ "prettyplease",
  "proc-macro2",
  "quote",
  "syn 2.0.60",
@@ -4364,25 +4329,6 @@ dependencies = [
  "wit-bindgen-rust",
 ]
 
-[[package]]
-name = "wit-component"
-version = "0.209.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "25a2bb5b039f9cb03425e1d5a6e54b441ca4ca1b1d4fa6a0924db67a55168f99"
-dependencies = [
- "anyhow",
- "bitflags 2.4.1",
- "indexmap 2.2.6",
- "log",
- "serde",
- "serde_derive",
- "serde_json",
- "wasm-encoder 0.209.1",
- "wasm-metadata 0.209.1",
- "wasmparser 0.209.1",
- "wit-parser 0.209.1",
-]
-
 [[package]]
 name = "wit-component"
 version = "0.212.0"
@@ -4396,28 +4342,10 @@ dependencies = [
  "serde",
  "serde_derive",
  "serde_json",
- "wasm-encoder 0.212.0",
- "wasm-metadata 0.212.0",
- "wasmparser 0.212.0",
- "wit-parser 0.212.0",
-]
-
-[[package]]
-name = "wit-parser"
-version = "0.209.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3e79b9e3c0b6bb589dec46317e645851e0db2734c44e2be5e251b03ff4a51269"
-dependencies = [
- "anyhow",
- "id-arena",
- "indexmap 2.2.6",
- "log",
- "semver",
- "serde",
- "serde_derive",
- "serde_json",
- "unicode-xid",
- "wasmparser 0.209.1",
+ "wasm-encoder",
+ "wasm-metadata",
+ "wasmparser",
+ "wit-parser",
 ]
 
 [[package]]
@@ -4435,7 +4363,7 @@ dependencies = [
  "serde_derive",
  "serde_json",
  "unicode-xid",
- "wasmparser 0.212.0",
+ "wasmparser",
 ]
 
 [[package]]
diff --git a/Cargo.toml b/Cargo.toml
index 4c6c74c9c..3043a9320 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -249,8 +249,8 @@ io-lifetimes = { version = "2.0.3", default-features = false }
 io-extras = "0.18.1"
 rustix = "0.38.31"
 # wit-bindgen:
-wit-bindgen = { version = "0.26.0", default-features = false }
-wit-bindgen-rust-macro = { version = "0.26.0", default-features = false }
+wit-bindgen = { version = "0.27.0", default-features = false }
+wit-bindgen-rust-macro = { version = "0.27.0", default-features = false }
 
 # wasm-tools family:
 wasmparser = { version = "0.212.0", default-features = false }
diff --git a/ci/build-wasi-preview1-component-adapter-provider.sh b/ci/build-wasi-preview1-component-adapter-provider.sh
new file mode 100755
index 000000000..c8c2bf4d2
--- /dev/null
+++ b/ci/build-wasi-preview1-component-adapter-provider.sh
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+set -ex
+
+# Manifest the adapter provider into the workspace
+cp crates/wasi-preview1-component-adapter/provider/Cargo.toml.in crates/wasi-preview1-component-adapter/provider/Cargo.toml
+sed -i '/"crates\/wasi-preview1-component-adapter",/a\ \ "crates\/wasi-preview1-component-adapter\/provider",' Cargo.toml
+
+# Check the adapter provider's code formatting and style
+cargo fmt -p wasi-preview1-component-adapter-provider -- --check
+cargo check -p wasi-preview1-component-adapter-provider
+cargo clippy -p wasi-preview1-component-adapter-provider
+
+# Check that publishing the adapter provider should work
+cargo publish -p wasi-preview1-component-adapter-provider --dry-run --allow-dirty
diff --git a/ci/build-wasi-preview1-component-adapter.sh b/ci/build-wasi-preview1-component-adapter.sh
index 76dcbc1c1..545a4e06f 100755
--- a/ci/build-wasi-preview1-component-adapter.sh
+++ b/ci/build-wasi-preview1-component-adapter.sh
@@ -15,24 +15,28 @@ release="target/wasm32-unknown-unknown/release/wasi_snapshot_preview1.wasm"
 $build_adapter
 $verify $debug
 
+build() {
+  input=$1
+  flavor=$2
+  $verify $input
+  name=wasi_snapshot_preview1.$flavor.wasm
+  dst=$(dirname $input)/$name
+  wasm-tools metadata add --name "wasi_preview1_component_adapter.$flavor.adapter" $input \
+    -o $dst
+}
+
 # Debug build, command
 $build_adapter --no-default-features --features command
 $verify $debug
 
 # Release build, command
 $build_adapter --release --no-default-features --features command
-$verify $release
-wasm-tools metadata add --name "wasi_preview1_component_adapter.command.adapter:${VERSION}" $release \
-  -o target/wasm32-unknown-unknown/release/wasi_snapshot_preview1.command.wasm
+build $release command
 
 # Release build, default features (reactor)
 $build_adapter --release
-$verify $release
-wasm-tools metadata add --name "wasi_preview1_component_adapter.reactor.adapter:${VERSION}" $release \
-  -o target/wasm32-unknown-unknown/release/wasi_snapshot_preview1.reactor.wasm
+build $release reactor
 
 # Release build, proxy
 $build_adapter --release --no-default-features --features proxy
-$verify $release
-wasm-tools metadata add --name "wasi_preview1_component_adapter.proxy.adapter:${VERSION}" $release \
-  -o target/wasm32-unknown-unknown/release/wasi_snapshot_preview1.proxy.wasm
+build $release proxy
diff --git a/crates/cranelift/src/debug/transform/attr.rs b/crates/cranelift/src/debug/transform/attr.rs
index 543b24a51..a6cb979fc 100644
--- a/crates/cranelift/src/debug/transform/attr.rs
+++ b/crates/cranelift/src/debug/transform/attr.rs
@@ -116,7 +116,15 @@ where
                     ..
                 } = file_context
                 {
-                    write::AttributeValue::FileIndex(Some(file_map[(i - file_index_base) as usize]))
+                    let index = usize::try_from(i - file_index_base)
+                        .ok()
+                        .and_then(|i| file_map.get(i).copied());
+                    match index {
+                        Some(index) => write::AttributeValue::FileIndex(Some(index)),
+                        // This was seen to be invalid in #8884 and #8904 so
+                        // ignore this seemingly invalid DWARF from LLVM
+                        None => continue,
+                    }
                 } else {
                     return Err(TransformError("unexpected file index attribute").into());
                 }
diff --git a/crates/jit-debug/src/perf_jitdump.rs b/crates/jit-debug/src/perf_jitdump.rs
index 6d6856e8d..4592318c0 100644
--- a/crates/jit-debug/src/perf_jitdump.rs
+++ b/crates/jit-debug/src/perf_jitdump.rs
@@ -252,8 +252,7 @@ impl JitDumpFile {
     pub fn dump_code_load_record(
         &mut self,
         method_name: &str,
-        addr: *const u8,
-        len: usize,
+        code: &[u8],
         timestamp: u64,
         pid: u32,
         tid: u32,
@@ -263,7 +262,7 @@ impl JitDumpFile {
 
         let rh = RecordHeader {
             id: RecordId::JitCodeLoad as u32,
-            record_size: size_limit as u32 + name_len as u32 + len as u32,
+            record_size: size_limit as u32 + name_len as u32 + code.len() as u32,
             timestamp,
         };
 
@@ -271,16 +270,13 @@ impl JitDumpFile {
             header: rh,
             pid,
             tid,
-            virtual_address: addr as u64,
-            address: addr as u64,
-            size: len as u64,
+            virtual_address: code.as_ptr() as u64,
+            address: code.as_ptr() as u64,
+            size: code.len() as u64,
             index: self.next_code_index(),
         };
 
-        unsafe {
-            let code_buffer: &[u8] = std::slice::from_raw_parts(addr, len);
-            self.write_code_load_record(method_name, clr, code_buffer)
-        }
+        self.write_code_load_record(method_name, clr, code)
     }
 }
 
diff --git a/crates/wasi-preview1-component-adapter/provider/.gitignore b/crates/wasi-preview1-component-adapter/provider/.gitignore
new file mode 100644
index 000000000..1ae47fad8
--- /dev/null
+++ b/crates/wasi-preview1-component-adapter/provider/.gitignore
@@ -0,0 +1,1 @@
+/Cargo.toml
diff --git a/crates/wasi-preview1-component-adapter/provider/Cargo.toml.in b/crates/wasi-preview1-component-adapter/provider/Cargo.toml.in
new file mode 100644
index 000000000..9f0ea47c7
--- /dev/null
+++ b/crates/wasi-preview1-component-adapter/provider/Cargo.toml.in
@@ -0,0 +1,19 @@
+[package]
+name = "wasi-preview1-component-adapter-provider"
+version.workspace = true
+authors.workspace = true
+description = "Embedded wasi-preview1-component-adapter binaries"
+license = "Apache-2.0 WITH LLVM-exception"
+repository = "https://github.com/bytecodealliance/wasmtime"
+documentation = "https://docs.rs/wasi-preview1-component-adapter-provider/"
+categories = ["wasm"]
+keywords = ["webassembly", "wasm"]
+edition.workspace = true
+
+[lints]
+workspace = true
+
+[package.metadata.docs.rs]
+all-features = true
+
+[dependencies]
diff --git a/crates/wasi-preview1-component-adapter/provider/artefacts/.gitignore b/crates/wasi-preview1-component-adapter/provider/artefacts/.gitignore
new file mode 100644
index 000000000..46be8eadb
--- /dev/null
+++ b/crates/wasi-preview1-component-adapter/provider/artefacts/.gitignore
@@ -0,0 +1,3 @@
+/wasi_snapshot_preview1.reactor.wasm
+/wasi_snapshot_preview1.command.wasm
+/wasi_snapshot_preview1.proxy.wasm
diff --git a/crates/wasi-preview1-component-adapter/provider/src/lib.rs b/crates/wasi-preview1-component-adapter/provider/src/lib.rs
new file mode 100644
index 000000000..0783c93bd
--- /dev/null
+++ b/crates/wasi-preview1-component-adapter/provider/src/lib.rs
@@ -0,0 +1,51 @@
+//! This crate contains the binaries of three WebAssembly modules:
+//!
+//! - [`WASI_SNAPSHOT_PREVIEW1_REACTOR_ADAPTER`]
+//! - [`WASI_SNAPSHOT_PREVIEW1_COMMAND_ADAPTER`]
+//! - [`WASI_SNAPSHOT_PREVIEW1_PROXY_ADAPTER`]
+//!
+//! These three modules bridge the wasip1 ABI to the wasip2 ABI of the component
+//! model.
+//!
+//! They can be given to the [`wit_component::ComponentEncoder::adapter`]
+//! method, using the [`WASI_SNAPSHOT_PREVIEW1_ADAPTER_NAME`], to translate a
+//! module from the historical WASM ABI to the canonical ABI.
+//!
+//! [`wit_component::ComponentEncoder::adapter`]: https://docs.rs/wit-component/latest/wit_component/struct.ComponentEncoder.html#method.adapter
+
+/// The name of the adapters in this crate, which may be provided to
+/// [`wit_component::ComponentEncoder::adapter`].
+///
+/// [`wit_component::ComponentEncoder::adapter`]: https://docs.rs/wit-component/latest/wit_component/struct.ComponentEncoder.html#method.adapter
+pub const WASI_SNAPSHOT_PREVIEW1_ADAPTER_NAME: &str = "wasi_snapshot_preview1";
+
+/// The "reactor" adapter provides the default adaptation from preview1 to
+/// preview2.
+///
+/// This adapter implements the [`wasi:cli/imports`] world.
+///
+/// [`wasi:cli/imports`]: https://github.com/WebAssembly/WASI/blob/01bb90d8b66cbc1d50349aaaab9ac5b143c9c98c/preview2/cli/imports.wit
+pub const WASI_SNAPSHOT_PREVIEW1_REACTOR_ADAPTER: &[u8] =
+    include_bytes!("../artefacts/wasi_snapshot_preview1.reactor.wasm");
+
+/// The "command" adapter extends the ["reactor" adapter] and additionally
+/// exports a `run` function entrypoint.
+///
+/// This adapter implements the [`wasi:cli/command`] world.
+///
+/// ["reactor" adapter]: WASI_SNAPSHOT_PREVIEW1_REACTOR_ADAPTER
+/// [`wasi:cli/command`]: https://github.com/WebAssembly/WASI/blob/01bb90d8b66cbc1d50349aaaab9ac5b143c9c98c/preview2/cli/command.wit
+pub const WASI_SNAPSHOT_PREVIEW1_COMMAND_ADAPTER: &[u8] =
+    include_bytes!("../artefacts/wasi_snapshot_preview1.command.wasm");
+
+/// The "proxy" adapter provides implements a HTTP proxy which is more
+/// restricted than the ["reactor" adapter] adapter, as it lacks filesystem,
+/// socket, environment, exit, and terminal support, but includes HTTP handlers
+/// for incoming and outgoing requests.
+///
+/// This adapter implements the [`wasi:http/proxy`] world.
+///
+/// ["reactor" adapter]: WASI_SNAPSHOT_PREVIEW1_REACTOR_ADAPTER
+/// [`wasi:http/proxy`]: https://github.com/WebAssembly/WASI/blob/01bb90d8b66cbc1d50349aaaab9ac5b143c9c98c/preview2/http/proxy.wit
+pub const WASI_SNAPSHOT_PREVIEW1_PROXY_ADAPTER: &[u8] =
+    include_bytes!("../artefacts/wasi_snapshot_preview1.proxy.wasm");
diff --git a/crates/wasi-preview1-component-adapter/src/lib.rs b/crates/wasi-preview1-component-adapter/src/lib.rs
index 83b0475a2..56d1f6e70 100644
--- a/crates/wasi-preview1-component-adapter/src/lib.rs
+++ b/crates/wasi-preview1-component-adapter/src/lib.rs
@@ -62,6 +62,7 @@ pub mod bindings {
         // Instead, we manually define the bindings for these functions in
         // terms of raw pointers.
         skip: ["run", "get-environment", "poll"],
+        generate_all,
     });
 
     #[cfg(feature = "reactor")]
@@ -78,6 +79,7 @@ pub mod bindings {
         // Instead, we manually define the bindings for these functions in
         // terms of raw pointers.
         skip: ["get-environment", "poll"],
+        generate_all,
     });
 
     #[cfg(feature = "proxy")]
@@ -99,6 +101,7 @@ pub mod bindings {
         raw_strings,
         runtime_path: "crate::bindings::wit_bindgen_rt_shim",
         skip: ["poll"],
+        generate_all,
     });
 
     pub mod wit_bindgen_rt_shim {
diff --git a/crates/wasmtime/src/profiling_agent.rs b/crates/wasmtime/src/profiling_agent.rs
index b32b84619..50480a624 100644
--- a/crates/wasmtime/src/profiling_agent.rs
+++ b/crates/wasmtime/src/profiling_agent.rs
@@ -45,7 +45,7 @@ cfg_if::cfg_if! {
 
 /// Common interface for profiling tools.
 pub trait ProfilingAgent: Send + Sync + 'static {
-    fn register_function(&self, name: &str, addr: *const u8, size: usize);
+    fn register_function(&self, name: &str, code: &[u8]);
 
     fn register_module(&self, code: &[u8], custom_name: &dyn Fn(usize) -> Option<String>) {
         use object::{File, Object as _, ObjectSection, ObjectSymbol, SectionKind, SymbolKind};
@@ -55,9 +55,9 @@ pub trait ProfilingAgent: Send + Sync + 'static {
             Err(_) => return,
         };
 
-        let text_base = match image.sections().find(|s| s.kind() == SectionKind::Text) {
+        let text = match image.sections().find(|s| s.kind() == SectionKind::Text) {
             Some(section) => match section.data() {
-                Ok(data) => data.as_ptr() as usize,
+                Ok(data) => data,
                 Err(_) => return,
             },
             None => return,
@@ -76,7 +76,6 @@ pub trait ProfilingAgent: Send + Sync + 'static {
                 continue;
             }
             if let Ok(name) = sym.name() {
-                let addr = text_base + address as usize;
                 let owned;
                 let name = match custom_name(address as usize) {
                     Some(name) => {
@@ -85,7 +84,8 @@ pub trait ProfilingAgent: Send + Sync + 'static {
                     }
                     None => name,
                 };
-                self.register_function(name, addr as *const u8, size as usize);
+                let code = &text[address as usize..][..size as usize];
+                self.register_function(name, code)
             }
         }
     }
@@ -99,6 +99,6 @@ pub fn new_null() -> Box<dyn ProfilingAgent> {
 struct NullProfilerAgent;
 
 impl ProfilingAgent for NullProfilerAgent {
-    fn register_function(&self, _name: &str, _addr: *const u8, _size: usize) {}
+    fn register_function(&self, _name: &str, _code: &[u8]) {}
     fn register_module(&self, _code: &[u8], _custom_name: &dyn Fn(usize) -> Option<String>) {}
 }
diff --git a/crates/wasmtime/src/profiling_agent/jitdump.rs b/crates/wasmtime/src/profiling_agent/jitdump.rs
index 5de53984f..cb8a49ece 100644
--- a/crates/wasmtime/src/profiling_agent/jitdump.rs
+++ b/crates/wasmtime/src/profiling_agent/jitdump.rs
@@ -50,14 +50,13 @@ pub fn new() -> Result<Box<dyn ProfilingAgent>> {
 }
 
 impl ProfilingAgent for JitDumpAgent {
-    fn register_function(&self, name: &str, addr: *const u8, size: usize) {
+    fn register_function(&self, name: &str, code: &[u8]) {
         let mut jitdump_file = JITDUMP_FILE.lock().unwrap();
         let jitdump_file = jitdump_file.as_mut().unwrap();
         let timestamp = jitdump_file.get_time_stamp();
         #[allow(trivial_numeric_casts)]
         let tid = rustix::thread::gettid().as_raw_nonzero().get() as u32;
-        if let Err(err) =
-            jitdump_file.dump_code_load_record(&name, addr, size, timestamp, self.pid, tid)
+        if let Err(err) = jitdump_file.dump_code_load_record(&name, code, timestamp, self.pid, tid)
         {
             println!("Jitdump: write_code_load_failed_record failed: {:?}\n", err);
         }
diff --git a/crates/wasmtime/src/profiling_agent/perfmap.rs b/crates/wasmtime/src/profiling_agent/perfmap.rs
index c60a28440..8ed7fc892 100644
--- a/crates/wasmtime/src/profiling_agent/perfmap.rs
+++ b/crates/wasmtime/src/profiling_agent/perfmap.rs
@@ -21,26 +21,27 @@ pub fn new() -> Result<Box<dyn ProfilingAgent>> {
 }
 
 impl PerfMapAgent {
-    fn make_line(
-        writer: &mut dyn Write,
-        name: &str,
-        addr: *const u8,
-        len: usize,
-    ) -> io::Result<()> {
+    fn make_line(writer: &mut dyn Write, name: &str, code: &[u8]) -> io::Result<()> {
         // Format is documented here: https://github.com/torvalds/linux/blob/master/tools/perf/Documentation/jit-interface.txt
         // Try our best to sanitize the name, since wasm allows for any utf8 string in there.
         let sanitized_name = name.replace('\n', "_").replace('\r', "_");
-        write!(writer, "{:x} {:x} {}\n", addr as usize, len, sanitized_name)?;
+        write!(
+            writer,
+            "{:p} {:x} {}\n",
+            code.as_ptr(),
+            code.len(),
+            sanitized_name
+        )?;
         writer.flush()?;
         Ok(())
     }
 }
 
 impl ProfilingAgent for PerfMapAgent {
-    fn register_function(&self, name: &str, addr: *const u8, size: usize) {
+    fn register_function(&self, name: &str, code: &[u8]) {
         let mut file = PERFMAP_FILE.lock().unwrap();
         let file = file.as_mut().unwrap();
-        if let Err(err) = Self::make_line(file, name, addr, size) {
+        if let Err(err) = Self::make_line(file, name, code) {
             eprintln!("Error when writing import trampoline info to the perf map file: {err}");
         }
     }
diff --git a/crates/wasmtime/src/profiling_agent/vtune.rs b/crates/wasmtime/src/profiling_agent/vtune.rs
index 159792401..cbf7f5d7b 100644
--- a/crates/wasmtime/src/profiling_agent/vtune.rs
+++ b/crates/wasmtime/src/profiling_agent/vtune.rs
@@ -47,10 +47,10 @@ impl Drop for VTuneAgent {
 
 impl State {
     /// Notify vtune about a newly tracked code region.
-    fn notify_code(&mut self, module_name: &str, method_name: &str, addr: *const u8, len: usize) {
+    fn notify_code(&mut self, module_name: &str, method_name: &str, code: &[u8]) {
         self.vtune
             .load_method(
-                MethodLoadBuilder::new(method_name.to_owned(), addr, len)
+                MethodLoadBuilder::new(method_name.to_owned(), code.as_ptr(), code.len())
                     .class_file_name(module_name.to_owned())
                     .source_file_name("<unknown wasm filename>".to_owned()),
             )
@@ -65,16 +65,13 @@ impl State {
 }
 
 impl ProfilingAgent for VTuneAgent {
-    fn register_function(&self, name: &str, addr: *const u8, size: usize) {
-        self.state
-            .lock()
-            .unwrap()
-            .register_function(name, addr, size);
+    fn register_function(&self, name: &str, code: &[u8]) {
+        self.state.lock().unwrap().register_function(name, code);
     }
 }
 
 impl State {
-    fn register_function(&mut self, name: &str, addr: *const u8, size: usize) {
-        self.notify_code("wasmtime", name, addr, size);
+    fn register_function(&mut self, name: &str, code: &[u8]) {
+        self.notify_code("wasmtime", name, code);
     }
 }
diff --git a/supply-chain/imports.lock b/supply-chain/imports.lock
index b588240c5..b304b8781 100644
--- a/supply-chain/imports.lock
+++ b/supply-chain/imports.lock
@@ -1770,6 +1770,13 @@ user-id = 3618
 user-login = "dtolnay"
 user-name = "David Tolnay"
 
+[[publisher.prettyplease]]
+version = "0.2.20"
+when = "2024-05-07"
+user-id = 3618
+user-login = "dtolnay"
+user-name = "David Tolnay"
+
 [[publisher.proc-macro2]]
 version = "1.0.81"
 when = "2024-04-17"
@@ -3542,6 +3549,12 @@ when = "2024-05-30"
 user-id = 73222
 user-login = "wasmtime-publish"
 
+[[publisher.wit-bindgen]]
+version = "0.27.0"
+when = "2024-06-28"
+user-id = 73222
+user-login = "wasmtime-publish"
+
 [[publisher.wit-bindgen-core]]
 version = "0.20.0"
 when = "2024-02-29"
@@ -3566,6 +3579,12 @@ when = "2024-05-30"
 user-id = 73222
 user-login = "wasmtime-publish"
 
+[[publisher.wit-bindgen-core]]
+version = "0.27.0"
+when = "2024-06-28"
+user-id = 73222
+user-login = "wasmtime-publish"
+
 [[publisher.wit-bindgen-rt]]
 version = "0.22.0"
 when = "2024-03-11"
@@ -3584,6 +3603,12 @@ when = "2024-05-30"
 user-id = 73222
 user-login = "wasmtime-publish"
 
+[[publisher.wit-bindgen-rt]]
+version = "0.27.0"
+when = "2024-06-28"
+user-id = 73222
+user-login = "wasmtime-publish"
+
 [[publisher.wit-bindgen-rust]]
 version = "0.20.0"
 when = "2024-02-29"
@@ -3608,6 +3633,12 @@ when = "2024-05-30"
 user-id = 73222
 user-login = "wasmtime-publish"
 
+[[publisher.wit-bindgen-rust]]
+version = "0.27.0"
+when = "2024-06-28"
+user-id = 73222
+user-login = "wasmtime-publish"
+
 [[publisher.wit-bindgen-rust-macro]]
 version = "0.20.0"
 when = "2024-02-29"
@@ -3632,6 +3663,12 @@ when = "2024-05-30"
 user-id = 73222
 user-login = "wasmtime-publish"
 
+[[publisher.wit-bindgen-rust-macro]]
+version = "0.27.0"
+when = "2024-06-28"
+user-id = 73222
+user-login = "wasmtime-publish"
+
 [[publisher.wit-component]]
 version = "0.201.0"
 when = "2024-02-27"


Test patch:
diff --git a/crates/test-programs/src/bin/api_reactor.rs b/crates/test-programs/src/bin/api_reactor.rs
index 7695dc0aa..ae8ecf9f9 100644
--- a/crates/test-programs/src/bin/api_reactor.rs
+++ b/crates/test-programs/src/bin/api_reactor.rs
@@ -1,6 +1,7 @@
 wit_bindgen::generate!({
     world: "test-reactor",
     path: "../wasi/wit",
+    generate_all,
 });
 
 struct T;
diff --git a/crates/test-programs/src/lib.rs b/crates/test-programs/src/lib.rs
index dfa4541a8..2ed2dcb8f 100644
--- a/crates/test-programs/src/lib.rs
+++ b/crates/test-programs/src/lib.rs
@@ -3,7 +3,11 @@ pub mod nn;
 pub mod preview1;
 pub mod sockets;
 
-wit_bindgen::generate!("test-command" in "../wasi/wit");
+wit_bindgen::generate!({
+    world: "test-command",
+    path: "../wasi/wit",
+    generate_all,
+});
 
 pub mod proxy {
     wit_bindgen::generate!({
@@ -14,6 +18,15 @@ pub mod proxy {
         with: {
             "wasi:http/types@0.2.0": crate::wasi::http::types,
             "wasi:http/outgoing-handler@0.2.0": crate::wasi::http::outgoing_handler,
+            "wasi:random/random@0.2.0": crate::wasi::random::random,
+            "wasi:io/error@0.2.0": crate::wasi::io::error,
+            "wasi:io/poll@0.2.0": crate::wasi::io::poll,
+            "wasi:io/streams@0.2.0": crate::wasi::io::streams,
+            "wasi:cli/stdout@0.2.0": crate::wasi::cli::stdout,
+            "wasi:cli/stderr@0.2.0": crate::wasi::cli::stderr,
+            "wasi:cli/stdin@0.2.0": crate::wasi::cli::stdin,
+            "wasi:clocks/monotonic-clock@0.2.0": crate::wasi::clocks::monotonic_clock,
+            "wasi:clocks/wall-clock@0.2.0": crate::wasi::clocks::wall_clock,
         },
     });
 }