18 mar 2018
in the nix-language-atlas series on lastlog.de/blog i want to discuss how well programming languages, for which i’m familiar with, integrate with nix. today, let’s revisit emscripten, as there also had been improvements since i wrote about it last time.
projects we have done:
1.37.16
) on emscripten
,
emscripten-fastcomp
and
emscripten-fastcomp-clang
called
emscriptenVersion
emscripten
to verify a small part
of the toolchainfor details see the PR https://github.com/NixOS/nixpkgs/pull/37291.
want to give this a shot from nixos?
git clone https://github.com/nixos/nixpkgs/
cd nixpkgs
git checkout f41a3e7d7d327ea66459d17bfbe4a751b2496cb1
nix-env -f default.nix -I nixpkgs=. -iA emscriptenPackages
installing ‘emscripten-json-c-0.13’
installing ‘emscripten-libxml2-2.9.7’
installing ‘emscripten-xmlmirror’
installing ‘emscripten-zlib-1.2.11’
...
in the above toolchain we are using libraries in .so
format, not the .a
format and in the end we link them
together using emcc. this has some advantages:
nix emscripten toolchain is now supported from:
especially the microsoft WSL release with the creators update is a very interesting audience as it makes it so easy to use nix on windows. no mingw, no cygwin! took me 10 minutes to install nix on windows!
for testing i’ve been compiling this very toolchain on my windows 10 computer. IO is slow but it works and it is easy to deploy.
i’ve sumbled on this questions in https://github.com/juj/emsdk:
How do I change the currently active SDK version?
How do I build multiple projects with different SDK versions in parallel?
How do I use Emscripten SDK with a custom version of python, java, node.js or some other tool?
this are very interesting questions and all get easy once one uses
this nixpkgs based toolchain as pointed out. i’ve been using the
emsdk
in the past but now that we have the ‘bits’ automated
in nixpkgs i’m happy to not have to work statefully anymore!
during my last two days of work on the toolchain update, i had these ideas and motivations for the future:
more documentation:
packaging some common targts, what would these be?
package the caching of emscripten in ~/.emscripten
properly, so that build artefacts can be reused over builds (time save)
and remove the HOME=$TMPDIR
requirement (ugly)
DEBUG:root:adding object /home/joachim/.emscripten_cache/asmjs/dlmalloc.bc to link
DEBUG:root:adding object /home/joachim/.emscripten_cache/asmjs/libc.bc to link
update nix-instantiate
, which we use in the ‘tour of
nix’, to a more recent version and also package it into the toolchain as
an example
hydra builds
be more transparent on the license, ideally we could generate a list of licenses in the final folder
@nixos community: i’d love to get some feedback on this, so send me an email to js@lastlog.de if you have some interesting input.
thanks to kripken
(emscripten author) for his help! i’d
love to put more effort into this, i think it’s really worth it so if
you have any funding for general development or want to have something
special realized, let me know!
another interesting project i’ve learned about lately would be https://github.com/NixOS/nixpkgs/pull/37291 from https://github.com/Ericson2314.