Skip to content
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

Add WebAssembly as supported platform for Perl build #61

Open
vadimkantorov opened this issue Nov 26, 2024 · 7 comments
Open

Add WebAssembly as supported platform for Perl build #61

vadimkantorov opened this issue Nov 26, 2024 · 7 comments

Comments

@vadimkantorov
Copy link

vadimkantorov commented Nov 26, 2024

There is an initial successful attempt at

Supporting WebAssembly can help in some interop / legacy scenarios where it would be nice to run existing Perl scripts in a portable / simple / isolated WebAssembly platform - like in browser.

It would be nice if such platform was added to stock perl along with some smoke / github actions ci build tests

The patches to the Perl itself in Perl/perl5@blead...haukex:emperl5:emperl_v5.30.0 are quite minimal and are related to the process termination refactoring, signal handling, and minor fixes to makefiles. It would be awesome to upstream / add similar fixes to upstream - then it would be simpler to at least have a smoke build test

@vadimkantorov
Copy link
Author

Or please feel free to close / move this issue to another repo, as this suggestion is not about the Perl language itself

@haarg
Copy link
Contributor

haarg commented Nov 27, 2024

I'm not sure this really needs a PPC. I'm pretty sure we would welcome the addition of this as a platform, assuming the changes for it were sensible.

@tonycoz
Copy link

tonycoz commented Nov 27, 2024

One issue I can see is: can we run tests against it? preferably in a work flow, so we know if we break it.

@vadimkantorov
Copy link
Author

vadimkantorov commented Nov 27, 2024

One issue I can see is: can we run tests against it? preferably in a work flow, so we know if we break it.

Yeah, basic tests can be run, probably some WASI-powered wasm runtime like wasmtime/wasmer could be used, and certainly node can be used for this goal. Almost certain that even shebang / binfmt Linux mechanism can be adapted for this.

@vadimkantorov
Copy link
Author

vadimkantorov commented Nov 27, 2024

In total there are 12 commits in Perl/perl5@blead...haukex:emperl5:emperl_v5.30.0 :

Patches to Perl itself (here probably the noexit and signal patches are the most important ones):

  • Perl/perl5@2c6d518: Added perlmain_noexit_patch - probably the most important patch here for practical use of WASM-version of perl interpreter, but maybe still not absolutely mandatory to get basic "run script and destroy the interpreter" smoke-like tests
  • Perl/perl5@e0c5d90: Disable (almost) all of Perl's signal handling - maybe not needed anymore since Emscripten signal support stubs in Implement default signal handlers emscripten-core/emscripten#20257
  • Perl/perl5@4598ea2: Get Errno to work on Emscripten - here maybe the path to errno.h could be promoted to some variable with some extra paths to be defined from Configure step
  • Perl/perl5@d5271e7: Remove use of SOCK_CLOEXEC - here maybe defined(SOCK_CLOEXEC) option could be moved to some config.h / configure variable, then it can be defined via the emscripten platform hints file. Although maybe now not needed, for Emscripten has evolved since 2019 when webperl/emperl was created

Patches to build scripts of Perl:

  • Perl/perl5@1ded189: Fix a minor bug with --sysroot in Configure - maybe this can be added upstream without much review
  • Perl/perl5@b05e740: Added emscripten hints file
  • Perl/perl5@9abeeee: Customize Makefile.SH" (here an important thing is that maybe pod-files generation bugs, so the patch removes pod generation) - maybe here an option can be added to the upstream configure/Makefile to disable pod generation altogether, could be useful in the general case as well

The remaining patches are more on interop of JS/Emscripten <> Perl (and are less important for basic functioning):

@jkeenan
Copy link

jkeenan commented Nov 27, 2024

One issue I can see is: can we run tests against it? preferably in a work flow, so we know if we break it.

Also, regular smoke-test reports would be valuable.

@Leont
Copy link

Leont commented Nov 28, 2024

I'm not sure this really needs a PPC. I'm pretty sure we would welcome the addition of this as a platform, assuming the changes for it were sensible.

Yeah, I can't see any reason why anyone would be opposed to it, as long as there's someone actually supporting it (and preferably someone setting up an automatic testing).

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

No branches or pull requests

5 participants