Skip to content

[fpcast-emu] Allow export of fpcast$ thunks for dynamic linking - #9421

Open
sbc100 wants to merge 3 commits into
mainfrom
fpcast-emu-export-thunks
Open

sbc100 wants to merge 3 commits into
mainfrom
fpcast-emu-export-thunks

Conversation

@sbc100

@sbc100 sbc100 commented Nov 23, 2026

Copy link
Copy Markdown
Member

When --pass-arg=fpcast-emu-export-thunks is passed to fpcast-emu, export an (i64 x 16) -> i64 thunk named fpcast$<export> alongside each original function export by reusing the thunk in funcThunks.

Skip imports, dynCall_* and fpcast$* exports, and non-function exports, and unwrap orig$ suffixes so both direct and orig$ export pairs share the corresponding fpcast$ thunk export.

This enables dynamic linkers such as Emscripten to resolve uniform function pointer targets across MAIN_MODULE and SIDE_MODULE exports while preserving original direct-call exports.

When `--pass-arg=fpcast-emu-export-thunks` is passed to `fpcast-emu`,
export an `(i64 x 16) -> i64` thunk named `fpcast$<export>` alongside
each original function export by reusing the thunk in `funcThunks`.

Skip imports, `dynCall_*` and `fpcast$*` exports, and non-function
exports, and unwrap `orig$` suffixes so both direct and `orig$` export
pairs share the corresponding `fpcast$` thunk export.

This enables dynamic linkers such as Emscripten to resolve uniform
function pointer targets across `MAIN_MODULE` and `SIDE_MODULE` exports
while preserving original direct-call exports.
@sbc100 sbc100 changed the title [fpcast-emu] Export fpcast$ thunks for dynamic linking [fpcast-emu] Allow export of fpcast$ thunks for dynamic linking Nov 23, 2026
@sbc100
sbc100 requested a review from kripken November 23, 2026 22:37
@github-actions
github-actions Bot requested a review from tlively November 23, 2026 22:37

@github-actions github-actions 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.

🤖 Google Antigravity Code Review

I have reviewed the changes in this Pull Request and left inline feedback.

Comment thread src/passes/FuncCastEmulation.cpp Resolved
Comment thread src/passes/FuncCastEmulation.cpp Resolved
Comment thread src/passes/FuncCastEmulation.cpp Resolved
@sbc100
sbc100 requested a review from tlively November 24, 2026 00:26
Move the `--pass-arg=fpcast-emu-export-thunks` export loop out of
`FuncCastEmulation::run` into `exportThunks`, and deduplicate the
`funcThunks` lookup between table elements and exports via `getThunk`.
@sbc100
sbc100 force-pushed the fpcast-emu-export-thunks branch from f5cf6fa to 22969e7 Compare November 24, 2026 00:31

This branch has not been deployed

No deployments
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