[[bad mustMatch:]]: error while compiling to wasm

kinke noone at nowhere.com
Mon Jul 9 19:25:57 UTC 2018


On Sunday, 8 July 2018 at 09:01:09 UTC, Hüseyin Akbaş wrote:
> Some guy has created a toolchain like emscripten in order to 
> compile a few libraries for webasm  with the D code. However, I 
> couldn't make it work. Here is the link: 
> https://github.com/CyberShadow/dscripten-tools What do you 
> think? Is it useful?

I had a quick look.
dscripten compiles to asm.js, a JavaScript subset auto-generated 
from code in statically typed languages and which most modern JS 
engines are supposed to generate efficient code for.
'Compiling' to JavaScript isn't supported by official LLVM and 
seems to require changes to LLVM itself, not just an additional 
LLVM target, hence it isn't supported by LDC either, and that why 
there's the dscripten fork using emscripten's LLVM.

WebAssembly is an official LLVM target and AFAICT supposed to 
replace the ugly and inefficient asm.js layer (that's still 
source code after all, human-readable for masochists). The first 
version apparently doesn't give you access to the JS garbage 
collector or the DOM though. Even passing strings between JS and 
WebAssembly seems to be a PITA (never seen that much code needed 
to print a 'hello world' to a console [1]).
DOM and GC access is planned for WebAssembly v2 AFAIK, and only 
then things start getting interesting IMO, allowing for 
front-ends fully written in D or interoperating with other 
JS/WebAssembly libs.

[1] 
https://medium.com/@mbebenita/hello-world-in-webassembly-83951757775


More information about the digitalmars-d-ldc mailing list