Thread overview
Anyone tried to emscripten a D/SDL game?
May 24, 2017
Guillaume Piolat
Jun 05, 2017
Sebastien Alaiwan
Jun 05, 2017
Johan Engelen
Jun 05, 2017
Sebastien Alaiwan
May 24, 2017
Suliman
Jun 05, 2017
Sebastien Alaiwan
May 24, 2017
Anyone have any experience (successful or unsuccessful) attempting this? Any info on the current state of it, or pitfalls, or pointers for getting started?
May 24, 2017
On Wednesday, 24 May 2017 at 17:00:51 UTC, Nick Sabalausky "Abscissa" wrote:
> Anyone have any experience (successful or unsuccessful) attempting this? Any info on the current state of it, or pitfalls, or pointers for getting started?

http://code.alaiwan.org/wp/?p=103
May 24, 2017
On Wednesday, 24 May 2017 at 17:06:55 UTC, Guillaume Piolat wrote:
>
> http://code.alaiwan.org/wp/?p=103

Awesome, thanks!
May 24, 2017
On Wednesday, 24 May 2017 at 17:06:55 UTC, Guillaume Piolat wrote:
> On Wednesday, 24 May 2017 at 17:00:51 UTC, Nick Sabalausky "Abscissa" wrote:
>> Anyone have any experience (successful or unsuccessful) attempting this? Any info on the current state of it, or pitfalls, or pointers for getting started?
>
> http://code.alaiwan.org/wp/?p=103

It's seems that Dart can be compiled to WASM https://medium.com/dartlang/dart-on-llvm-b82e83f99a70

It's it's possible to do same with D?
June 05, 2017
On Wednesday, 24 May 2017 at 17:08:06 UTC, Nick Sabalausky "Abscissa" wrote:
> On Wednesday, 24 May 2017 at 17:06:55 UTC, Guillaume Piolat wrote:
>>
>> http://code.alaiwan.org/wp/?p=103
>
> Awesome, thanks!

Author here ; the blogpost is indeed interesting but it's outdated.
It's a lot more simpler now that the "LDC + emscripten-fastcomp" combination works (no need for intermediate C lowering anymore)

The whole simplified toolchain and example project live here: https://github.com/Ace17/dscripten
If you have questions about how this work, I'd be glad to answer them!
June 05, 2017
On Wednesday, 24 May 2017 at 17:47:42 UTC, Suliman wrote:
> It's it's possible to [compile to WASM] with D?
It should be.

LLVM has a working WebAssembly backend ; LDC might need some slight modifications to become aware of this new target. Everything that don't rely on the D runtime should work (except for bugs, e.g https://github.com/kripken/emscripten-fastcomp/issues/187 ).

Then, I think the following blog post could be easily adapted for the D langage:
https://medium.com/@mbebenita/lets-write-pong-in-webassembly-ac3a8e7c4591

However, please keep in mind that the target instruction set is only the tip of the iceberg ; you have to provide a target environment (like SDL bindings or a simplified D runtime), so the generated code can do anything usefull (like I/O).


June 05, 2017
On Monday, 5 June 2017 at 05:22:44 UTC, Sebastien Alaiwan wrote:
>
> The whole simplified toolchain and example project live here: https://github.com/Ace17/dscripten

Are you planning on upstreaming some of your work to LDC? Please do! :-)
Looks like it is relatively easy to integrate most of your changes.

For `llvm::Triple::asmjs` and `llvm::Triple::Emscripten`, what predefined versions would you propose ?
Have a look here: https://dlang.org/spec/version.html#predefined-versions

Cheers,
  Johan


June 05, 2017
On Monday, 5 June 2017 at 10:48:54 UTC, Johan Engelen wrote:
> On Monday, 5 June 2017 at 05:22:44 UTC, Sebastien Alaiwan wrote:
>>
>> The whole simplified toolchain and example project live here: https://github.com/Ace17/dscripten
>
> Are you planning on upstreaming some of your work to LDC? Please do! :-)

Don't let the small size of the LDC patch from dscripten deceive you ; it mangles LDC in the easiest possible way to adapt it to the quirks of emscripten-fastcomp (the LLVM fork).
(the official LLVM branch doesn't even declare the asmjs/Emscripten triples).

At this point, I think emscripten-fastcomp might be on the go ; especially if the WebAssembly backend from the official LLVM branch becomes widely used (at this point, I'll probably ditch emscripten-fastcomp from dscripten, to use WebAssembly instead).

Some stuff that could be easily upstreamed in a clean non-emscripten specific way:
- allowing to disable the build of phobos and druntime from the cmake build.
- allowing to disable the build of the debug information generator.
- allowing to disable the build of the tests.