Emscripten: Would you consider Docker as an official deployment method?

Created on 31 Oct 2016  ·  22Comments  ·  Source: emscripten-core/emscripten

Now that Docker works natively on Mac and Windows, would you consider an official Docker image?

There's a few on Docker Hub, but they're invariably out of date: https://hub.docker.com/search/?isAutomated=0&isOfficial=0&page=1&pullCount=1&q=emscripten&starCount=0

Given how huge the checkout is of clang, and subsequent long build time just to get to the point of running a compiled Emscripten SDK, I think Docker could work really well.

The way images are composed and committed to layers in Docker, I think it could work really well, with minimal downloads needed for new layers with just the compiled Emscripten tools.

Then you could just run something like:

docker run --rm -v $(pwd):/src -t docker/emscripten emcc

That could even be wrapped up in the SDK so that emcc just aliased to that anyway.

wontfix

Most helpful comment

Just for inspiration for the official image, we are using emscripten in docker too, although only released versions using following Dockerfile https://github.com/apiaryio/emscripten-docker/blob/master/1.37/Dockerfile it may contain something useful. I'd be really grateful if there was a official image so if I can help let me know.

All 22 comments

cc @juj

I should add, I thought this would be particularly useful for incoming - if you have a CI build for that branch somewhere, it wouldn't be a huge step to wrap that up into a Docker image everyone could just pickup and be able to run right away.

Something like:

FROM ubuntu:xenial-20161010

RUN apt-get update && apt-get install -y \
    locales \
    build-essential \
    cmake \
    curl \
    python \
    nodejs \
    git \
    default-jdk

RUN locale-gen en_US.UTF-8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'

RUN curl https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz -o emsdk-portable.tar.gz && \
    gunzip emsdk-portable.tar.gz && \
    tar -xf emsdk-portable.tar

RUN cd emsdk_portable  && \
    ./emsdk update && \
    ./emsdk install clang-incoming-64bit emscripten-incoming-64bit sdk-incoming-64bit && \
    ./emsdk activate clang-incoming-64bit emscripten-incoming-64bit sdk-incoming-64bit

It's highly dependent on what your CI/build is like, otherwise I'd be happy to PR.

Something like this might be good for binaryen CI too, if we could get incoming builds.

I think @juj has a way or was working on a way to get those from the emscripten waterfall.

Another thought - the top 'unofficial' Docker Emscripten image is made by @asRIA / @trzeci:

https://hub.docker.com/r/trzeci/emscripten/
https://github.com/asRIA/emscripten-docker

Maybe he/she would be willing to contribute that as a starting point.

Hi @marcosscriven, thank you for summoning me. I realized that the hub was not updated somehow by my script.
For me it was the main reason to have a separated and quick solution to test latest master or incomming branch.

I would love to contribute. I put some effort to make images as light as it was possible.

Cheers,
Piotr

@marcosscriven I've found a reason why it silently failed. Requirement for CMake was set to 3.4+.
From your perspective, is it required to have an image based on ubuntu? Currently It bases on debian:jessie due very small size.

@asRIA - not at all required to based on Ubuntu, it just happened to be the easiest way to get all the deps, including CMake 3.4, without spending too much time.

Certainly if the Emscripten project does end up producing an official image more time could be spent minimising it. It doesn't really even need to be built in the context of the Docker build (I use OS X so it was convenient for me) - if CI is there, compiling against a given Linux version/kernel, the Docker file could simply copy that artifact into a minimal image.

Subsequent downloads of the image would then just be that last layer containing the latest Emscripten binaries (incoming or master), so the base image size wouldn't be such a problem.

I just had a poke around the build server @kripken linked to, and found it already publishes a nightly to https://s3.amazonaws.com/mozilla-games/

So just tried this with docker build . in a file called Dockerfile:

FROM ubuntu:xenial-20161010

RUN apt-get update && apt-get install -y \
    locales \
    curl \
    python \
    nodejs \
    default-jdk

RUN locale-gen en_US.UTF-8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'

