Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure Emscripten for jsartoolkit5 #11

Closed
kalwalt opened this issue Dec 31, 2019 · 15 comments
Closed

How to configure Emscripten for jsartoolkit5 #11

kalwalt opened this issue Dec 31, 2019 · 15 comments
Assignees
Labels
emscripten All about emscripten and jsartoolkit5 good first issue Good for newcomers

Comments

@kalwalt
Copy link
Owner

kalwalt commented Dec 31, 2019

Emscripten for jsartoolkit5

In this issue i want to explain how to setup Emscripten for jsartoolkit5. Because we had a certain number of issue compiling in different OS and sharing the code, compiled with different Emscripten versions.
Be aware that now Emscripten may use two different backends for emitting WASM code as described here https://emscripten.org/docs/compiling/WebAssembly.html#backends read carefully this because using a different backends lead to errors if you want to recompile it with a different backend.
If you want change the WASM backend or the Emscripten version consider that the makem.js

var EMSCRIPTEN_ROOT = process.env.EMSCRIPTEN;
use the emscripten environment variable, if you switch form upstream to fastcomp you need to change it !!

Setting the paths

Infact they are separate folder for upstream the path should looks like:

/path/to/emsdk/upstream/emscripten/

for fastcomp:

/path/to/emsdk/fastcomp/emscripten

and so the environment variable should be (for fastcomp):

export EMSCRIPTEN=/home/walter/emsdk/fastcomp/emscripten
while changing version/backend remember to clear the Emscripten cache:

emcc --clear-cache

Final summary

Use the Emscripten version recommended in the #1 (comment) if you have a different one make these steps:

  • install the Emscripten version required:

./emsdk install 1.xx.xx-fastcomp

  • activate it

./emsdk activate 1.xx.xx-fastcomp

  • activate path and other env vars

source ./emsdk_env.sh

  • change your emescripten var as explained above !!

  • clear the emscripten cache:

emcc --clear-cache

  • now you can rebuild the jsartoolkit5 libs:
// inside the jsartoolkit5 folder run as usual:
npm run build

Anyway hopefully soon we will setup a Docker environment to solve most of these issues.

Update

We strongly suggest to use Docker to build the project as written in the README.md https://github.com/kalwalt/jsartoolkit5/tree/fixing-nft#recommended-build-using-docker

@kalwalt kalwalt added good first issue Good for newcomers emscripten All about emscripten and jsartoolkit5 labels Dec 31, 2019
@kalwalt kalwalt self-assigned this Dec 31, 2019
This was referenced Dec 31, 2019
@ThorstenBux
Copy link

ThorstenBux commented Jan 1, 2020

plain clone of the fixing-nft branch

macos (10.15.2 (19C57)) zsh

thorstenbux@Zaphod jsartoolkit5 % emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.39.5
clang version 6.0.1 (/b/s/w/ir/cache/git/chromium.googlesource.com-external-git.luolix.top-emscripten--core-emscripten--fastcomp--clang 98df4be387dde3e3918fa5bbb5fc43e1a0e1daac) (/b/s/w/ir/cache/git/chromium.googlesource.com-external-git.luolix.top-emscripten--core-emscripten--fastcomp b4837f88af2d240abb550c0bbd47f3b8ffe5985a) (emscripten 1.38.31 : 1.38.31)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /Users/thorstenbux/repos/emsdk/fastcomp/fastcomp/bin
shared:INFO: (Emscripten: Running sanity checks)

thorstenbux@Zaphod jsartoolkit5 % echo $EMSCRIPTEN
/Users/thorstenbux/repos/emsdk/fastcomp/emscripten

thorstenbux@Zaphod jsartoolkit5 % emcc --clear-cache
emcc:INFO: clearing cache as requested by --clear-cache
shared:INFO: (Emscripten: Running sanity checks)

npm run build

running locally with http-server -S -C and self-signed certificates.

Errors:
examples/nft_improved_worker/nft_pinball_video.html
artoolkit.min.js:1 Uncaught abort(OOM). Build with -s ASSERTIONS=1 for more info.

