You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove _ prefix/name mangling for native symbols #12844
With the original JS compiler native symbols historically got prefixed with an _.
With fastcomp this tradition was continued with JSBackend.cpp adding extra _ to all its exports.
With the llvm backend we still continue this mangling but only in the JS wrapper code. The actual exports from the wam module do not have this mangling but the wrapper code added this. See:
I suggest we add a new setting called MANGLE_NATIVE_SYMBOLS which defaults to 1. We can then default this to `0 in STRICT mode and one day change the default for everyone.
Alternative names for this setting:
MANGLE_EXPORTS
MANGLED_EXPORTS
PREFIX_EXPORTS
When this setting is enabled, EXPORTED_FUNCTIONS should also not contain the mangling so users would have to move from EXPORTED_FUNCTIONS=[_main] to EXPORTED_FUNCTIONS=[main]
Another option considered in #8380 is to let people opt-in to non-prefixed names with a new convenient export setting to unify all the existing ones. Assuming we want such a new export setting anyhow - I would say yes - it could save us from a new separate option.
Hmm, it seems that having a unified way to specify exports is somewhat orthogonal to whether the names are mangled. But I can see that if you are going to change the export system it might make sense to make both changes at the same time.
I think #8380 is somewhat more complicated and would require more investigation about that different types of exports. This change on the other hand seems very straight forward. I do need to think about #8380 some more though.. perhaps you are correct and that is the way to go.
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.
Activity
[-]Remove `_` prefix/name mangles for native symbols[/-][+]Remove `_` prefix/name mangling for native symbols[/+]kripken commentedon Nov 20, 2020
Another option considered in #8380 is to let people opt-in to non-prefixed names with a new convenient export setting to unify all the existing ones. Assuming we want such a new export setting anyhow - I would say yes - it could save us from a new separate option.
sbc100 commentedon Nov 20, 2020
Hmm, it seems that having a unified way to specify exports is somewhat orthogonal to whether the names are mangled. But I can see that if you are going to change the export system it might make sense to make both changes at the same time.
I think #8380 is somewhat more complicated and would require more investigation about that different types of exports. This change on the other hand seems very straight forward. I do need to think about #8380 some more though.. perhaps you are correct and that is the way to go.
stale commentedon Apr 17, 2022
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.
sbc100 commentedon Apr 17, 2024
I've been thinking about a plan for how to make this happen:
MANGLE_NATIVE_SYMBOLS, which defaults totrue(perhaps not in-sSTRICTmode).MANGLE_NATIVE_SYMBOLSis enabled.MANGLE_NATIVE_SYMBOLSinSTRICTmode and suggest that folks move away from mangled names.MANGLE_NATIVE_SYMBOLSby default and have folks opt into it for legacy support.This plan doesn't address how to deal with the underscore mangling in the
EXPORTED_FUNCTIONSlist.