RUN curl -s https://s3.amazonaws.com/mozilla-games/emscripten/packages/emscripten/nightly/linux/emscripten-latest.tar.gz -o emscripten-latest.tar.gz && \
    curl -s https://s3.amazonaws.com/mozilla-games/emscripten/packages/llvm/nightly/linux_64bit/emscripten-llvm-latest.tar.gz -o emscripten-llvm-latest.tar.gz

RUN mkdir emscripten && mkdir llvm && \
    tar -xzf emscripten-latest.tar.gz -C emscripten --strip-components=1 && \
    tar -xzf emscripten-llvm-latest.tar.gz -C llvm --strip-components=1 && \
    ln -s /emscripten/emcc /usr/local/bin && \
    emcc && \
    sed -i.bak "s/LLVM_ROOT =.*/LLVM_ROOT = '\/llvm\/'/" /root/.emscripten && \
    touch /root/.emscripten && \
    echo 'int main() {}' > tmp.c && \
    emcc tmp.c && rm tmp.c

WORKDIR /src/    

Once that built, I could just do this in a local directory with hello.c in it:

➜  emscripten git:(master) ✗ time docker run -v $(pwd):/src -it d928a943f0fd emcc hello.c
0.01s user 0.01s system 0% cpu 1.884 total
➜  emscripten git:(master) ✗ node a.out.js
hello, world!

d928a943f0fd is just the un-tagged hash of the built image.

In short, I think the Dockerfile (per above) is the easy bit - the hard bit is:

This looks promising, there is something to polish up, like optimize a size of the docker image, and warm-up EMSDK. That is, pre-compile some system libraries.

Agree about cleaning up the size. Re 'warming up' I did that by running 'emcc' on an minimal file. Thus the .cache files are there in the image.

Regarding to warming up: compiling one file isn't enough. There are plenty of different combinations that are missing in simple hello_world test. (This is also on TODO list for my docker file).

Please take a look at: https://github.com/kripken/emscripten/blob/master/tools/system_libs.py
You will see libs like: libcxx, libcxxabi, pthreads, dlmalloc_threadsafe, dlmalloc_threadsafe_tracing etc.
Ideally every variant should be created.

To bootstrap emsdk locally to a latest precompiled nightly build, one can run:

git clone https://github.com/juj/emsdk.git
cd emsdk
./emsdk update-tags
./emsdk install sdk-nightly-latest-64bit
./emsdk activate --embedded sdk-nightly-latest-64bit
source ./emsdk_env.sh
emcc --clear-cache --clear-ports
python $EMSCRIPTEN/embuilder.py build ALL

After these steps, the emsdk/ directory contains a selfstanding Emscripten installation, which also has the libcxx/libcxxabi etc compiled to it. The build ALL step might build more than is interesting (it builds all ports as well, such as SDL2, Freetype2, etc.), so it's also possible to just specify build libc libcxx ... individually for the interesting ones.

I don't know about Docker, but perhaps the above steps might make sense for a Docker image. One feature that is coming in the future is the ability to do sdk-tag-latest-64bit in addition to sdk-nightly-latest-64bit which will get the latest tagged release as opposed to the nightly builds. After this feature is complete, I recommend that a Docker image would pull those tagged precompiled packages instead of nightly packages.

Sweet, just tested embuilder to define what is an influence on an image size.

With build ALL create an image takes ~4 minutes longer, but size of an image has increased from 228MB to 337MB what is significant. Most likely it can be tweaked better, as you said it has compiled every port what might be not required.

Thank you for the info about precompiled versions for Linux, this was something that was missing,

Small investigation shows where I have extra ~100MB:

root@c1666038b23a:~/.emscripten_cache/asmjs# 
4.0K    binaryen_tag_version_13.txt
3.5M    bullet.bc
48K     dlmalloc.bc
48K     dlmalloc_threadsafe.bc
1.8M    freetype.bc
28K     gl.bc
724K    libc-mt.bc
724K    libc.bc
1.7M    libcxx.a
1.6M    libcxx_noexcept.a
468K    libcxxabi.bc
464K    libpng.bc
40K     ogg.bc
84M     ports-builds/
    42M     bullet/
    16M     freetype/
    12K     include/
    5.7M    libpng/
    1.3M    ogg/
    7.6M    sdl2/
    180K    sdl2-image/
    64K     sdl2-net/
    116K    sdl2-ttf/
    7.4M    vorbis/
