[WASM] Perl crashes without LC_ALL=1
I've completed my work of compiling Perl5 to WebAssembly, but one issue I never tracked down is that if the environment variable LC_ALL is not set with a value off '1' Perl crashes with this error:
locale.c: 1480: panic: 'C.UTF-8;C;C;C;C;C' needs an '=' to split name=value
; errno=28
Called by locale.c: 4097
The only reason I found that solution is because of this issue, but other solutions did not work. Prior to me contributing an official target, this is one thing that needs to be resolved. Any hints or guidance would be appreciated.
The full workflow is here.
Could you give us the config.h that is being used when this error occurs?
Could you give us the
config.hthat is being used when this error occurs?
@andrewmd5, could you provide us with the file @khwilliamson requested above? Thanks.
@Leont Hoping the patches in https://github.com/6over3/zeroperl/tree/main/patches would get upstreamed, hintfile for WASM would get added to the stock perl, and it will get some smoke testing in CI...
It would also be nice to have more native support for read-only virtual FS by overriding PerlIO to load *.pm files from embedded memory:
- https://github.com/Perl/perl5/issues/22571
@Leont Hoping the patches in https://github.com/6over3/zeroperl/tree/main/patches would get upstreamed, hintfile for WASM would get added to the stock perl, and it will get some smoke testing in CI...
I think they are currently not in a mergable state, they make WASM work by breaking other platforms (glob.patch and wasi-exit.patch being the most obvious examples). And a few of them could use a cleanup. But it is a beginning of something that could be merged.
It would also be nice to have more native support for read-only virtual FS by overriding PerlIO to load *.pm files from embedded memory:
Yeah I think that's possible but also a non-trivial amount of work.
Yeah I think that's possible but also a non-trivial amount of work.
In the meanwhile, the approach of linker's --wrap= works, but it would be nice to also have built-in support of a C-land supported hook for loading *.pm files
For glob.patch - probably the right way could be to do detect getpwnam and getpwuid in build time, check with ifdefs and do not call them if they are not available?
And for wasi-exit.patch - probably these should just be under some ifdef check for WASI? @andrewmd5
WDYT?
@Leont Hoping the patches in https://github.com/6over3/zeroperl/tree/main/patches would get upstreamed, hintfile for WASM would get added to the stock perl, and it will get some smoke testing in CI...
I think they are currently not in a mergable state, they make WASM work by breaking other platforms (glob.patch and wasi-exit.patch being the most obvious examples). And a few of them could use a cleanup. But it is a beginning of something that could be merged.
It would also be nice to have more native support for read-only virtual FS by overriding PerlIO to load *.pm files from embedded memory:
Yeah I think that's possible but also a non-trivial amount of work.
Only the glob patch is actually applied; the wasi-exit isn’t needed since adding a setjmp runtime.
chmod u+w ./ext/File-Glob/bsd_glob.c && patch ./ext/File-Glob/bsd_glob.c ${{ github.workspace }}/patches/glob.patch && chmod u-w ./ext/File-Glob/bsd_glob.c
chmod u+w ./pp_sys.c && patch ./pp_sys.c ${{ github.workspace }}/patches/stat.patch && chmod u-w ./pp_sys.c
chmod u+w ./Configure && patch ./Configure ${{ github.workspace }}/patches/Configure.patch && chmod u-w ./Configure
And I don’t believe the Configure one is required anymore. The other two are just nuclear options for include hell. Really the only requirement is the asyncify changes and figuring out why locales are messed up.
Also, if supporting asynchronous WASI / WebAPI isn’t a priority, you could simplify things a bit. These articles might help clarify some of the trade-offs:
https://andrews.substack.com/p/get-in-loser-were-rewinding-the-stack
https://open.substack.com/pub/andrews/p/4-mains-or-nothing-at-all?utm_campaign=post&utm_medium=web
Let me know your thoughts.
Sent via Superhuman iOS ( @.*** )
On Thu, Oct 16, 2025 at 1:17 AM, Vadim Kantorov < @.*** > wrote:
vadimkantorov left a comment (Perl/perl5#22992) ( https://github.com/Perl/perl5/issues/22992#issuecomment-3407276446 )
For glob.patch - probably the right way could be to do detect getpwnam and getpwuid in build time, check with ifdefs and do not call them if they are not available?
And for wasi-exit.patch - probably these should just be under some ifdef check for WASI? @andrewmd5 ( https://github.com/andrewmd5 )
WDYT?
— Reply to this email directly, view it on GitHub ( https://github.com/Perl/perl5/issues/22992#issuecomment-3407276446 ) , or unsubscribe ( https://github.com/notifications/unsubscribe-auth/AAJ4VNLD5P3FKBFHCRVJ3DL3XZXR7AVCNFSM6AAAAABW64IKDOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTIMBXGI3TMNBUGY ). You are receiving this because you were mentioned. Message ID: <Perl/perl5/issues/22992/3407276446 @ github. com>
I finally figured it out. Configure's locale format detection fails during cross-compilation, defaulting to name=value pairs. WASI uses positional notation with semicolon separators. Since Configure unconditionally overwrites hint file values, we must patch config.sh after it runs and regenerate config.h. Fixes runtime panic: 'C.UTF-8;C;C;C;C;C' needs an '=' error.
https://github.com/6over3/zeroperl/pull/12/commits/9ffbd3d1f45b371ccbca9a64fb1c825151633a18
I finally figured it out. Configure's locale format detection fails during cross-compilation, defaulting to name=value pairs. WASI uses positional notation with semicolon separators. Since Configure unconditionally overwrites hint file values, we must patch config.sh after it runs and regenerate config.h. Fixes runtime panic: 'C.UTF-8;C;C;C;C;C' needs an '=' error.
I would argue this not being overridable is a bug (but probably a tricky one)
I agree it is a bug. I kind of think it could be an easy fix. Adding some ifndefs in perl.h and maybe skipping some code in Configure if the values are set, so that in a hint file one could set this. It is tricky for the caller to get the syntax exactly right, but if it's worth it to someone, we should allow them to try.
Let me know if I can provide any further details or funding for the sprint to help upstream & stabilize my work / findings.
With my latest batch of work I managed to get everything bundled into a WASM reactor module so Perl can be embedded in any host language. JavaScript Reference implementation here. Working on Swift at the moment.