[Development] wasm and static vs. shared libs

Martin Koller kollix at aon.at
Wed Oct 2 11:32:20 CEST 2019


On Mittwoch, 2. Oktober 2019 00:02:01 CEST Lorn Potter wrote:
> Hi Martin,
> 
> 
> On 1/10/19 4:38 PM, Martin Koller wrote:
> > Hi,
> > 
> > I see that compiling Qt for wasm produces .a static libs.
> > This however leads to a couple of duplicate symbols when linking my existing large application.
> > 
> > Here
> > https://emscripten.org/docs/compiling/Building-Projects.html?highlight=link#archive-a-files
> > I read
> > "Where possible it is better to generate shared library files (.so) rather than archives (.a) — this is generally a simple change in your project’s build system. Shared libraries are simpler, and are more predictable with respect to linking."
> > 
> > so my question is: why does qt/wasm not allow to be built as -shared ?
> 
> 
> https://github.com/emscripten-core/emscripten/wiki/Linking
> 
> 
> Probably my main concern is the performance hit of dynamic linking. 
> 5-10% performance hit did not seem like an acceptable trade-off to me. 
> Not sure if the performance drop is different for running wasm instead 
> of the javascript like when this was first started.
> 
> As well, getting the build system to behave is easier in wasm with 
> static libraries.
> 
> That said, there is a task for wasm dynamic linking support, but has not 
> been worked on recently, and the WIP change is out of date.
> 
> https://bugreports.qt.io/browse/QTBUG-63925

I'm not sure we talk about the same thing.
I'm not talking about "dynamic linking" (happening at runtime) but only
about libXX.a versus libXX.so
where
https://emscripten.org/docs/compiling/Building-Projects.html?highlight=link#dynamic-linking
explains that
"By default, Emscripten .so files are the same as .bc or .o files, that is, they contain LLVM bitcode. Dynamic libraries that you specify in the final build stage (when generating JavaScript or HTML) are linked in as static libraries."

So I read this as: libXX.so files are still linked in statically, the only difference is how emscripten handles
the resolving of symbols.
See how
https://emscripten.org/docs/compiling/Building-Projects.html?highlight=link#archive-a-files
explains
"Emscripten supports .a archive files, which are bundles of object files. This is an old format for libraries, and it has special semantics - for example, the order of linking matters with .a files, but not with plain object files (in .bc, .o or .so)."

-- 
Best regards/Schöne Grüße

Martin
A: Because it breaks the logical sequence of discussion
Q: Why is top posting bad?

()  ascii ribbon campaign - against html e-mail 
/\                        - against proprietary attachments

Geschenkideen, Accessoires, Seifen, Kulinarisches: www.lillehus.at




More information about the Development mailing list