52K     pthreads.bc
60K     sdl2-image.bc
24K     sdl2-net.bc
56K     sdl2-ttf.bc
1.8M    sdl2.bc
844K    vorbis.bc
28K     wasm-libc.bc
236K    zlib.bc

It looks that ports-builds contains projects. It might be safe to remove it.

root@c1666038b23a:~/.emscripten_ports# du -sh *
49M     binaryen
3.1M    binaryen.zip
34M     bullet
7.2M    bullet.zip
12M     freetype
2.2M    freetype.zip
4.7M    libpng
1.2M    libpng.zip
1.2M    ogg
320K    ogg.zip
72M     sdl2
31M     sdl2-image
8.6M    sdl2-image.zip
1.7M    sdl2-net
368K    sdl2-net.zip
25M     sdl2-ttf
6.0M    sdl2-ttf.zip
6.9M    sdl2.zip
5.6M    vorbis
1.4M    vorbis.zip
3.2M    zlib
712K    zlib.zip

Second question: Is it safe to get rid off :~/.emscripten_ports. It contains zips and unpacked projects.

Do you see any implication @juj ?

Yes, it's ok to delete ~/.emscripten_ports when not using any of the ports. The linker flags such as -s USE_SDL2=1 are the ones that autolink to these ports.

@juj I tried your commands but i get these errors, is there a working Docker image?

