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

Fails to compile / Dockerfile #44

Closed
jcaesar opened this issue Dec 6, 2017 · 8 comments
Closed

Fails to compile / Dockerfile #44

jcaesar opened this issue Dec 6, 2017 · 8 comments

Comments

@jcaesar
Copy link

jcaesar commented Dec 6, 2017

Since you already suggested using docker in the readme, I translated those instructions into a dockerfile.

FROM ubuntu:17.10

RUN apt-get update && apt-get -y install wget python git automake libtool build-essential cmake libglib2.0-dev closure-compiler git

RUN useradd -c 'Usa' -m -d /home/u -s /bin/bash u
USER u
WORKDIR /home/u

RUN wget https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz
RUN tar xzvf emsdk-portable.tar.gz
WORKDIR /home/u/emsdk-portable
RUN ./emsdk update
RUN ./emsdk install latest
RUN ./emsdk activate latest

WORKDIR /home/u
RUN git clone https://github.com/Kagami/ffmpeg.js.git
WORKDIR /home/u/ffmpeg.js
RUN git submodule init && git submodule update --recursive # sobmodules!

RUN bash -c '. ../emsdk-portable/emsdk_env.sh && make all'

I hope this can be useful to someone.

@PaulKinlan
Copy link
Contributor

I've done the similar and didn't have issues. The way I did it was slightly different, I used docker to create a stable environment and then I have separate commands that I run to create the build and copy the output back to my host environment.

FROM debian:sid

RUN apt-get update && apt-get -y install wget python git sudo automake libtool build-essential cmake libglib2.0-dev closure-compiler

RUN useradd -c 'Usa' -m -d /home/ffmpeg -s /bin/bash ffmpeg
USER ffmpeg
WORKDIR /home/ffmpeg

RUN wget https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz
RUN tar xzvf emsdk-portable.tar.gz
WORKDIR /home/ffmpeg/emsdk-portable
RUN ./emsdk update
RUN ./emsdk install latest
RUN ./emsdk activate latest

ENTRYPOINT ["/bin/bash"]

I then build this instance as follows sudo docker build -t ffmpegjs-build ., not it doesn't compile anything yet. I then run the instance with sudo docker run --rm -v "$(pwd)/output:/home/ffmpeg/tools" -it ffmpegjs-build, this will connect to the instance (because it is running bash) and it will mount a folder as a volume that contains my run script as follows:

#!/bin/bash

cd /home/ffmpeg/emsdk-portable
./emsdk update
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh

cd /home/ffmpeg
git clone https://github.com/Kagami/ffmpeg.js.git
cd ffmpeg.js
git submodule init
git submodule update --recursive

make all

