emscripten icon indicating copy to clipboard operation
emscripten copied to clipboard

2817d strips out needed symbols when some inputs are bitcode static libraries

Open ssj-gz opened this issue 13 years ago • 5 comments

I have a Qt app that works before 2817d but not after. The problem seems to come from a needed function definition (__Z10qAllocMoreii) being stripped out.

I'm not sure if this use-case is supported, but due to the convoluted nature of Qt's build system, I don't use emcc until the very final step of converting bitcode to js - rather, I compile the Qt libraries to bitcode static libaries (making sure that it uses only emscripten's versions of the system headers) and then do the same for whatever Qt app I'm trying to compile, and only then do I use emcc to link the app bitcode and the Qt library bitcode and convert to js.

I have a pre-compiled example here - simply extract to a directory, and run

emcc   embeddeddialogs.bc   QtCore.a QtGui.a   -O0   --closure 0   --jcache   --pre-js pre-qt.js   --embed-file qt-fonts   -s TOTAL_MEMORY=40000000    -o embeddeddialogs.html

Prior to 2817d, opening this in Chromium would (eventually!) lead to some debugging output followed by a small Qt window showing in the canvas, but as of 2817d, an exception is thrown during the call to "initRuntime" instead (you'll need to wrap the call to "initRuntime" in a try-catch block to see it). It is caused by the definition of __Z10qAllocMoreii not being included.

Apologies for the gigantic test-case - I couldn't find a way to reproduce it with a smaller one :/

PS - thanks for the quick fix on #745 - that cleared up all known Qt rendering glitches :)

ssj-gz avatar Dec 10 '12 16:12 ssj-gz

That commit will only add .o files inside .a archives when they are actually needed. A later commit refined that so we do the need check recursively. Is this still broken for you on incoming?

kripken avatar Dec 10 '12 18:12 kripken

Hi kripken,

Just tried on incoming, and now it gets a bit further, but now is missing the symbol:

_ZN6QTimerC1EP7QObject

(wrap "callMain" in try ... catch blocks to spot it)

Based on the html file of a working version, this actually appears to be an index into a vtable, rather than a function definition - although, running it through c++filt seems to say that is it QTimer::QTimer(QObject*), which is indeed a Qt constructor - not sure what's going on there :)

ssj-gz avatar Dec 10 '12 18:12 ssj-gz

Looking at the symbols here, it looks like you have the wrong order of archives. Sadly in POSIX, the order of .a files does matter. QtCore has symbols that QtGui needs, so QtCore must be after QtGui in the link command, otherwise it won't find them. (Or, do not use .a files, use .so instead which do not have this problem - but are less efficient in some cases.)

Changing the order, I see that the symbol does appear in the generated code.

kripken avatar Dec 10 '12 19:12 kripken

Doh - that's perfect, thanks - hope this didn't take up too much of your time!

ssj-gz avatar Dec 10 '12 19:12 ssj-gz

No worries, glad to help. Looking forward to more demos :)

kripken avatar Dec 10 '12 19:12 kripken