❯ python $EMSCRIPTEN/embuilder.py build ALL
INFO:root:building and verifying libc
INFO:root:generating system library: libc.bc... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/libc.bc" for subsequent builds)
INFO:root: - ok
INFO:root:generating system library: dlmalloc.bc... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/dlmalloc.bc" for subsequent builds)
INFO:root: - ok
INFO:root:...success
INFO:root:building and verifying libc-mt
INFO:root:generating system library: libc-mt.bc... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/libc-mt.bc" for subsequent builds)
INFO:root: - ok
INFO:root:generating system library: pthreads.bc... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/pthreads.bc" for subsequent builds)
INFO:root: - ok
INFO:root:generating system library: dlmalloc_threadsafe.bc... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/dlmalloc_threadsafe.bc" for subsequent builds)
INFO:root: - ok
INFO:root:...success
INFO:root:building and verifying dlmalloc
INFO:root:...success
INFO:root:building and verifying dlmalloc_threadsafe
INFO:root:...success
INFO:root:building and verifying pthreads
INFO:root:...success
INFO:root:building and verifying libcxx
INFO:root:generating system library: libcxx.a... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/libcxx.a" for subsequent builds)
INFO:root: - ok
INFO:root:generating system library: libcxxabi.bc... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/libcxxabi.bc" for subsequent builds)
INFO:root: - ok
INFO:root:...success
INFO:root:building and verifying libcxx_noexcept
INFO:root:generating system library: libcxx_noexcept.a... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/libcxx_noexcept.a" for subsequent builds)
INFO:root: - ok
INFO:root:...success
INFO:root:building and verifying libcxxabi
INFO:root:...success
INFO:root:building and verifying gl
INFO:root:generating system library: gl.bc... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/gl.bc" for subsequent builds)
INFO:root: - ok
INFO:root:...success
INFO:root:building and verifying binaryen
WARNING:root:retrieving port: binaryen from https://github.com/WebAssembly/binaryen/archive/version_21.zip
WARNING:root:unpacking port: binaryen
INFO:root:generating port: binaryen_tag_version_21.txt... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/binaryen_tag_version_21.txt" for subsequent builds)
INFO:root:building port: binaryen
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Building with -std=c++11
-- Building with -msse2
-- Building with -mfpmath=sse
-- Building with -Wall
-- Building with -Werror
-- Building with -Wextra
-- Building with -Wno-unused-parameter
-- Building with -fno-omit-frame-pointer
-- Building with -fPIC
-- Building with -O2
-- Building with -UNDEBUG
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mibook/.emscripten_ports/binaryen/binaryen-version_21
Scanning dependencies of target wasm
Scanning dependencies of target passes
Scanning dependencies of target emscripten-optimizer
Scanning dependencies of target asmjs
[  1%] Building CXX object src/wasm/CMakeFiles/wasm.dir/wasm.cpp.o
[  2%] Building CXX object src/asmjs/CMakeFiles/asmjs.dir/asm_v_wasm.cpp.o
[  4%] Building CXX object src/passes/CMakeFiles/passes.dir/pass.cpp.o
[  5%] Building CXX object src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/optimizer-shared.cpp.o
[  7%] Building CXX object src/asmjs/CMakeFiles/asmjs.dir/shared-constants.cpp.o
[  8%] Linking CXX static library ../../lib/libasmjs.a
[  8%] Built target asmjs
Scanning dependencies of target support
[ 10%] Building CXX object src/support/CMakeFiles/support.dir/archive.cpp.o
[ 11%] Building CXX object src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/parser.cpp.o
[ 13%] Building CXX object src/wasm/CMakeFiles/wasm.dir/wasm-binary.cpp.o
[ 14%] Building CXX object src/passes/CMakeFiles/passes.dir/CoalesceLocals.cpp.o
[ 16%] Building CXX object src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/simple_ast.cpp.o
[ 17%] Building CXX object src/support/CMakeFiles/support.dir/bits.cpp.o
[ 19%] Building CXX object src/support/CMakeFiles/support.dir/colors.cpp.o
[ 20%] Building CXX object src/support/CMakeFiles/support.dir/command-line.cpp.o
[ 22%] Linking CXX static library ../../lib/libemscripten-optimizer.a
[ 22%] Built target emscripten-optimizer
[ 23%] Building CXX object src/support/CMakeFiles/support.dir/file.cpp.o
[ 25%] Building CXX object src/support/CMakeFiles/support.dir/safe_integer.cpp.o
[ 26%] Building CXX object src/support/CMakeFiles/support.dir/threads.cpp.o
[ 28%] Building CXX object src/wasm/CMakeFiles/wasm.dir/wasm-s-parser.cpp.o
[ 29%] Linking CXX static library ../../lib/libsupport.a
[ 29%] Built target support
[ 31%] Building CXX object src/passes/CMakeFiles/passes.dir/CodePushing.cpp.o
[ 32%] Building CXX object src/passes/CMakeFiles/passes.dir/DeadCodeElimination.cpp.o
[ 34%] Building CXX object src/passes/CMakeFiles/passes.dir/DuplicateFunctionElimination.cpp.o
[ 35%] Building CXX object src/passes/CMakeFiles/passes.dir/ExtractFunction.cpp.o
[ 37%] Building CXX object src/passes/CMakeFiles/passes.dir/Inlining.cpp.o
[ 38%] Linking CXX static library ../../lib/libwasm.a
[ 38%] Built target wasm
[ 40%] Building CXX object src/passes/CMakeFiles/passes.dir/LegalizeJSInterface.cpp.o
[ 41%] Building CXX object src/passes/CMakeFiles/passes.dir/MemoryPacking.cpp.o
[ 43%] Building CXX object src/passes/CMakeFiles/passes.dir/MergeBlocks.cpp.o
[ 44%] Building CXX object src/passes/CMakeFiles/passes.dir/Metrics.cpp.o
[ 46%] Building CXX object src/passes/CMakeFiles/passes.dir/NameManager.cpp.o
[ 47%] Building CXX object src/passes/CMakeFiles/passes.dir/NameList.cpp.o
[ 49%] Building CXX object src/passes/CMakeFiles/passes.dir/OptimizeInstructions.cpp.o
[ 50%] Building CXX object src/passes/CMakeFiles/passes.dir/PostEmscripten.cpp.o
[ 52%] Building CXX object src/passes/CMakeFiles/passes.dir/Precompute.cpp.o
[ 53%] Building CXX object src/passes/CMakeFiles/passes.dir/Print.cpp.o
[ 55%] Building CXX object src/passes/CMakeFiles/passes.dir/PrintCallGraph.cpp.o
[ 56%] Building CXX object src/passes/CMakeFiles/passes.dir/RelooperJumpThreading.cpp.o
[ 58%] Building CXX object src/passes/CMakeFiles/passes.dir/RemoveImports.cpp.o
[ 59%] Building CXX object src/passes/CMakeFiles/passes.dir/RemoveMemory.cpp.o
[ 61%] Building CXX object src/passes/CMakeFiles/passes.dir/RemoveUnusedBrs.cpp.o
[ 62%] Building CXX object src/passes/CMakeFiles/passes.dir/RemoveUnusedNames.cpp.o
[ 64%] Building CXX object src/passes/CMakeFiles/passes.dir/RemoveUnusedFunctions.cpp.o
[ 65%] Building CXX object src/passes/CMakeFiles/passes.dir/ReorderLocals.cpp.o
[ 67%] Building CXX object src/passes/CMakeFiles/passes.dir/ReorderFunctions.cpp.o
[ 68%] Building CXX object src/passes/CMakeFiles/passes.dir/SimplifyLocals.cpp.o
[ 70%] Building CXX object src/passes/CMakeFiles/passes.dir/Vacuum.cpp.o
[ 71%] Linking CXX static library ../../lib/libpasses.a
[ 71%] Built target passes
Scanning dependencies of target wasm-opt
Scanning dependencies of target binaryen
Scanning dependencies of target wasm-as
Scanning dependencies of target wasm-shell
[ 73%] Building CXX object CMakeFiles/wasm-opt.dir/src/tools/wasm-opt.cpp.o
[ 74%] Building CXX object CMakeFiles/wasm-as.dir/src/tools/wasm-as.cpp.o
[ 76%] Building CXX object CMakeFiles/binaryen.dir/src/binaryen-c.cpp.o
[ 77%] Building CXX object CMakeFiles/wasm-shell.dir/src/tools/wasm-shell.cpp.o
[ 79%] Linking CXX executable bin/wasm-opt
[ 79%] Built target wasm-opt
Scanning dependencies of target s2wasm
[ 80%] Building CXX object CMakeFiles/s2wasm.dir/src/tools/s2wasm.cpp.o
[ 82%] Linking CXX executable bin/wasm-as
[ 82%] Built target wasm-as
Scanning dependencies of target wasm-dis
[ 83%] Building CXX object CMakeFiles/wasm-dis.dir/src/tools/wasm-dis.cpp.o
[ 85%] Building CXX object CMakeFiles/wasm-shell.dir/src/wasm-interpreter.cpp.o
[ 86%] Linking CXX executable bin/wasm-dis
[ 88%] Building CXX object CMakeFiles/binaryen.dir/src/cfg/Relooper.cpp.o
[ 88%] Built target wasm-dis
Scanning dependencies of target asm2wasm
[ 89%] Building CXX object CMakeFiles/asm2wasm.dir/src/tools/asm2wasm.cpp.o
[ 91%] Linking CXX executable bin/wasm-shell
[ 91%] Built target wasm-shell
[ 92%] Building CXX object CMakeFiles/asm2wasm.dir/src/wasm-emscripten.cpp.o
[ 94%] Building CXX object CMakeFiles/s2wasm.dir/src/wasm-emscripten.cpp.o
[ 95%] Building CXX object CMakeFiles/s2wasm.dir/src/wasm-linker.cpp.o
[ 97%] Linking CXX shared library lib/libbinaryen.so
[ 97%] Built target binaryen
[ 98%] Linking CXX executable bin/asm2wasm
[100%] Linking CXX executable bin/s2wasm
[100%] Built target asm2wasm
[100%] Built target s2wasm
INFO:root: - ok
INFO:root:generating system library: wasm-libc.bc... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/wasm-libc.bc" for subsequent builds)
INFO:root: - ok
INFO:root:...success
INFO:root:building and verifying bullet
WARNING:root:retrieving port: bullet from https://github.com/emscripten-ports/bullet/archive/version_1.zip
WARNING:root:unpacking port: bullet
INFO:root:generating system library: bullet.bc... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/bullet.bc" for subsequent builds)
INFO:root:building port: bullet
INFO:root: - ok
INFO:root:...success
INFO:root:building and verifying freetype
WARNING:root:retrieving port: freetype from https://github.com/emscripten-ports/FreeType/archive/version_1.zip
WARNING:root:unpacking port: freetype
INFO:root:generating port: freetype.bc... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/freetype.bc" for subsequent builds)
INFO:root: - ok
INFO:root:...success
INFO:root:building and verifying libpng
WARNING:root:retrieving port: zlib from https://github.com/emscripten-ports/zlib/archive/version_1.zip
WARNING:root:unpacking port: zlib
INFO:root:generating port: zlib.bc... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/zlib.bc" for subsequent builds)
INFO:root: - ok
WARNING:root:retrieving port: libpng from https://github.com/emscripten-ports/libpng/archive/version_1.zip
WARNING:root:unpacking port: libpng
INFO:root:generating port: libpng.bc... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/libpng.bc" for subsequent builds)
INFO:root:building port: libpng
INFO:root: - ok
INFO:root:...success
INFO:root:building and verifying ogg
WARNING:root:retrieving port: ogg from https://github.com/emscripten-ports/ogg/archive/version_1.zip
WARNING:root:unpacking port: ogg
INFO:root:generating system library: ogg.bc... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/ogg.bc" for subsequent builds)
INFO:root:building port: ogg
INFO:root: - ok
INFO:root:...success
INFO:root:building and verifying sdl2
WARNING:root:retrieving port: sdl2 from https://github.com/emscripten-ports/SDL2/archive/version_12.zip
WARNING:root:unpacking port: sdl2
INFO:root:generating port: sdl2.bc... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/sdl2.bc" for subsequent builds)
INFO:root: - ok
INFO:root:...success
INFO:root:building and verifying sdl2-image
WARNING:root:retrieving port: sdl2-image from https://github.com/emscripten-ports/SDL2_image/archive/version_3.zip
WARNING:root:unpacking port: sdl2-image
INFO:root:generating port: sdl2-image.bc... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/sdl2-image.bc" for subsequent builds)
INFO:root: - ok
INFO:root:...success
INFO:root:building and verifying sdl2-ttf
WARNING:root:retrieving port: sdl2-ttf from https://github.com/emscripten-ports/SDL2_ttf/archive/version_1.zip
WARNING:root:unpacking port: sdl2-ttf
INFO:root:generating port: sdl2-ttf.bc... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/sdl2-ttf.bc" for subsequent builds)
INFO:root: - ok
INFO:root:...success
INFO:root:building and verifying sdl2-net
WARNING:root:retrieving port: sdl2-net from https://github.com/emscripten-ports/SDL2_net/archive/version_2.zip
WARNING:root:unpacking port: sdl2-net
INFO:root:generating port: sdl2-net.bc... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/sdl2-net.bc" for subsequent builds)
INFO:root:building port: sdl2-net
INFO:root: - ok
INFO:root:...success
INFO:root:building and verifying vorbis
WARNING:root:retrieving port: vorbis from https://github.com/emscripten-ports/vorbis/archive/version_1.zip
WARNING:root:unpacking port: vorbis
INFO:root:generating system library: vorbis.bc... (this will be cached in "/home/mibook/Code/emsdk/.emscripten_cache/asmjs/vorbis.bc" for subsequent builds)
INFO:root:building port: vorbis
INFO:root: - ok
INFO:root:...success
INFO:root:building and verifying zlib
INFO:root:...success
INFO:root:building and verifying native_optimizer
module.js:338
    throw err;
    ^

