Open Quuxplusone opened 4 years ago
Thanks for the report.
The crash should certainly be fixed. However you can make progress with this by disabled the building and using of shared libraries. I believe passing --disable-shared
to configure will do this. emscripten doesn't support shared libraries per-say. At least not in the sense the autoconf expected.
Right, I do intend to link statically at the final stage, and the supposed shared object is really a bitcode file. But adding --disable-shared
, which does avoid the crash, does not seem to give a useful build artifact (I get a 1kB libtool .la text file vs a 5MB .pd_linux (which is a renamed .so) file for a native build).
I'll see if I can patch Gem's build system to give a working static .a (really .bc) library, thanks for the idea. I'll report back here if I have success along those lines.
Just to add, that this did work about a year ago.
These days we prefer to use normal static libraries (.a files) rather than .bc files which is essentially combined object files.
This is more standard, plus it means we can use actual wasm object files rather than bitcode which is makes for faster builds. Plus we now have a linker that fully supports .a files.
I acknowledge that the technique you are using here used to work, and in general continues to work (once we fix this bug anyway).
However I stand by the statement that it would be better all around to use .a
files in almost all cases. Fake .so files (combined objects files in .bc format) should be avoided when possible.
Regarding .la
files, IIUC they are expected to be small, and are normally text files that reference the actual build artifact which should be a .a archive.
I managed to create a Gem.a in a hacky way (just copy/paste the failing shared library creation command and modify it to use ar instead; should be possible to fix the build system to do this for me somehow though I may need to ask the maintainers for help as I don't know much about the build system)
Then I needed to link my final artifact with
-Wl,--whole-archive Gem.a -Wl,--no-whole-archive
otherwise most of the code went missing (it uses C++ static initializers to register stuff for the main library setup function to call, so it isn't referenced by any code in the normal way). Thanks for your help!
Compiling Gem (a plugin for Pure-data) with Emscripten ("latest" as of today) fails at the link stage with an assertion failure in wasm-ld:
To reproduce, on a system with
debootstrap
: