About supporting EMScripten
cbleser
udefranette at gmail.com
Sat Aug 29 12:33:08 UTC 2020
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?
More information about the digitalmars-d-ldc
mailing list