Skip to content

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

Merged
sbc100 merged 3 commits into
mainfrom
fpcast-emu-export-thunks
Nov 30, 2026
Merged

sbc100 merged 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 strip orig$ prefixes 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
@sbc100
sbc100 force-pushed the fpcast-emu-export-thunks branch from f5cf6fa to 22969e7 Compare November 24, 2026 00:31

@tlively tlively left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM % nits with "suffixes" fixed to "prefixes" in the description.

Comment thread src/passes/FuncCastEmulation.cpp Resolved
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 commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

LGTM % nits with "suffixes" fixed to "prefixes" in the description.

I think suffixes is correct maybe? I update it to orig$XXXX suffixes .. so its clear the it the XXX / suffix part that is being unwrapped?

@sbc100

sbc100 commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

LGTM % nits with "suffixes" fixed to "prefixes" in the description.

I think suffixes is correct maybe? I update it to orig$XXXX suffixes .. so its clear the it the XXX / suffix part that is being unwrapped?

I went with strip orig$ prefixes..

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 22969e7 to 03d4466 Compare November 30, 2026 21:49
@sbc100
sbc100 merged commit c354e2a into main Nov 30, 2026
18 of 19 checks passed
@sbc100
sbc100 deleted the fpcast-emu-export-thunks branch November 30, 2026 23:11
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