examples/nft_threejs_wasm.html
Uncaught RuntimeError: abort(OOM). Build with -s ASSERTIONS=1 for more info.

@ThorstenBux
Copy link

Falling back to 1.38.44-fastcomp

install 1.38.44-fastcomp
activate 1.38.44-fastcomp
source ./emsdk_env.sh

Restarted all active Terminals
Restarted VS code

thorstenbux@Zaphod ~ % emcc --clear-cache
emcc:INFO: clearing cache as requested by --clear-cache
shared:INFO: (Emscripten: Running sanity checks)

thorstenbux@Zaphod ~ % emcc -v
cache:INFO: generating system asset: is_vanilla.txt... (this will be cached in "/Users/thorstenbux/.emscripten_cache/is_vanilla.txt" for subsequent builds)
cache:INFO:  - ok
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.38.44
clang version 6.0.1 (/b/s/w/ir/cache/git/chromium.googlesource.com-external-git.luolix.top-emscripten--core-emscripten--fastcomp--clang 98df4be387dde3e3918fa5bbb5fc43e1a0e1daac) (/b/s/w/ir/cache/git/chromium.googlesource.com-external-git.luolix.top-emscripten--core-emscripten--fastcomp 1b4148f39a69c7fc62edadd85e4122b68694dfb7) (emscripten 1.38.31 : 1.38.31)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /Users/thorstenbux/repos/emsdk/fastcomp/fastcomp/bin
shared:INFO: (Emscripten: Running sanity checks)

thorstenbux@Zaphod ~ % echo $EMSCRIPTEN
/Users/thorstenbux/repos/emsdk/fastcomp/emscripten

npm run build

Errors:
examples/nft_threejs_wasm.html
Uncaught abort(OOM). Build with -s ASSERTIONS=1 for more info.

examples/nft_improved_worker/nft_pinball_video.html
Uncaught abort(OOM). Build with -s ASSERTIONS=1 for more info.

@ThorstenBux
Copy link

Conclusion:

I think it is safe to assume it doesn't build with NFT on macOS

@kalwalt
Copy link
Owner Author

kalwalt commented Jan 1, 2020

@ThorstenBux that Is weird! And It looks very strange, i will think about it. Thank you for testing ☺️.

@ThorstenBux
Copy link

I'm setting up docker now. How do you install libJPEG on your linux box? I need it for the includes

@kalwalt
Copy link
Owner Author

kalwalt commented Jan 1, 2020

My libjpeg includes are in emscripten/libjpeg folder.

@ThorstenBux
Copy link

did you put them there? I can't find them in my emscripten installation

@ThorstenBux
Copy link

never mind. I think I've got a docker setup working. Will test in details tomorrow and push to a branch

@ThorstenBux
Copy link

@kalwalt Happy New Year :)

plz have a look if that works for you. The instructions on how to build with Docker are in the readme
https://github.com/ThorstenBux/jsartoolkit5/tree/build-with-docker

If you say it is working I'll open a PR.

@kalwalt
Copy link
Owner Author

kalwalt commented Jan 1, 2020

@ThorstenBux Happy New Year!! Sorry was very late, i will test your branch.

@kalwalt
Copy link
Owner Author

kalwalt commented Jan 1, 2020

About libjpeg includes i take them from https://github.com/kalwalt/libjpeg-for-jsartoolkit5

@kalwalt
Copy link
Owner Author

kalwalt commented Jan 1, 2020

@ThorstenBux i tested your branch https://github.com/ThorstenBux/jsartoolkit5/tree/build-with-docker and it works pefectly for me 🎉💥🙌🍾😀. If you open a PR i will review you.

@kalwalt
Copy link
Owner Author

kalwalt commented Jan 2, 2020

It is recommended to use the Docker setup see in the Readme.md https://github.com/kalwalt/jsartoolkit5/tree/fixing-nft#recommended-build-using-docker as written at the top.

@nicolocarpignoli
Copy link
Collaborator

I think we can close this, right?

@ThorstenBux
Copy link

ThorstenBux commented Jan 7, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emscripten All about emscripten and jsartoolkit5 good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants