Prevent cross-module inlining of remaining @_extern(wasm) functions#631
Merged
kateinoigakukun merged 1 commit intomainfrom Feb 13, 2026
Merged
Conversation
Extends the fix from b3ddd88 (which addressed f32/f64) to all remaining public @_extern(wasm) BridgeJS intrinsics: i32, string, pointer, throw, init_memory, and struct_cleanup. Without @inline(never) wrappers, the Swift compiler can inline these functions across module boundaries, causing the wasm import module attribute to change from "bjs" to "env". This results in a wasm-ld linker error when a downstream module (e.g. via BridgeJS codegen) references the same symbol with a different import module. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
872da4d to
1cf60d8
Compare
kateinoigakukun
approved these changes
Feb 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends the fix from #628 (
b3ddd88f) to all remaining public@_extern(wasm)BridgeJS intrinsics that were missing the@inline(never)wrapper pattern:_swift_js_throw_swift_js_init_memory_swift_js_push_string_swift_js_push_i32_swift_js_pop_i32_swift_js_struct_cleanup_swift_js_push_pointerProblem
Without
@inline(never)wrappers, the Swift compiler can inline these public@_extern(wasm, module: "bjs", ...)functions across module boundaries. When this happens, the wasm import module attribute changes from"bjs"to"env"(the default), causing awasm-ldlinker error:Fix
Applied the same pattern already used for f32/f64/pop_pointer: make the
@_externdeclarationprivateand wrap it with a@inline(never)public function that prevents cross-module inlining while preserving the correct wasm import module.🤖 Generated with Claude Code