wasm4
wasm4 copied to clipboard
Provide documentation about adding support for more languages!
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?
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).
I proposed support custom templates for png2src, can be used for generating image source without adding a generator template inside runtime.
#53
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:
- A way to import and export WebAssembly functions.
- The compiler must be configured to import memory. Generally compilers export their own memory by default.
- The memory needs to be sized to an initial size and maximum size of 1 page (64 KB).
- 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 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!)
I think binary will over 65k in scratch for C# =)
@eXponenta sad for that... But that doesn't mean i can't try any another language... 😄
@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 That's awesome! Please open a PR when you feel it's ready for others to use!