I have some trouble getting the LLVM backend to work. My FFmpeg build links a couple of libraries, which works fine with the "fastcomp" backend. However, for some of the linked-in libraries (eg., libvpx, libopus), llvm-nm fails with:
llvm-nm failed on file libvpx.bc: return code 1, error: emsdk/upstream/6308/bin/llvm-nm: error: libvpx.bc Relocations not in offset order
This causes wasm-ld to fail subsequently when linking the entire build. Other libraries (eg., libavfilter from the FFmpeg build) do not seem to exhibit this problem.
My build settings are this:
-s USE_OGG=1 \
-s USE_VORBIS=1 \
-s USE_ZLIB=1 \
-s PRECISE_F32=2 \
-s DOUBLE_MODE=0 \
-s ASSERTIONS=0 \
-s INVOKE_RUN=0 \
-s NODEJS_CATCH_EXIT=0 \
--memory-init-file 0
Not sure what causes this and how to fix it. As a side note, I've used Emscripten from its incoming branch (commit id is 3a9424299cdda8157e0ccf38ebef951a1b7b5fe4), whereas LLVM is retrieved by means of emsdk. I normally build the "fastcomp" backend myself, cloning the emscripten-fastcomp and emscripten-fastcomp-clang repos and keeping them in lockstep with emscripten. However, I could not find the instructions on how to compile emscripten-fastcomp to include the LLVM backend (I tried adding "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly") to the cmake command, but that does not seem to generate the "wasm-ld" command (I get this: emcc: WASM_BACKEND selected but could not find lld (wasm-ld): /home/balko/dev/libav.js/emscripten-fastcomp/build/bin/wasm-ld).
Other than that, I had to manually add a "-DEMSCRIPTEN=1" compiler define in order to make the "EMSCRIPTEN" symbol known throughout the code, which I found surprising.
Any clues on how to get this to work from anyone who has successfully used the LLVM backend in a similar setting would be greatly appreciated.
Thanks,
Soeren