Error: Cannot find module '../tools/eliminator/node_modules/uglify-js'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:286:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/home/mibook/Code/emsdk/emscripten/nightly-1.36.14-2016_12_19_18_10/tools/js-optimizer.js:132:14)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:475:10)
Traceback (most recent call last):
  File "/home/mibook/Code/emsdk/emscripten/nightly-1.36.14-2016_12_19_18_10/emcc", line 13, in <module>
    emcc.run()
  File "/home/mibook/Code/emsdk/emscripten/nightly-1.36.14-2016_12_19_18_10/emcc.py", line 1934, in run
    JSOptimizer.flush()
  File "/home/mibook/Code/emsdk/emscripten/nightly-1.36.14-2016_12_19_18_10/emcc.py", line 1830, in flush
    run_passes(chunks[0], title, just_split=False, just_concat=False)
  File "/home/mibook/Code/emsdk/emscripten/nightly-1.36.14-2016_12_19_18_10/emcc.py", line 1803, in run_passes
    final = shared.Building.js_optimizer(final, passes, debug_level >= 4, JSOptimizer.extra_info, just_split=just_split, just_concat=just_concat)
  File "/home/mibook/Code/emsdk/emscripten/nightly-1.36.14-2016_12_19_18_10/tools/shared.py", line 1828, in js_optimizer
    ret = js_optimizer.run(filename, passes, NODE_JS, debug, extra_info, just_split, just_concat)
  File "/home/mibook/Code/emsdk/emscripten/nightly-1.36.14-2016_12_19_18_10/tools/js_optimizer.py", line 559, in run
    return temp_files.run_and_clean(lambda: run_on_js(filename, passes, js_engine, source_map, extra_info, just_split, just_concat))
  File "/home/mibook/Code/emsdk/emscripten/nightly-1.36.14-2016_12_19_18_10/tools/tempfiles.py", line 78, in run_and_clean
    return func()
  File "/home/mibook/Code/emsdk/emscripten/nightly-1.36.14-2016_12_19_18_10/tools/js_optimizer.py", line 559, in <lambda>
    return temp_files.run_and_clean(lambda: run_on_js(filename, passes, js_engine, source_map, extra_info, just_split, just_concat))
  File "/home/mibook/Code/emsdk/emscripten/nightly-1.36.14-2016_12_19_18_10/tools/js_optimizer.py", line 378, in run_on_js
    asm_shell_pre, asm_shell_post = minifier.minify_shell(asm_shell, 'minifyWhitespace' in passes, source_map).split('EMSCRIPTEN_FUNCS();');
  File "/home/mibook/Code/emsdk/emscripten/nightly-1.36.14-2016_12_19_18_10/tools/js_optimizer.py", line 247, in minify_shell
    assert len(output) > 0 and not output.startswith('Assertion failed'), 'Error in js optimizer: ' + output
