Skip to content

Fix external usage of EM_JS functions #18928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 9, 2023
Merged

Fix external usage of EM_JS functions #18928

merged 1 commit into from
Mar 9, 2023

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Mar 9, 2023

When no local usage of an EM_JS function is present the compiler was completely removing the import of the function (and its import_name).

With this change we force at least one reference to the function by taking its address in an otherwise unused (and GC-able) pointer.

This use case was broken by the switch to LLD_REPORT_UNDEFINED in #16003.

Fixes: #18927

@kripken
Copy link
Member

kripken commented Mar 9, 2023

In what sense is it still GC-able? I assume only LTO can do it?

@sbc100
Copy link
Collaborator Author

sbc100 commented Mar 9, 2023

In what sense is it still GC-able? I assume only LTO can do it?

I mean that normal --gc-sections thing which is on by default in wasm-ld.

Basically wasm-ld will never see this pointer as being used so it won't allocate the 4-bytes to store it.

@sbc100 sbc100 force-pushed the fix_em_js branch 4 times, most recently from 1c9679b to f02d0cc Compare March 9, 2023 20:00
When no local usage of an EM_JS function is present the compiler was
completely removing the import of the function (and its import_name).

With this change we force at least one reference to the function by
taking its address in an otherwise unused (and GC-able) pointer.

This use case was broken by the switch to LLD_REPORT_UNDEFINED in #16003.

Fixes: #18927
@sbc100 sbc100 merged commit 8d041ba into main Mar 9, 2023
@sbc100 sbc100 deleted the fix_em_js branch March 9, 2023 23:00
@sbc100 sbc100 changed the title Fix external useage of EM_JS function Fix external usage of EM_JS function Mar 14, 2023
impact-maker pushed a commit to impact-maker/emscripten that referenced this pull request Mar 17, 2023
When no local usage of an EM_JS function is present the compiler was
completely removing the import of the function (and its import_name).

With this change we force at least one reference to the function by
taking its address in an otherwise unused (and GC-able) pointer.

This use case was broken by the switch to LLD_REPORT_UNDEFINED in emscripten-core#16003.

Fixes: emscripten-core#18927
impact-maker pushed a commit to impact-maker/emscripten that referenced this pull request Mar 17, 2023
When no local usage of an EM_JS function is present the compiler was
completely removing the import of the function (and its import_name).

With this change we force at least one reference to the function by
taking its address in an otherwise unused (and GC-able) pointer.

This use case was broken by the switch to LLD_REPORT_UNDEFINED in emscripten-core#16003.

Fixes: emscripten-core#18927
@sbc100 sbc100 changed the title Fix external usage of EM_JS function Fix external usage of EM_JS functions May 4, 2023
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.

EM_JS functions can only be called from the files in which they're defined
3 participants