Emscripten: An LLVM-to-JavaScript Compiler
If you want to work with emcc, emconfigure and emmake as you are used to from Ubuntu and similar distributions,
nix-shell -p emscriptenA few things to note:
export EMCC_DEBUG=2is nice for debugging- The build artifact cache in
~/.emscriptensometimes creates issues and needs to be removed from time to time
Examples
Let’s see two different examples from pkgs/top-level/emscripten-packages.nix:
pkgs.zlib.overridepkgs.buildEmscriptenPackage
A special requirement of the pkgs.buildEmscriptenPackage is the doCheck = true.
This means each Emscripten package requires that a checkPhase is implemented.
- Use
export EMCC_DEBUG=2from within a phase to get more detailed debug output what is going wrong. - The cache at
~/.emscriptenrequires to setHOME=$TMPDIRin individual phases. This makes compilation slower but also more deterministic.
Debugging
Use nix-shell -I nixpkgs=/some/dir/nixpkgs -A emscriptenPackages.libz and from there you can go through the individual steps. This makes it easy to build a good unit test or list the files of the project.
nix-shell -I nixpkgs=/some/dir/nixpkgs -A emscriptenPackages.libzcd /tmp/unpackPhase- cd libz-1.2.3
configurePhasebuildPhase- … happy hacking…