OK, I think perhaps the code I referred to inside tools/shared.py was meant to be used with the fastcomp backend. When using the LLVM backend LLVM is the one that writes the wasm file and the one that builds the dylink section (see https://github.com/llvm/llvm-project/blob/190dacc3cc206fa90a44e2f4aa6b56c327d1942a/lld/wasm/SyntheticSections.cpp#L58).
does this mean we should somehow pass the "needed_dynlibs" array of dependencies to LLVM so that it can correctly fills the dylink section? On Wednesday, October 23, 2019 at 12:35:30 PM UTC+2, Manuel Martín de Miguel wrote: > > Hi, > > I need to be able to link several SIDE_MODULEs to each other. more info > about the use case here: > https://github.com/iodide-project/pyodide/issues/240 > > "1 level" Dynamic linking seems to be working currently with the WASM > backend by using the MAIN_MODULE, SIDE_MODULE and RUNTIME_LINKED_LIBS flags. > > At first I though "multi level" dynamic linking was also working. By multi > level I mean for example a MAIN_MODULE that links against a SIDE_MODULE > which in turn links against another SIDE_MODULE. > This PR and this CHANGELOG entry made me think it should be working: > https://github.com/emscripten-core/emscripten/pull/7512/ > CHANGELOG.md version 1.38.22: > Dynamic linker has been taught to handle library -> library dependencies. > > However it doesn't seem to be working with the LLVM wasm backend. The way > this is supposed to work is by introducing > a new section in the wasm shared objects called "dylink". This section > contains references to other .wasm dependencies. The main module > seems to be able to read this section in order to load more .wasm > dependencies. (see the loadWebAssembly function on a main module). > > The problem is that the section is not being written properly. A dump of a > wasm shared object shows that it's just filled with zeros: > > emscripten@2502103aaaa0:/home/manuel/devenvironment/projects/mlx/experiments/emscripten-tests/wasm-study/wasm$ > > llvm- > readobj --sections --section-data libk_so.wasm > > File: libk_so.wasm > Format: WASM > Arch: wasm32 > AddressSize: 32bit > Sections [ > Section { > Type: CUSTOM (0x0) > Size: 5 > Offset: 8 > Name: dylink > SectionData ( > 0000: 00000000 00 |.....| > ) > } > > When building a SIDE_MODULE emcc.py should be calling this function: > shared.py:WebAssembly.make_shared_library(). This function is the one that > builds > the dylink section. The problem is that currently this code seems > deactivated for the wasm backend, as we can see in the following code > inside emcc.py: > > if shared.Settings.SIDE_MODULE and not shared.Settings.WASM_BACKEND: > wso = shared.WebAssembly.make_shared_library(final, > wasm_binary_target, shared.Settings.RUNTIME_LINKED_LIBS) > > This makes me think this is still not supported form WASM, only for asm.js. > > I just want to know the state of this functionality and how it fits in the > roadmap, if needed I could try to implement the remaining parts since it > seems only a few things are needed for it > to work. > > Thanks! > > > > -- The contents of this email are confidential. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to this message and deleting it from your computer. Thank you. Devo, Inc; [email protected] <mailto:[email protected]>; Calle Estébanez Calderón 3-5, 5th Floor. Madrid, Spain 28020 -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/e47c5f29-e6d8-4504-8aa4-3b9ab643e601%40googlegroups.com.
