Skip to content

link tag imports to exports instead of synthesizing tags - #2580

Merged
alexcrichton merged 1 commit into
bytecodealliance:mainfrom
dicej:tag-imports-revisited
Jul 27, 2026
Merged

alexcrichton merged 1 commit into
bytecodealliance:mainfrom
dicej:tag-imports-revisited

Conversation

@dicej

@dicej dicej commented Jul 27, 2026 •

Copy link
Copy Markdown
Collaborator

#2306 added code to define and export tags in the env module generated by wasm-tools component link in order to satisfy any imports of those tags by the libraries to be linked.

However, for LLVM-generated shared libraries using C++ exceptions, that's not what we want. Instead, libunwind.so will define and export the cpp_exception tag which those libraries import, in which case adding a duplicate definition to the env module only causes problems (e.g. a library can't catch exceptions because it's using a different tag in its try_table).

Unlike for functions, there no call_indirect-equivalent for breaking circular dependencies involving tags AFAICT, so we instead require that the module which exports a tag be instantiated before any modules which import that tag, which allows us to link the imports to the export directly. If that's not possible (e.g. due to some non-LLVM toolchain doing "weird" things), we'll raise an error.

bytecodealliance#2306 added code to define
 and export tags in the `env` module generated by `wasm-tools component link` in
 order to satisfy any imports of those tags by the libraries to be linked.

However, for LLVM-generated shared libraries using C++ exceptions, that's not
what we want.  Instead, `libunwind.so` will define and export the
`cpp_exception` tag which those libraries import, in which case adding a
duplicate definition to the `env` module only causes problems (e.g. a library
can't catch exceptions because it's using a different tag in its `try_table`).

Unlike for functions, there no `call_indirect`-equivalent for breaking circular
dependencies involving tags AFAICT, so we instead require that the module which
exports a tag be instantiated before any modules which import that tag, which
allows us to link the imports to the export directly.  If that's not possible
(e.g. due to some non-LLVM toolchain doing "weird" things), we'll raise an
error.
@dicej
dicej requested a review from alexcrichton July 27, 2026 20:20
@dicej
dicej requested a review from a team as a code owner July 27, 2026 20:20
@alexcrichton
alexcrichton enabled auto-merge July 27, 2026 20:24
@alexcrichton
alexcrichton added this pull request to the merge queue Jul 27, 2026
Merged via the queue into bytecodealliance:main with commit ecf95a7 Jul 27, 2026
37 checks passed
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
wasm-tools 1.255.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## What's Changed
* Fix generating deeply nested WIT types in `wit-smith` by @alexcrichton in bytecodealliance/wasm-tools#2576
* wasm-tools mutate: validate the input module before mutating by @SAY-5 in bytecodealliance/wasm-tools#2577
* link tag imports to exports instead of synthesizing tags by @dicej in bytecodealliance/wasm-tools#2580
* Fix folded branch hints by @vouillon in bytecodealliance/wasm-tools#2578
* support cooperative multithreading ABI in `wit_component::linking` by @dicej in bytecodealliance/wasm-tools#2581
* avoid calling `__wasm_init_task` more than once in `init` module by @dicej in bytecodealliance/wasm-tools#2582
* Support `__wasm_{g,s}et_{tls_base,stack_pointer}` in `wit-component` by @alexcrichton in bytecodealliance/wasm-tools#2584
* fix table resolution for `thread.new-indirect` intrinsic calls by @dicej in bytecodealliance/wasm-tools#2585
* Release wasm-tools 1.255.0 by @github-actions[bot] in bytecodealliance/wasm-tools#2586


**Full Changelog**: https://github.com/bytecodealliance/wasm-tools/compare/v1.254.0...v1.255.0</pre>
  <p>View the full release notes at <a href="https://github.com/bytecodealliance/wasm-tools/releases/tag/v1.255.0">https://github.com/bytecodealliance/wasm-tools/releases/tag/v1.255.0</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!15533
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants