Bug 50519 - [Qt] [WK2] WebKit2 enabled build fails to link
Summary: [Qt] [WK2] WebKit2 enabled build fails to link
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC All
: P4 Normal
Assignee: Andras Becsi
URL:
Keywords: Qt, QtTriaged
Depends on:
Blocks:
 
Reported: 2010-12-04 06:42 PST by Laszlo Gombos
Modified: 2011-01-20 10:20 PST (History)
2 users (show)

See Also:


Attachments
proposed fix (13.39 KB, patch)
2010-12-20 07:23 PST, Andras Becsi
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Laszlo Gombos 2010-12-04 06:42:10 PST
build-webkit --qt --minimal CONFIG+=webkit2 results in the following linnking error:


/usr/bin/ld: ../WebKit2/release/libwebkit2.a(ThreadLauncherQt.o): in function WebKit::ThreadLauncher::createWebThread():ThreadLauncherQt.cpp(.text+0xea): error: undefined reference to 'WTF::createThread(void* (*)(void*), void*, char const*)'
/usr/bin/ld: ../WebKit2/release/libwebkit2.a(WebProcess.o): in function WebKit::WebProcess::initialize(QString, RunLoop*):WebProcess.cpp(.text+0x1852): error: undefined reference to 'WTF::createThread(void* (*)(void*), void*, char const*)'
collect2: ld returned 1 exit status
make[1]: *** [../lib/libQtWebKit.so.4.9.0] Error 1
Comment 1 Andras Becsi 2010-12-20 07:23:32 PST
Created attachment 76996 [details]
proposed fix

This patch also adds missing ENABLE(DATABASE) guards to fix the build. 

The linking issue is caused by a more complex problem.
In a default WebKit2 build WebCore links to the static jscore library, and because some parts of WebCore (IconDatabase, ImageResizerThread, DatabaseThread, LocalStorageThread, WorkerThread) are using createThread, the linker doesn't remove the symbol so it is present afterwards when linking to the static webkit2 lib, but in a minimal build these parts are guarded by various ENABLE guards so because they are not needed in WebCore the linker removes the symbol, but the WebKit2 ThreadLauncher nonetheless needs the symbol, hence the linking fails.
This patch adds -whole-archive to JavaScriptCore.pri's addJavaScriptCoreLib to explicitly force the linker to keep all the symbols of the archive.

This is only a workaround and should serve as a temporary solution until we find a proper solution, how to refactor the build system.
Comment 2 Andras Becsi 2010-12-20 07:29:16 PST
(In reply to comment #1)
> Created an attachment (id=76996) [details]
> proposed fix
> 
> This patch also adds missing ENABLE(DATABASE) guards to fix the build. 
> 
> The linking issue is caused by a more complex problem.
> In a default WebKit2 build WebCore links to the static jscore library, and because some parts of WebCore (IconDatabase, ImageResizerThread, DatabaseThread, LocalStorageThread, WorkerThread) are using createThread, the linker doesn't remove the symbol so it is present afterwards when linking to the static webkit2 lib, but in a minimal build these parts are guarded by various ENABLE guards so because they are not needed in WebCore the linker removes the symbol, but the WebKit2 ThreadLauncher nonetheless needs the symbol, hence the linking fails.
> This patch adds -whole-archive to JavaScriptCore.pri's addJavaScriptCoreLib to explicitly force the linker to keep all the symbols of the archive.
> 
> This is only a workaround and should serve as a temporary solution until we find a proper solution, how to refactor the build system.

The whole-archive change should be inside a webkit2 guard, but before I update the patch I'll wait for some opinions.
Comment 3 Laszlo Gombos 2010-12-20 09:47:31 PST
This perhaps is another reason to _not_ build WebKit2 as a separate library - and instead build it into the WebKit library directly like many other WebKit features.
Comment 4 Kenneth Rohde Christiansen 2010-12-24 03:06:19 PST
Comment on attachment 76996 [details]
proposed fix

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

> JavaScriptCore/JavaScriptCore.pri:88
> -        LIBS += -l$$JAVASCRIPTCORE_TARGET
> +        LIBS += -Wl,-whole-archive -l$$JAVASCRIPTCORE_TARGET -Wl,-no-whole-archive

I think this change is different from the rest of this patch. Please split up.
Comment 5 Andras Becsi 2011-01-20 10:20:08 PST
A workaround to use whole-archive was landed in r76263 which fixes the issue for now until the build system gets redesigned.
(See https://bugs.webkit.org/show_bug.cgi?id=51339)
Closing this bug.