Skip to content

fix(plugin): avoid importing __free from env#11908

Merged
kdy1 merged 2 commits into
mainfrom
kdy1/fix-free-wasm-import
May 28, 2026
Merged

fix(plugin): avoid importing __free from env#11908
kdy1 merged 2 commits into
mainfrom
kdy1/fix-free-wasm-import

Conversation

@kdy1

@kdy1 kdy1 commented May 28, 2026

Copy link
Copy Markdown
Member

Description:

  • Treat __free in plugin memory interop as the linked allocator symbol from swc_plugin::allocation, not an env host import.
  • Stop injecting env::__free from the Wasm plugin runtime import object.
  • This fixes the regression from build: Update rustc to nightly-2026-04-10 #11783 where __free was accidentally treated like a dynamic host import.

Related issue:

Related to #11783.

@kdy1
kdy1 requested a review from a team as a code owner May 28, 2026 08:44
kodiakhq[bot]
kodiakhq Bot previously approved these changes May 28, 2026
@changeset-bot

changeset-bot Bot commented May 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b3ed437

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kdy1
kdy1 enabled auto-merge (squash) May 28, 2026 08:46
@kdy1
kdy1 disabled auto-merge May 28, 2026 08:46
@kdy1
kdy1 enabled auto-merge (squash) May 28, 2026 08:46

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a145755e0b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 189 to 192
[
("__free", free_bytes),
(
"__set_transform_plugin_core_pkg_diagnostics",
set_plugin_core_pkg_diagnostics,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the legacy __free import shim

Plugins compiled while swc_plugin_proxy declared #[link(wasm_import_module = "env")] fn __free still have an env::__free import whenever they use host-returned values (metadata/comments/source maps). Since both Wasmtime and Wasmer instantiate with exactly the names returned from this import object, dropping this entry makes those otherwise schema-compatible plugins fail during runtime.init before the compatibility handshake can run. Keeping the shim is harmless for newly fixed plugins that no longer import it, and preserves loading for artifacts built with the previous release.

Useful? React with 👍 / 👎.

@kdy1
kdy1 disabled auto-merge May 28, 2026 08:56
@codspeed-hq

codspeed-hq Bot commented May 28, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 189 untouched benchmarks
⏩ 120 skipped benchmarks1


Comparing kdy1/fix-free-wasm-import (b3ed437) with main (4e2e9fc)2

Open in CodSpeed

Footnotes

  1. 120 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (bcfff7d) during the generation of this report, so 4e2e9fc was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@kdy1
kdy1 merged commit 4584296 into main May 28, 2026
67 checks passed
@kdy1
kdy1 deleted the kdy1/fix-free-wasm-import branch May 28, 2026 09:23
@github-actions github-actions Bot added this to the Planned milestone May 28, 2026
@kdy1 kdy1 modified the milestones: Planned, v1.15.41 Jun 10, 2026
@swc-project swc-project locked as resolved and limited conversation to collaborators Jul 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[email protected] are yanked

3 participants