Bug 25809

Summary: decorations __declspec(dlimport) and __declspec(dlexport) break linking on win32 with mingw
Product: WebKit Reporter: Fridrich Strba <fridrich.strba>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal    
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Windows XP   
Attachments:
Description Flags
don't use __declspec(dlimport) and __declspec(dlexport) decorations when building with mingw
none
use !COMPILER(GCC) instead of !defined(__MINGW32__)
none
A proper standard-compliant patch with ChangeLog entries mjs: review+

Fridrich Strba
Reported 2009-05-14 14:54:03 PDT
Since we are building webkit by building several static libraries that we link into one shared library, the decorations break the linking on win32 with mingw. The win32 linker cannot link the symbols into a static library as __imp___whatever, so, it links them as _whatever only. But at the time when we are creating the libwebkit shared library, the linker looks for the __imp___whatever symbols because the decorations force him to do so. Now, the win32 linker that comes with GNU binutils has a nice feature that is called autoimport. It is activated by default and does the RightThing(tm) without the decorations. When building with gcc on windows, it is a safe practice to rely on this nifty feature, because getting the __declspec(dl*) decorations right is just a big pain and sometime not even humanly possible. Following patch solves that for win32 builds with mingw32
Attachments
don't use __declspec(dlimport) and __declspec(dlexport) decorations when building with mingw (1.12 KB, patch)
2009-05-14 14:55 PDT, Fridrich Strba
no flags
use !COMPILER(GCC) instead of !defined(__MINGW32__) (1.10 KB, patch)
2009-05-14 15:04 PDT, Fridrich Strba
no flags
A proper standard-compliant patch with ChangeLog entries (3.61 KB, patch)
2009-05-15 02:04 PDT, Fridrich Strba
mjs: review+
Fridrich Strba
Comment 1 2009-05-14 14:55:05 PDT
Created attachment 30359 [details] don't use __declspec(dlimport) and __declspec(dlexport) decorations when building with mingw
Fridrich Strba
Comment 2 2009-05-14 15:02:09 PDT
Comment on attachment 30359 [details] don't use __declspec(dlimport) and __declspec(dlexport) decorations when building with mingw > --- webkit-1.1.7/JavaScriptCore/config.h (revision 43188) > +++ webkit-1.1.7/JavaScriptCore/config.h (working copy) > @@ -25,7 +25,7 @@ > > #include <wtf/Platform.h> > > -#if PLATFORM(WIN_OS) && !defined(BUILDING_WX__) > +#if PLATFORM(WIN_OS) && !defined(BUILDING_WX__) && !COMPILER(GCC) > #if defined(BUILDING_JavaScriptCore) || defined(BUILDING_WTF) > #define JS_EXPORTDATA __declspec(dllexport) > #else > --- webkit-1.1.7/WebCore/config.h (revision 43188) > +++ webkit-1.1.7/WebCore/config.h (working copy) > @@ -24,7 +24,7 @@ > > #include <wtf/Platform.h> > > -#if PLATFORM(WIN_OS) && !defined(BUILDING_WX__) > +#if PLATFORM(WIN_OS) && !defined(BUILDING_WX__) && !COMPILER(GCC) > #if defined(BUILDING_JavaScriptCore) || defined(BUILDING_WTF) > #define JS_EXPORTDATA __declspec(dllexport) > #else > --- webkit-1.1.7/WebKitTools/DumpRenderTree/config.h (revision 43188) > +++ webkit-1.1.7/WebKitTools/DumpRenderTree/config.h (working copy) > @@ -26,7 +26,7 @@ > > #include <wtf/Platform.h> > > -#if PLATFORM(WIN_OS) > +#if PLATFORM(WIN_OS) && !defined(__MINGW32__) > #define JS_EXPORTDATA __declspec(dllimport) > #define WEBKIT_EXPORTDATA __declspec(dllimport) > #else
Fridrich Strba
Comment 3 2009-05-14 15:02:58 PDT
Comment on attachment 30359 [details] don't use __declspec(dlimport) and __declspec(dlexport) decorations when building with mingw >--- webkit-1.1.7/JavaScriptCore/config.h (revision 43188) >+++ webkit-1.1.7/JavaScriptCore/config.h (working copy) >@@ -25,7 +25,7 @@ > > #include <wtf/Platform.h> > >-#if PLATFORM(WIN_OS) && !defined(BUILDING_WX__) >+#if PLATFORM(WIN_OS) && !defined(BUILDING_WX__) && !COMPILER(GCC) > #if defined(BUILDING_JavaScriptCore) || defined(BUILDING_WTF) > #define JS_EXPORTDATA __declspec(dllexport) > #else >--- webkit-1.1.7/WebCore/config.h (revision 43188) >+++ webkit-1.1.7/WebCore/config.h (working copy) >@@ -24,7 +24,7 @@ > > #include <wtf/Platform.h> > >-#if PLATFORM(WIN_OS) && !defined(BUILDING_WX__) >+#if PLATFORM(WIN_OS) && !defined(BUILDING_WX__) && !COMPILER(GCC) > #if defined(BUILDING_JavaScriptCore) || defined(BUILDING_WTF) > #define JS_EXPORTDATA __declspec(dllexport) > #else >--- webkit-1.1.7/WebKitTools/DumpRenderTree/config.h (revision 43188) >+++ webkit-1.1.7/WebKitTools/DumpRenderTree/config.h (working copy) >@@ -26,7 +26,7 @@ > > #include <wtf/Platform.h> > >-#if PLATFORM(WIN_OS) >+#if PLATFORM(WIN_OS) && !defined(__MINGW32__) > #define JS_EXPORTDATA __declspec(dllimport) > #define WEBKIT_EXPORTDATA __declspec(dllimport) > #else
Fridrich Strba
Comment 4 2009-05-14 15:04:34 PDT
Created attachment 30360 [details] use !COMPILER(GCC) instead of !defined(__MINGW32__)
Fridrich Strba
Comment 5 2009-05-15 02:04:12 PDT
Created attachment 30379 [details] A proper standard-compliant patch with ChangeLog entries
Jan Alonzo
Comment 6 2009-05-17 01:37:37 PDT
Comment on attachment 30379 [details] A proper standard-compliant patch with ChangeLog entries > Index: JavaScriptCore/config.h > =================================================================== > --- JavaScriptCore/config.h (revision 43762) > +++ JavaScriptCore/config.h (working copy) > @@ -25,7 +25,7 @@ > > #include <wtf/Platform.h> > > -#if PLATFORM(WIN_OS) && !defined(BUILDING_WX__) > +#if PLATFORM(WIN_OS) && !defined(BUILDING_WX__) && !COMPILER(GCC) > #if defined(BUILDING_JavaScriptCore) || defined(BUILDING_WTF) Is there a reason why you're not using COMPILER(MINGW32) here? Since this is specific to mingw, I think we should use COMPILER(MINGW32) here.
Fridrich Strba
Comment 7 2009-05-18 00:42:32 PDT
The COMPILER(GCC) encompassed also the Cygwin gcc compiler that is likely to hit this issue too because of the way we link the shared webkit library.
Maciej Stachowiak
Comment 8 2009-05-22 00:39:53 PDT
Comment on attachment 30379 [details] A proper standard-compliant patch with ChangeLog entries Are the decorations MSVC-specific, or do they fail only in GCC? Would it be better to use COMPILER(MSVC) instead of !COMPILER(GCC)? (Honestly not sure; r- for reply to question but feel free to just reflag this patch if the way it is now is right.)
Fridrich Strba
Comment 9 2009-05-22 00:51:06 PDT
The decorations don't work well when the compiler is GCC. That is why !COMPILER(GCC) They work well with MSVC, but they might also work well with other compilers for Windows, I don't have them and that is why I did this solution, because it is covering MinGW and CygWin where this problem arises.
Maciej Stachowiak
Comment 10 2009-05-22 00:59:00 PDT
Comment on attachment 30379 [details] A proper standard-compliant patch with ChangeLog entries r=me
Gustavo Noronha (kov)
Comment 11 2009-05-27 05:05:55 PDT
Landed as r44184.
Note You need to log in before you can comment on or make changes to this bug.