LLVM backend: linker error ("Relocations not in offset order")

38 views
Skip to first unread message

Soeren Balko

unread,
May 20, 2019, 7:16:56 PM5/20/19
to emscripten-discuss
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


Alon Zakai

unread,
May 21, 2019, 1:15:26 PM5/21/19
to emscripte...@googlegroups.com
This may be due to an out of date LLVM. You say you got LLVM from the emsdk - did you get "latest-upstream"? The upstream version in the fastcomp build is not new enough, in particular, only very recent LLVM from upstream master will work (with emscripten incoming).

Regarding that symbol, I think __EMSCRIPTEN__ is defined automatically. It's possible fastcomp also defined it without underscores - if so, we should probably either support both, or document this better.


--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/f3247662-0409-4d67-bdfc-d187fd659fbb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Soeren Balko

unread,
May 21, 2019, 6:57:58 PM5/21/19
to emscripten-discuss
Thanks for pointing out that it's supposed to be __EMSCRIPTEN__, not EMSCRIPTEN. Will change that in our code base.

Other than that, I did use the "latest-upstream" emsdk version. The only oddity is that I am not using the Emscripten version from emsdk, but a recent fork of Emscripten's incoming branch with some patches on top. None of these patches should affect the compiler backend though, most of them are in preamble.js. 

Is there anything else I could try to get the LLVM backend to work? Are some settings that I use (PRECISE_F32, DOUBLE_MODE, etc.) not available outside of fastcomp?

Soeren
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

Alon Zakai

unread,
May 21, 2019, 7:09:48 PM5/21/19
to emscripte...@googlegroups.com
Some settings like PRECISE_F32 don't work in wasm in general (since wasm has native f32s). That one just silently does nothing. Other flags that don't work should throw an error. If not that's a bug.

If nothing seems obvious, if you can provide a testcase hitting that error we can look into it.

To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/0271178d-d75d-4b40-b3e2-85a897e2227b%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages