Aluriak / webclingo-example

Example of clingo usage on website as a client-side JS program
https://aluriak.github.io/webclingo-example/
12 stars 3 forks source link

Build for WebAssembly #3

Closed domoritz closed 6 years ago

domoritz commented 6 years ago

I'd like to use clingo in modern browsers with WebAssembly. The instructions say that I only need to pass WASM=1 to emcc. Can you tell me where I need to add this option?

Aluriak commented 6 years ago

According to this, you should put -s WASM=1 to the CMAKE_CXX_FLAGS option, giving you -DCMAKE_CXX_FLAGS="-std=c++11 -Wall -s DISABLE_EXCEPTION_CATCHING=0 -s WASM=1" in the current source.

According to this less reliable source, you could also add -DEMCC_LINKER_FLAGS="-s WASM=1".

However, because of the problem found in #2, i can't really test this. However, i got some wasm related errors during import of clingo when compiled with the first method.

domoritz commented 6 years ago

Do you think you could build it and add the clingo.wasm and clingo.js files in the repo?

Aluriak commented 6 years ago

Well, i should have do that, but i did it bad. Now you have both my working clingo.js and clingo.js.mem in debug/fedora24/.

I ran the WASM server as you propose in #6, and the compilation was completed without error. I however got the ccall is not a function error (see #2). WASM file is uploaded now.

domoritz commented 6 years ago

I'm surprised that the normal compilation works for you on fedora but compiling wasm causes the same ccall issue (#2) that I see without WASM. It would be awesome to get this to work.