Skip to content

Fix: When symbol is both imported and exported, don't drop import#26356

Open
hoodmane wants to merge 4 commits intoemscripten-core:mainfrom
hoodmane:fix-syscall-wrapping
Open

Fix: When symbol is both imported and exported, don't drop import#26356
hoodmane wants to merge 4 commits intoemscripten-core:mainfrom
hoodmane:fix-syscall-wrapping

Conversation

@hoodmane
Copy link
Collaborator

@hoodmane hoodmane commented Feb 27, 2026

This fixes wrapping syscalls with -sMAIN_MODULE and -sEXPORT_ALL. Resolves #26355.

This fixes wrapping syscalls with -sMAIN_MODULE and -sEXPORT_ALL. Resolves issue 26355.
@hoodmane hoodmane force-pushed the fix-syscall-wrapping branch from 6ab4594 to 441ec3c Compare February 27, 2026 14:43
Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

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

Can we create a test case for this?

Kind sad we have to pipe this potentially-large array of string to the JS compiler, but maybe there is no other way to achieve this.

src/jsifier.mjs Outdated

// if the function was implemented in compiled code, there is no need to
// include the js version
if (WASM_EXPORTS.has(symbol) && !DEFAULT_LIBRARY_FUNCS_TO_INCLUDE.includes(symbol)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm.. i wonder if we might still need DEFAULT_LIBRARY_FUNCS_TO_INCLUDE ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Using DEFAULT_LIBRARY_FUNCS_TO_INCLUDE here broke some of the -O0 tests for reasons I don't completely understand -- something about missing makeInvalidEarlyAccess() settings. Using WASM_IMPORTS instead fixed it.

@hoodmane
Copy link
Collaborator Author

hoodmane commented Mar 5, 2026

Can we create a test case for this?

Added test_export_all_syscall_override.

I can't reproduce the test_precompiled_headers_pch, test_precompiled_headers_gch, and test_fp16_O3 failures locally, they all are working fine on my system.

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.

Wrapping syscalls doesn't work with -sMAIN_MODULE -sEXPORT_ALL

3 participants