Bug 88873 - [Qt][Win] Symbols are not exported in QtWebKit5.dll
Summary: [Qt][Win] Symbols are not exported in QtWebKit5.dll
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Simon Hausmann
URL:
Keywords:
Depends on:
Blocks: 88300
  Show dependency treegraph
 
Reported: 2012-06-12 07:43 PDT by Simon Hausmann
Modified: 2012-06-26 07:29 PDT (History)
2 users (show)

See Also:


Attachments
Script to facilitate symbol exports (847 bytes, text/x-python)
2012-06-12 07:45 PDT, Simon Hausmann
no flags Details
Patch (5.17 KB, patch)
2012-06-26 03:51 PDT, Simon Hausmann
no flags Details | Formatted Diff | Diff
Patch (5.24 KB, patch)
2012-06-26 06:34 PDT, Simon Hausmann
no flags Details | Formatted Diff | Diff
Patch (5.60 KB, patch)
2012-06-26 06:47 PDT, Simon Hausmann
no flags Details | Formatted Diff | Diff
Patch (5.22 KB, patch)
2012-06-26 06:53 PDT, Simon Hausmann
vestbo: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Hausmann 2012-06-12 07:43:01 PDT
In the WebKit2 static library we Q_DECL_EXPORT a bunch of classes/functions, but when linking QtWebKit5.dll those symbols are not exported when compiling with MSVC. This is how the MSVC toolchain behaves.

The suggested workaround is to run a little script over the static libraries we create to extract all the symbols that are marked for export and make sure that they are actually exported (and not discarded!) in the final dll.
Comment 1 Simon Hausmann 2012-06-12 07:45:53 PDT
Created attachment 147084 [details]
Script to facilitate symbol exports

The attached scripts implements the basic functionality needed. Symbols marked for export get a /EXPORT:<name of mangled symbol> in the linker directive section of the .obj file (and thus .lib file). We can extract all these with the script and generate a new file with linker pragmas that should be compiled into QtWebKit5.dll and makes sure that the symbols we want to export are also referenced.
Comment 2 Simon Hausmann 2012-06-25 21:51:23 PDT
After the changes for bug #78109 this is now needed for the the Windows build altogether, because the WK1 API is now also in a separate static library.
Comment 3 Simon Hausmann 2012-06-26 03:51:03 PDT
Created attachment 149504 [details]
Patch
Comment 4 Jocelyn Turcotte 2012-06-26 04:58:47 PDT
Comment on attachment 149504 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=149504&action=review

> Tools/Scripts/mkexports:43
> +print "Found %s symbols in %s" % (len(symbols), sys.argv[1])

This could describe the action made on this symbol for those not knowing what this is about, something like "Forwarding the export of symbol %s from static lib %s".

> Tools/qmake/mkspecs/features/win32/default_post.prf:25
> +contains(TARGET, $$resolveFinalLibraryName($${QT.webkit.name})) {

Just a nitpick but it's a bit weird to place it in default_post and then add a condition on TARGET.
A different way of doing it could be to put a function in functions.prf and call it from api.pri and WebKit1.pro.

> Tools/qmake/mkspecs/features/win32/default_post.prf:35
> +    exportgen.commands = python $${ROOT_WEBKIT_DIR}$${QMAKE_DIR_SEP}Tools$${QMAKE_DIR_SEP}Scripts$${QMAKE_DIR_SEP}mkexports ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}

If we have to put the script in Tools/Scripts we could name it a bit more like the local script name style. Something like "generate-win32-export-forwards" maybe.
Comment 5 Simon Hausmann 2012-06-26 05:13:22 PDT
Comment on attachment 149504 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=149504&action=review

>> Tools/Scripts/mkexports:43
>> +print "Found %s symbols in %s" % (len(symbols), sys.argv[1])
> 
> This could describe the action made on this symbol for those not knowing what this is about, something like "Forwarding the export of symbol %s from static lib %s".

Good idea, will change that.

>> Tools/qmake/mkspecs/features/win32/default_post.prf:25
>> +contains(TARGET, $$resolveFinalLibraryName($${QT.webkit.name})) {
> 
> Just a nitpick but it's a bit weird to place it in default_post and then add a condition on TARGET.
> A different way of doing it could be to put a function in functions.prf and call it from api.pri and WebKit1.pro.

True. Either that or we simply don't do that check and always implement this behaviour when TEMPLATE = lib and contains(CONFIG, shared)

Essentially this is adding the missing bits on win32 that --whole-archive is on linux for example.

>> Tools/qmake/mkspecs/features/win32/default_post.prf:35
>> +    exportgen.commands = python $${ROOT_WEBKIT_DIR}$${QMAKE_DIR_SEP}Tools$${QMAKE_DIR_SEP}Scripts$${QMAKE_DIR_SEP}mkexports ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
> 
> If we have to put the script in Tools/Scripts we could name it a bit more like the local script name style. Something like "generate-win32-export-forwards" maybe.

Alright, I like export-forwards in the name.
Comment 6 Simon Hausmann 2012-06-26 06:34:53 PDT
Created attachment 149523 [details]
Patch
Comment 7 Simon Hausmann 2012-06-26 06:47:12 PDT
Created attachment 149525 [details]
Patch
Comment 8 Simon Hausmann 2012-06-26 06:53:57 PDT
Created attachment 149526 [details]
Patch
Comment 9 Simon Hausmann 2012-06-26 07:29:20 PDT
Committed r121261: <http://trac.webkit.org/changeset/121261>