Skip to content

[Serialization][wasm] Preserve wasm import metadata for SIL serialization#87250

Merged
MaxDesiatov merged 1 commit intoswiftlang:mainfrom
kateinoigakukun:yt/fix-extern-import
Feb 23, 2026
Merged

[Serialization][wasm] Preserve wasm import metadata for SIL serialization#87250
MaxDesiatov merged 1 commit intoswiftlang:mainfrom
kateinoigakukun:yt/fix-extern-import

Conversation

@kateinoigakukun
Copy link
Copy Markdown
Member

@kateinoigakukun kateinoigakukun commented Feb 16, 2026

Serialize/deserialize wasm import module/name for SIL serialization so inlined decls keep their import names. Otherwise, inlining a function with @_extern(wasm) would lose the import name and cause IRGen to emit an import from the default module "env".

Related links: swiftwasm/JavaScriptKit#631 swiftwasm/JavaScriptKit#628

Resolves #87320

@kateinoigakukun
Copy link
Copy Markdown
Member Author

@swift-ci smoke test

@kateinoigakukun
Copy link
Copy Markdown
Member Author

@swift-ci smoke test

@kateinoigakukun
Copy link
Copy Markdown
Member Author

@swift-ci smoke test

@kateinoigakukun
Copy link
Copy Markdown
Member Author

@swift-ci smoke test macOS Platform

@kateinoigakukun
Copy link
Copy Markdown
Member Author

@swift-ci smoke test Windows Platform

@kateinoigakukun
Copy link
Copy Markdown
Member Author

@swift-ci smoke test macOS Platform

@kateinoigakukun kateinoigakukun marked this pull request as ready for review February 18, 2026 13:18
@kateinoigakukun kateinoigakukun requested review from MaxDesiatov and removed request for xymus February 18, 2026 13:19
@MaxDesiatov MaxDesiatov added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. SILSerialization SIL WebAssembly Platform: WebAssembly labels Feb 18, 2026
@MaxDesiatov MaxDesiatov moved this to In Progress in Swift for Wasm Feb 18, 2026
@MaxDesiatov
Copy link
Copy Markdown
Contributor

@kateinoigakukun would you mind creating an issue that tracks this at https://github.com/swiftlang/swift/issues? If you plan to cherry-pick this for 6.3 the issue will be required anyway, but also desirable for main-only PRs

@kateinoigakukun
Copy link
Copy Markdown
Member Author

Opened a cherry-pick PR against 6.3 #87335

@MaxDesiatov MaxDesiatov requested a review from al45tair February 19, 2026 08:23
Comment thread lib/Serialization/DeserializeSIL.cpp Outdated
break;
case ExtraStringFlavor::WasmImportModule:
WasmImportModule = blobData;
if (!WasmImportField.empty())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can it be that only one of these two attributes is set and the other is empty? Then you wouldn't set the non-empty attribute at all.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point! Yes, one of them can be empty. Added tests to cover such cases.

…tion

Serialize/deserialize wasm import module/name for SIL serialization so
inlined decls keep their import names. Otherwise, inlining a function
with `@_extern(wasm)` would lose the import name and cause IRGen to emit
an import from the default module "env".
@kateinoigakukun
Copy link
Copy Markdown
Member Author

@swift-ci smoke test

Copy link
Copy Markdown
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm

@MaxDesiatov MaxDesiatov merged commit b5162b1 into swiftlang:main Feb 23, 2026
3 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Swift for Wasm Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. SIL SILSerialization WebAssembly Platform: WebAssembly

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[WebAssembly] "wasm-ld: import module mismatch for symbol" when using @_extern(wasm, ...)

4 participants