wasm4 icon indicating copy to clipboard operation
wasm4 copied to clipboard

Provide documentation about adding support for more languages!

Open ghost opened this issue 2 years ago • 8 comments

Hi, Thanks for WASM-4! ❤️

In fact WebAssembly have been supported by wide list of languages which can be found here: https://github.com/appcypher/awesome-wasm-langs

The only problem here that if dev would like to add support or definitions for a language from the list, By myself looked into docs but this isn't mentioned...

Is there a guide or someway to add more languages?

ghost avatar Sep 03 '21 01:09 ghost

Hello there! May I ask, what language are you planning to support?

The only problem here that if dev would like to add support or definitions for a language from the list, By myself looked into docs but this isn't mentioned...

My guess is you open an issue and discuss with the owner/contributors. Adding a support for a language requires a template (like here).

takaeri avatar Sep 03 '21 02:09 takaeri

I proposed support custom templates for png2src, can be used for generating image source without adding a generator template inside runtime.

#53

eXponenta avatar Sep 03 '21 08:09 eXponenta

Welcome!

Yeah, we need a page in the documentation for this. For now here's a rough guideline for anyone interested.

At a very minimum your language needs:

  1. A way to import and export WebAssembly functions.
  2. The compiler must be configured to import memory. Generally compilers export their own memory by default.
  3. The memory needs to be sized to an initial size and maximum size of 1 page (64 KB).
  4. The compiler must be configured to avoid using the lower region of memory reserved by WASM-4.

LLVM-based languages can use these wasm-ld linker flags to configure the above: --import-memory --initial-memory=65536 --max-memory=65536, --global-base=6560 and/or -zstack-size=....

I think that should be all you need to get a new language running with WASM-4. As a bonus, you can take it even further by including:

  • A new project template for w4 new.
  • An output format for w4 img2src.
  • Updated docs on the website.

If you're planning support for a specific language, definitely let us know! It's possible other language X users would be interested and willing to help.

aduros avatar Sep 04 '21 19:09 aduros

@aduros Thanks! ❤️

If had time will try to give Nim or C# a try... (Though i can't promise with that due to time lack, but if did will reply further and thanks!)

Rabios avatar Sep 05 '21 11:09 Rabios

I think binary will over 65k in scratch for C# =)

eXponenta avatar Sep 05 '21 11:09 eXponenta

@eXponenta sad for that... But that doesn't mean i can't try any another language... 😄

Rabios avatar Sep 05 '21 17:09 Rabios

@Rabios Hi, I've made a repo that shows how to use WASM-4 from Nim - https://github.com/Yardanico/wasm4nim/. I think after I polish things a bit more and create a nimble project (so that it can be built with a single command) I can add it to the wasm4 repo as a template.

Yardanico avatar Nov 11 '21 09:11 Yardanico

@Yardanico That's awesome! Please open a PR when you feel it's ready for others to use!

aduros avatar Nov 11 '21 11:11 aduros