AssertionError: Error in js optimizer: 
Traceback (most recent call last):
  File "/home/mibook/Code/emsdk/emscripten/nightly-1.36.14-2016_12_19_18_10/embuilder.py", line 147, in <module>
    ''', ['optimizer.2.exe'], ['-O2'])
  File "/home/mibook/Code/emsdk/emscripten/nightly-1.36.14-2016_12_19_18_10/embuilder.py", line 69, in build
    shared.Building.emcc(temp, args, output_filename=temp_js)
  File "/home/mibook/Code/emsdk/emscripten/nightly-1.36.14-2016_12_19_18_10/tools/shared.py", line 1721, in emcc
    assert os.path.exists(output_filename), 'emcc could not create output file: ' + output_filename
AssertionError: emcc could not create output file: /home/mibook/Code/emsdk/tmp/tmpVNQVoo.js

@juj When using your script, two problems arise:

  • as mentioned above, there's an issue with uglifyjs when compiling native_optimizer, but it seems to work fine when omitting it from the embuilder.
  • there's also an issue where the downloaded clang is missing its include directory, making it incapable of compiling various source codes such as those depending on stdarg.h. This issue is a bit more problematic; do you have an idea to fix it?

[edit] I "fixed" it by using gcc instead of clang when building regular source codes. The issue actually only happened when building with clang without using emscripten. Everything was fine when using emcc. I guess that the actual fix would be not to put the emsdk's clang binary in the PATH.

Just for inspiration for the official image, we are using emscripten in docker too, although only released versions using following Dockerfile https://github.com/apiaryio/emscripten-docker/blob/master/1.37/Dockerfile it may contain something useful. I'd be really grateful if there was a official image so if I can help let me know.

This issue has been automatically marked as stale because there has been no activity in the past 2 years. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.

Was this page helpful?
0 / 5 - 0 ratings