cd /home/
cp /home/ffmpeg/ffmpeg.js/*.js /home/ffmpeg/output

As you can see it is pretty much exactly what you had, but split in to two phases.

@jcaesar
Copy link
Author

jcaesar commented Mar 6, 2018

Hm. I tried to reproduce my problem. Can't, anymore. Oh well.

@MWijnants-1
Copy link

I'm also facing compilation issues. I'm testing on Ubuntu 18.04 LTS 64-bit (running as a VM on Windows 10). The specific compile error I'm getting is the following:

Stack: Error
at assertTrue (eval at globalEval (/home/u/emsdk-portable/emscripten/1.38.1/tools/js-optimizer.js:114:8), :59:26)
at Object.emitDCEGraph (/home/u/emsdk-portable/emscripten/1.38.1/tools/js-optimizer.js:8143:3)
at /home/u/emsdk-portable/emscripten/1.38.1/tools/js-optimizer.js:8367:14
at Array.forEach ()
at Object. (/home/u/emsdk-portable/emscripten/1.38.1/tools/js-optimizer.js:8366:21)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)

undefined:60
throw msg;
^
Assertion failed: could not find the assigment to "asmLibraryArg". perhaps --pre-js or --post-js code moved it out of the global scope? (things like that should be done after emcc runs, as they do not need to be run through the optimizer which is the special thing about --pre-js/--post-js code)
Traceback (most recent call last):
File "/home/u/emsdk-portable/emscripten/1.38.1/emcc", line 11, in
python_selector.run(file)
File "/home/u/emsdk-portable/emscripten/1.38.1/tools/python_selector.py", line 38, in run
sys.exit(run_by_import(filename, main) if on_allowed_version() else run_by_subprocess(filename))
File "/home/u/emsdk-portable/emscripten/1.38.1/tools/python_selector.py", line 13, in run_by_import
return getattr(importlib.import_module(os.path.basename(filename)), main)()
File "/home/u/emsdk-portable/emscripten/1.38.1/emcc.py", line 1933, in run
wasm_text_target, misc_temp_files, optimizer)
File "/home/u/emsdk-portable/emscripten/1.38.1/emcc.py", line 2473, in do_binaryen
emit_symbol_map=emit_symbol_map)
File "/home/u/emsdk-portable/emscripten/1.38.1/tools/shared.py", line 2252, in minify_wasm_js
js_file = Building.metadce(js_file, wasm_file, minify_whitespace=minify_whitespace, debug_info=debug_info)
File "/home/u/emsdk-portable/emscripten/1.38.1/tools/shared.py", line 2272, in metadce
txt = Building.js_optimizer_no_asmjs(js_file, ['emitDCEGraph', 'noEmitAst'], return_output=True)
File "/home/u/emsdk-portable/emscripten/1.38.1/tools/shared.py", line 2117, in js_optimizer_no_asmjs
return run_process(NODE_JS + [js_optimizer.JS_OPTIMIZER, filename] + passes, stdout=PIPE).stdout
File "/home/u/emsdk-portable/emscripten/1.38.1/tools/shared.py", line 131, in run_process
return run_base(cmd, universal_newlines=universal_newlines, check=check, *args, **kw)
File "/home/u/emsdk-portable/emscripten/1.38.1/tools/shared.py", line 127, in run_base
result.check_returncode()
File "/home/u/emsdk-portable/emscripten/1.38.1/tools/shared.py", line 114, in check_returncode
raise Py2CalledProcessError(returncode=self.returncode, cmd=self.args, output=self.stdout, stderr=self.stderr)
tools.shared.Py2CalledProcessError: Command '['/home/u/emsdk-portable/node/8.9.1_64bit/bin/node', '/home/u/emsdk-portable/emscripten/1.38.1/tools/js-optimizer.js', '/tmp/tmpkVZagF/ffmpeg-webm.bc.o.js.pp.js.mem.js.jsopted.js.jsopted.js.jsopted.js.jso.js', 'emitDCEGraph', 'noEmitAst']' returned non-zero exit status 1
Makefile:316: recipe for target 'ffmpeg-webm.js' failed
make: *** [ffmpeg-webm.js] Error 1

I get similar errors for all possible build targets (i.e., ffmpeg-webm.js, ffmpeg-worker-webm.js, ffmpeg-mp4.js, ffmpeg-worker-mp4.js). The errors occur both when building directly and when using Docker (i.e., the approach suggested in this thread).

Does anyone have an idea what might be going wrong?
Many thanks!

@swznd
Copy link

swznd commented May 26, 2018

@mwijnants since version 1.38 emscripten using WASM by default, and it seems pre and post script not compatible for WASM

try using version 1.37

./emsdk install emscripten-1.37.40 
./emsdk activate emscripten-1.37.40 
source ./emsdk_env.sh

@MWijnants-1
Copy link

@swznd that seemed to do the trick, thank you so much for the advice!

For the sake of completeness, installing and activating emscripten version 1.37.40 did not work "out of the box". I had to manually install and activate clang-e1.37.40-64bit.

@seranus
Copy link

seranus commented Jun 17, 2018

@mwijnants same issue, do you have a link to the clang file?

@MWijnants-1
Copy link

@seranus

You can use

emsdk list [--old]

to query the list of supported tools (including clang and node.js). In this list, there should be a matching clang version for each emscripten version. You can then install this version via the

emsdk install

syntax. See emsdk command line syntax and emsdk Tools and SDK Targets for more information.

Hope this helps.

@Kagami
Copy link
Owner

Kagami commented Apr 19, 2020

Thank you @jcaesar @PaulKinlan. I've added docker-based build instruction to readme.

rei2hu pushed a commit to essencesdev/ffmpeg.js that referenced this issue Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants