Thread overview | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
August 04, 2020 About supporting EMScripten | ||||
---|---|---|---|---|
| ||||
Are there any plans for supporting EMScripten? I still think that supporting Web and Android are things that would give a substantial revival to D. And I'm really not talking about betterC, if I were to program without D, there should be no reason to even start with D. Vladimir Panteleev(aka CyberShadow) and Sebastien Alaiwan(aka Seb I think) are the big players on this project If you don't want to plan to support it, would someone give me some advice on how would I be able to do this myself? I'm still on very early stage of doing those porting things but I'm pretty lost, I would like to being able to help on wherever I can, if there any advices on how to start porting things, I would be grateful. Do I need to learn about LLVM, LDC, EMScripten and WebAssembly? Which things would be target for accomplishing almost full D support onto those things? I'm on Dlang discord as Hipreme, if someone would welcome me at helping me those things, please, send me a DM, I'll be sure to document the entire process. |
August 05, 2020 Re: About supporting EMScripten | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hipreme | On Tuesday, 4 August 2020 at 21:52:46 UTC, Hipreme wrote: > Are there any plans for supporting EMScripten? Nope, not really. AFAIU, Emscripten is superseded by regular WebAssembly + WASI, and druntime + Phobos ports are almost ready, see https://github.com/ldc-developers/ldc/pull/3345. |
August 05, 2020 Re: About supporting EMScripten | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | On Wednesday, 5 August 2020 at 10:51:42 UTC, kinke wrote:
> On Tuesday, 4 August 2020 at 21:52:46 UTC, Hipreme wrote:
>> Are there any plans for supporting EMScripten?
>
> Nope, not really. AFAIU, Emscripten is superseded by regular WebAssembly + WASI, and druntime + Phobos ports are almost ready, see https://github.com/ldc-developers/ldc/pull/3345.
My level of knowledge wasn't enough to understand what is really happeneing in this PR
Is there some way for me to get started using this WASM without BetterC and using SDL? Is there someway I can help in this project?
|
August 05, 2020 Re: About supporting EMScripten | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hipreme | On Wednesday, 5 August 2020 at 20:34:07 UTC, Hipreme wrote: > Is there some way for me to get started using this WASM without BetterC You will need to compile it yourself and configure ldc.conf to point to the built libraries. This is all very beta so likely you will hit some dark corners. I wish it was further along and had some good docs, but it is what it is. > and using SDL? Emscripten has a port of SDL, but this is just druntime. If you want to do audio and graphics I can only show you the port of a js13k game I did. Play it live at https://skoppe.github.io/spasm/examples/underrun/ source at https://github.com/skoppe/spasm/tree/master/examples/underrun At this point I can't help you much, but once things are more finished I hope you can try out some things. |
August 05, 2020 Re: About supporting EMScripten | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sebastiaan Koppe | On Wednesday, 5 August 2020 at 21:40:47 UTC, Sebastiaan Koppe wrote:
> On Wednesday, 5 August 2020 at 20:34:07 UTC, Hipreme wrote:
>> Is there some way for me to get started using this WASM without BetterC
>
> You will need to compile it yourself and configure ldc.conf to point to the built libraries. This is all very beta so likely you will hit some dark corners.
>
> I wish it was further along and had some good docs, but it is what it is.
>
>> and using SDL?
>
> Emscripten has a port of SDL, but this is just druntime.
>
> If you want to do audio and graphics I can only show you the port of a js13k game I did.
>
> Play it live at https://skoppe.github.io/spasm/examples/underrun/ source at https://github.com/skoppe/spasm/tree/master/examples/underrun
>
> At this point I can't help you much, but once things are more finished I hope you can try out some things.
If I have some way to test and help, I would be happy already.
Is there some built libraries already? Or I'll need to run ldc-build-runtime myself?
If I can get past this point, I'll be documenting it anyway, I like to document everything I do
So, is it possible to integrate the EMScripten SDL port with what you're doing?
|
August 06, 2020 Re: About supporting EMScripten | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hipreme | On Wednesday, 5 August 2020 at 21:46:49 UTC, Hipreme wrote: > If I have some way to test and help, I would be happy already. > Is there some built libraries already? Or I'll need to run ldc-build-runtime myself? You need to run it yourself. Very manual at the moment. Here are some very rough instructions. 1) Clone ldc and checkout my PR mentioned above. 2) Download and extract https://github.com/CraneStation/wasi-sdk/releases/download/wasi-sdk-8/wasi-sdk-8.0-linux.tar.gz somewhere. 3) export WASI_SDK_PREFIX=<path/to/wasi-sdk-8.0> 4) go into the ldc's runtime folder and run `ldc-build-runtime --ninja "--dFlags=-mtriple=wasm32-wasi" --ldcSrcDir=../ CMAKE_TOOLCHAIN_FILE="$WASI_SDK_PREFIX/share/cmake/wasi-sdk.cmake" WASI_SDK_PREFIX=$WASI_SDK_PREFIX BUILD_SHARED_LIBS=OFF` (you may need to build ldc-build-runtime first). That should get you a wasm build of druntime and phobos in `runtime/ldc-build-runtime.tmp/lib`. 5) Add this to ldc2.conf and fix the folders for your install ``` "^wasm(32|64)-": { switches = [ "-defaultlib=c,druntime-ldc,phobos2-ldc", "-link-internally", ]; post-switches = [ "-I<path/to/runtime/druntime/src>", "-I<path/to/runtime/phobos>", ], lib-dirs = ["<path/to/runtime/ldc-build-runtime.tmp/lib>","<path/to/wasi-sdk-8.0/share/wasi-sysroot/lib/wasm32-wasi/>"]; }; ``` 6) create a dub project somewhere, add `buildRequirements "allowWarnings"` to the dub.sdl app.d ``` void main() { import core.stdc.stdio; printf("exit"); } ``` 7) compile that with `dub --arch=wasm32-unknown-unknown-wasm --build-mode=allAtOnce` (from memory). 8) run with wasmtime or wasmer To get it to run in the browser you need a WASI loader, as it will depend on several WASI runtime functions. If in doubt consult the `azure-pipelines/posix.yml` and search for wasm (it will have everything until the dub project). > So, is it possible to integrate the EMScripten SDL port with what you're doing? I rather not, but I guess it is possible. |
August 29, 2020 Re: About supporting EMScripten | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sebastiaan Koppe | On Thursday, 6 August 2020 at 10:15:54 UTC, Sebastiaan Koppe wrote: I tried to install the > On Wednesday, 5 August 2020 at 21:46:49 UTC, Hipreme wrote: >> If I have some way to test and help, I would be happy already. >> Is there some built libraries already? Or I'll need to run ldc-build-runtime myself? > > You need to run it yourself. Very manual at the moment. Here are some very rough instructions. > > 1) Clone ldc and checkout my PR mentioned above. > > 2) Download and extract https://github.com/CraneStation/wasi-sdk/releases/download/wasi-sdk-8/wasi-sdk-8.0-linux.tar.gz somewhere. > > 3) export WASI_SDK_PREFIX=<path/to/wasi-sdk-8.0> > > 4) go into the ldc's runtime folder and run `ldc-build-runtime --ninja "--dFlags=-mtriple=wasm32-wasi" --ldcSrcDir=../ CMAKE_TOOLCHAIN_FILE="$WASI_SDK_PREFIX/share/cmake/wasi-sdk.cmake" WASI_SDK_PREFIX=$WASI_SDK_PREFIX BUILD_SHARED_LIBS=OFF` (you may need to build ldc-build-runtime first). > > That should get you a wasm build of druntime and phobos in `runtime/ldc-build-runtime.tmp/lib`. > > 5) Add this to ldc2.conf and fix the folders for your install > > ``` > "^wasm(32|64)-": > { > switches = [ > "-defaultlib=c,druntime-ldc,phobos2-ldc", > "-link-internally", > ]; > post-switches = [ > "-I<path/to/runtime/druntime/src>", > "-I<path/to/runtime/phobos>", > ], > lib-dirs = ["<path/to/runtime/ldc-build-runtime.tmp/lib>","<path/to/wasi-sdk-8.0/share/wasi-sysroot/lib/wasm32-wasi/>"]; > }; > ``` > 6) create a dub project somewhere, add `buildRequirements "allowWarnings"` to the dub.sdl > > app.d > ``` > void main() { > import core.stdc.stdio; > printf("exit"); > } > ``` > > 7) compile that with `dub --arch=wasm32-unknown-unknown-wasm --build-mode=allAtOnce` (from memory). > > 8) run with wasmtime or wasmer > > To get it to run in the browser you need a WASI loader, as it will depend on several WASI runtime functions. > > If in doubt consult the `azure-pipelines/posix.yml` and search for wasm (it will have everything until the dub project). > >> So, is it possible to integrate the EMScripten SDL port with what you're doing? > > I rather not, but I guess it is possible. Thank you for the instruction. I tried to compile wasm-druntime. But I run into some problems inside the I following error. CMake Error at CMakeLists.txt:227 (list): list sub-command REMOVE_ITEM requires two or more arguments. I have made a repo on https://github.com/tagion/wasm_druntime.git Which should run the build like this: ``` make subdate make all ``` I am not sure of I have the correct branch? |
August 31, 2020 Re: About supporting EMScripten | ||||
---|---|---|---|---|
| ||||
Posted in reply to cbleser | On Saturday, 29 August 2020 at 12:33:08 UTC, cbleser wrote: > Thank you for the instruction. > I tried to compile wasm-druntime. But I run into some problems inside the I following error. > > CMake Error at CMakeLists.txt:227 (list): > list sub-command REMOVE_ITEM requires two or more arguments. > > I have made a repo on > https://github.com/tagion/wasm_druntime.git > Which should run the build like this: > ``` > make subdate > make all > ``` > I am not sure of I have the correct branch? It seems you don't have the right version of ldc/druntime/phobos. Please checkout https://github.com/skoppe/ldc/commit/828926064c52eba905d9bbbf9d4d57f64a2cd267 |
September 01, 2020 Re: About supporting EMScripten | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sebastiaan Koppe | On Monday, 31 August 2020 at 08:31:11 UTC, Sebastiaan Koppe wrote: > On Saturday, 29 August 2020 at 12:33:08 UTC, cbleser wrote: >> Thank you for the instruction. >> I tried to compile wasm-druntime. But I run into some problems inside the I following error. >> >> CMake Error at CMakeLists.txt:227 (list): >> list sub-command REMOVE_ITEM requires two or more arguments. >> >> I have made a repo on >> https://github.com/tagion/wasm_druntime.git >> Which should run the build like this: >> ``` >> make subdate >> make all >> ``` >> I am not sure of I have the correct branch? > > It seems you don't have the right version of ldc/druntime/phobos. Please checkout https://github.com/skoppe/ldc/commit/828926064c52eba905d9bbbf9d4d57f64a2cd267 Hi Sebastiaan. Thank you for you input. But still run into another problem. I corrected the branch now it compiles but it does not link. The test can be found here. https://github.com/tagion/wasm_druntime.git I have tried ldc-build-runtime with both ninja and make nut the result is the same. Used ldc-build-runtime cd /tmp/wasm_druntime/ldc/runtime; ldc-build-runtime --dFlags=-mtriple=wasm32-wasi --buildDir=/tmp/wasm_druntime/ldc-build-runtime.tmp --ldcSrcDir=../ CMAKE_TOOLCHAIN_FILE=/tmp/wasm_druntime/wasi-sdk-8.0/share/cmake/wasi-sdk.cmake WASI_SDK_PREFIX=/tmp/wasm_druntime/wasi-sdk-8.0 BUILD_SHARED_LIBS=OFF --- cut --- Error: unrecognized file extension obj make[2]: *** [CMakeFiles/druntime-ldc.dir/build.make:1292: lib/libdruntime-ldc.a] Error 1 make[2]: Leaving directory '/tmp/wasm_druntime/ldc-build-runtime.tmp' make[1]: *** [CMakeFiles/Makefile2:265: CMakeFiles/druntime-ldc.dir/all] Error 2 make[1]: Leaving directory '/tmp/wasm_druntime/ldc-build-runtime.tmp' make: *** [Makefile:130: all] Error 2 --- cut -- The compiler I use is. ldc2 --version LDC - the LLVM D compiler (1.20.1): based on DMD v2.090.1 and LLVM 10.0.0 built with LDC - the LLVM D compiler (1.20.1) Default target: x86_64-pc-linux-gnu Host CPU: skylake http://dlang.org - http://wiki.dlang.org/LDC Registered Targets: aarch64 - AArch64 (little endian) aarch64_32 - AArch64 (little endian ILP32) aarch64_be - AArch64 (big endian) amdgcn - AMD GCN GPUs arm - ARM arm64 - ARM64 (little endian) arm64_32 - ARM64 (little endian ILP32) armeb - ARM (big endian) avr - Atmel AVR Microcontroller bpf - BPF (host endian) bpfeb - BPF (big endian) bpfel - BPF (little endian) hexagon - Hexagon lanai - Lanai mips - MIPS (32-bit big endian) mips64 - MIPS (64-bit big endian) mips64el - MIPS (64-bit little endian) mipsel - MIPS (32-bit little endian) msp430 - MSP430 [experimental] nvptx - NVIDIA PTX 32-bit nvptx64 - NVIDIA PTX 64-bit ppc32 - PowerPC 32 ppc64 - PowerPC 64 ppc64le - PowerPC 64 LE r600 - AMD GPUs HD2XXX-HD6XXX riscv32 - 32-bit RISC-V riscv64 - 64-bit RISC-V sparc - Sparc sparcel - Sparc LE sparcv9 - Sparc V9 systemz - SystemZ thumb - Thumb thumbeb - Thumb (big endian) wasm32 - WebAssembly 32-bit wasm64 - WebAssembly 64-bit x86 - 32-bit X86: Pentium-Pro and above x86-64 - 64-bit X86: EM64T and AMD64 xcore - XCore I checked the .obj file and they are the correct format file CMakeFiles/druntime-ldc.dir/druntime/src/core/stdc/errno.c.obj CMakeFiles/druntime-ldc.dir/druntime/src/core/stdc/errno.c.obj: WebAssembly (wasm) binary module version 0x1 (MVP) And wasm2was list looks correct. Maybe I have the wrong compiler or can I use another linker? |
September 01, 2020 Re: About supporting EMScripten | ||||
---|---|---|---|---|
| ||||
Posted in reply to cbleser | On Tuesday, 1 September 2020 at 13:18:15 UTC, cbleser wrote: > On Monday, 31 August 2020 at 08:31:11 UTC, Sebastiaan Koppe wrote: >> It seems you don't have the right version of ldc/druntime/phobos. Please checkout https://github.com/skoppe/ldc/commit/828926064c52eba905d9bbbf9d4d57f64a2cd267 > > Hi Sebastiaan. > Thank you for you input. But still run into another problem. > > > I corrected the branch now it compiles but it does not link. > > [...] > > --- cut --- > Error: unrecognized file extension obj > make[2]: *** [CMakeFiles/druntime-ldc.dir/build.make:1292: lib/libdruntime-ldc.a] Error 1 > make[2]: Leaving directory '/tmp/wasm_druntime/ldc-build-runtime.tmp' > make[1]: *** [CMakeFiles/Makefile2:265: CMakeFiles/druntime-ldc.dir/all] Error 2 > make[1]: Leaving directory '/tmp/wasm_druntime/ldc-build-runtime.tmp' > make: *** [Makefile:130: all] Error 2 > --- cut -- Ah yes, I missed that step. You need to patch the sdk. See the CI https://github.com/tagion/ldc/blob/828926064c52eba905d9bbbf9d4d57f64a2cd267/.azure-pipelines/posix.yml#L159 Essentially replace `Wasm` with `Linux` in $WASI_SDK_PREFIX/share/cmake/wasi-sdk.cmake |
Copyright © 1999-2021 by the D Language Foundation