Bug 91229 - [Qt] MSVC: unresolved external symbol __DllMainCRTStartup@12
Summary: [Qt] MSVC: unresolved external symbol __DllMainCRTStartup@12
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (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-07-13 06:08 PDT by Jocelyn Turcotte
Modified: 2012-07-24 06:25 PDT (History)
6 users (show)

See Also:


Attachments
Patch (5.10 KB, patch)
2012-07-16 04:36 PDT, Simon Hausmann
no flags Details | Formatted Diff | Diff
Patch (5.09 KB, patch)
2012-07-16 07:26 PDT, Simon Hausmann
jturcotte: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jocelyn Turcotte 2012-07-13 06:08:57 PDT
Since the recent build changes in QtWebKit I get this error while linking QtWebKit.

From my investigations, this seems to happen since there is no more obj files linked into the DLL, only static libraries.
The way the linker usually links to MSVCRT.dll is by looking at linking directives in obj files, which depends if they were compiled with /MD, /MT, etc.

I didn't try out yet to fix it but I'm leaving on vacation and this is the result of my investigation. I guess that forcing the correct libs to the linker or adding an empty .cpp file in api.pri just to carry those options to the linker should do the trick.

This is using the --no-webkit2 switch.
Comment 1 Simon Hausmann 2012-07-13 07:09:31 PDT
win32's default_post.prf is supposed to generate the forwarding export .cpp files using generate-win32-export-forwards. The generated sources are added to SOURCES and the resulting obj file should have those linker directives.

However I also see the same issue and I do notice that the corresponding build rules for those are not always generated. So the lack of those rules is one issue and we could probably work around this particular linking issue with a dummy main.cpp file.
Comment 2 Simon Hausmann 2012-07-15 23:38:38 PDT
I think I found the reason. From win32/default_post.prf:

----
# When creating the target DLL, extract exporting linker directives from
# all static libraries we're linking into the DLL and make sure they are
# also exported from the DLL.
shared:contains(TEMPLATE, lib) {
    for(target, POST_TARGETDEPS) {
        libdep = $$find(target, .*\\.lib)
        exists($$libdep): LIBSWITHEXPORTS += $$libdep
    }
}

!isEmpty(LIBSWITHEXPORTS) {
    exportgen.input = LIBSWITHEXPORTS
    [...]
}
----

When the makefiles are generated the first time, the POST_TARGETDEPS are set correctly, but the exists() check prevents the population of LIBSWITHEXPORTS. Therefore the extra compiler is not set up and SOURCES remains empty.
Comment 3 Simon Hausmann 2012-07-16 04:36:53 PDT
Created attachment 152509 [details]
Patch
Comment 4 Simon Hausmann 2012-07-16 04:40:52 PDT
Fixing bug dependencies, this isn't really a WK2 specific problem.
Comment 5 Zoltan Horvath 2012-07-16 05:05:50 PDT
Comment on attachment 152509 [details]
Patch

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

> Tools/Scripts/generate-win32-export-forwards:31
> +    dumpBin = subprocess.Popen("dumpbin /directives " + library, stdout=subprocess.PIPE, universal_newlines=True);

Semicolon isn't needed.

> Tools/Scripts/generate-win32-export-forwards:33
> +    output, errors = dumpBin.communicate();

Since you don't do anything with 'errors' then
output = dumpBin.communicate()[0] 
is enough.

> Tools/Scripts/generate-win32-export-forwards:39
> +exportedSymbolRegexp = re.compile("\s*(?P<symbol>/EXPORT:.+)");

Semicolon isn't needed.


I didn't test it, but otherwise looks Iwouldr+it. :)
Comment 6 Peter Gal 2012-07-16 05:06:59 PDT
View in context: https://bugs.webkit.org/attachment.cgi?id=152509&action=review

Some python comments:

> Tools/Scripts/generate-win32-export-forwards:31
> +    dumpBin = subprocess.Popen("dumpbin /directives " + library, stdout=subprocess.PIPE, universal_newlines=True);

no need for the semicolon at the end.

> Tools/Scripts/generate-win32-export-forwards:33
> +    output, errors = dumpBin.communicate();

ditto

> Tools/Scripts/generate-win32-export-forwards:36
> +libraries = sys.argv[1 : len(sys.argv) - 1]

you can use negative indexing to get the last argument's index. so this'll be: sys.argv[1:-1]

> Tools/Scripts/generate-win32-export-forwards:37
> +outputFileName = sys.argv[len(sys.argv) - 1]

ditto: sys.argv[-1]

> Tools/Scripts/generate-win32-export-forwards:39
> +exportedSymbolRegexp = re.compile("\s*(?P<symbol>/EXPORT:.+)");

semicolon is not needed

> Tools/Scripts/generate-win32-export-forwards:45
> +        if match != None:

this can simply be: if match:
because None is logically false.
Comment 7 Simon Hausmann 2012-07-16 06:04:24 PDT
Awesome, thanks guys for the suggestions :)
Comment 8 Simon Hausmann 2012-07-16 07:26:45 PDT
Created attachment 152530 [details]
Patch
Comment 9 Simon Hausmann 2012-07-24 04:14:52 PDT
Comment on attachment 152530 [details]
Patch

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

> Tools/Scripts/generate-win32-export-forwards:37
> +libraries = sys.argv[1 : len(sys.argv) - 1]
> +outputFileName = sys.argv[len(sys.argv) - 1]

I still need the -1 syntax trick here.

> Tools/Scripts/generate-win32-export-forwards:45
> +        if match != None:

if match:

> Tools/qmake/mkspecs/features/win32/default_post.prf:36
> +        mac: suffix = _debug

I'll remove the mac stuff and win32 scope before landing, since this is in win32/default_post.prf
Comment 10 Simon Hausmann 2012-07-24 06:25:01 PDT
Committed r123465: <http://trac.webkit.org/changeset/123465>