Search code examples
ffmpegemscriptencc

shared:ERROR: closure compiler failed (rc: 1)


I want to build ffmpeg.js, but I am getting the following error when running make all:

    pop()()}}var shouldRunNow=true;if(Module["noInitialRun"])
{shouldRunNow=false}Module["noExitRuntime"]=true;run();return
 __ffmpegjs_return}module["exports"]=__ffmpegjs;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
    ^^^^^^^^^^^^^^^
    1 error(s), 6 warning(s)
    shared:ERROR: closure compiler failed (rc: 1)
    Makefile:316: recipe for target 'ffmpeg-webm.js' failed
    make: *** [ffmpeg-webm.js] Error 1 

The relevant lines in the Makefile are:

# Compile bitcode to JavaScript.
# NOTE(Kagami): Bump heap size to 64M, default 16M is not enough even
# for simple tests and 32M tends to run slower than 64M.
EMCC_COMMON_ARGS = \
    --closure 1 \
    -s TOTAL_MEMORY=67108864 \
    -s OUTLINING_LIMIT=20000 \
    -O3 --memory-init-file 0 \
    --pre-js $(PRE_JS) \
    -o $@

ffmpeg-webm.js: $(FFMPEG_WEBM_BC) $(PRE_JS) $(POST_JS_SYNC)
    emcc $(FFMPEG_WEBM_BC) $(WEBM_SHARED_DEPS) \ --------->>>>> THIS IS LINE 316
        --post-js $(POST_JS_SYNC) \
        $(EMCC_COMMON_ARGS)

How can I build ffmpeg.js with emcc correctly?


Solution

  • It says Closure Compiler failed. Remove --closure 1. You probably need to reduce the Optimization flag to -O2 in order to compile. As you can see, in my experience, Emscripten optimizers has some bugs with JS modularization code.

    It is always good try compiling anything without any optimization flags, then gradually enable them.