Open goshdarngames opened 4 years ago
Build process described here: https://github.com/SWI-Prolog/swipl-devel/blob/master/CMAKE.md
I've managed to get past it, but I have some errors. Jan: I'm really looking forward to getting SWIPL as a WASM.
Patches are welcome! I'm happy to share some knowledge from the earlier work by @rla and possibly (help) changing some stuff to core that better facilitates WASM. I think most of that work has already been done, mostly making saved states and .qlf file word-size independent and allow finding and opening files from the initial resource file which allows packaging the whole eco system in a single file.
I'm afraid I'm not going to pull the wagon though ...
https://github.com/jacobfriedman/p2p-prolog/issues/1#issuecomment-701250912
I will go over the build process again some time but the current instructions skip wasm zlib build.
Maybe it's included in emscripten- just have to find out how to inject it at build
"...port functionality of emscripten with -s USE_ZLIB=1 when running emcc – "
jacobfriedman/p2p-prolog#1 (comment)
I will go over the build process again some time but the current instructions skip wasm zlib build.
do you have time for a quick call? I've built a wasm and am trying to instantiate via JS.
Alright - I'm getting somewhere. The process will be documented in a dockerfile.
Two errors remain, I believe:
Error # 1 The loadpackage gives absolute locations for directories, rather than relative to the /build/src location. Thus, the virtual FS residing in the module can't resolve upon JS execution. This DRY issue was found by rewiring the directories with a find/replace (not ideal). I'll look into the emscripten makefile tonight and see if I can't fix it.
loadPackage({
"files": [{
"filename": "home/jacob/projects/wasm-prolog/swipl-devel/build.wasm/src/wasm-preload/boot.prc",
...
}, ...
Error # 2: Once #1 is resolved, console outputs: To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking
I'm not sure dynamic linking is needed at runtime. I haven't executed anything yet - but it seems like adding extra items to the VFS at runtime would be an ideal feature.
More relevant now is https://github.com/SWI-Prolog/npm-swipl-wasm
The emscripten setup seems a bit of a mess. After some tweaking with various scripts I got emscripten to run (from the latest git). Then I get somewhere using this, which notably changes the location of the toolchain file.
The compiler works fine, but then the toolchain file is broken and sets emar wrong and we fail using
I didn't try any further ... Requires some determination and syncing with the emscripting project. I'm afraid I have other priorities. Happy to comment and merge pull requests though.
Originally posted by @JanWielemaker in https://github.com/SWI-Prolog/swipl-devel/issues/575#issuecomment-620468515