Bug 130837 - Webkit2 doesnt build on powerpc 32 bits
Summary: Webkit2 doesnt build on powerpc 32 bits
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-27 06:29 PDT by Landry Breuil
Modified: 2014-11-24 06:49 PST (History)
6 users (show)

See Also:


Attachments
Patch (573 bytes, patch)
2014-11-18 02:31 PST, Alberto Garcia
no flags Details | Formatted Diff | Diff
Patch (508 bytes, patch)
2014-11-19 01:19 PST, Alberto Garcia
no flags Details | Formatted Diff | Diff
Patch (1.32 KB, patch)
2014-11-20 04:33 PST, Alberto Garcia
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Landry Breuil 2014-03-27 06:29:03 PDT
With a variety of patches i can build webkit1 on ppc 32 bits (it blows at runtime but that's another story), but webkit2 fails with:

webkit-2.4.0-gtk3/webkitgtk-2.4.0/.libs/libWebKit2Platform.a(libWebKit2Platform_l
a-Connection.o)(.gnu.linkonce.t._ZNSt13__atomic_baseIyEppEv+0x2c): In function `_ZNSt13__atomic_baseIyEppEv':                                                                                               
: undefined reference to `__atomic_fetch_add_8'

This is most probably due to the fact that ppc 32 bits cant have atomic ops on a 8-bytes value. The func is std::__atomic_base<unsigned long long>::operator++(),
and i'm pretty sure this comes from http://trac.webkit.org/browser/trunk/Source/WebKit2/Platform/IPC/Connection.h#L216
the ++ operator being called in http://trac.webkit.org/browser/trunk/Source/WebKit2/Platform/IPC/Connection.cpp#L341.

The std::atomic<> template was added in http://trac.webkit.org/browser/trunk/Source/WebKit2/Platform/CoreIPC/Connection.h?annotate=blame&rev=159724#file11 and i fail to see the reasoning for it.
Comment 1 Landry Breuil 2014-03-27 15:09:36 PDT
Note that there's another std::atomic<int64_t> in Source/WebKit2/UIProcess/StatisticsRequest.cpp, and apparently one more in git master/svn head.

A workaround is to #if out the std::atomic template for 64-bits types on ppc, but a better real solution would be welcome.
Cf http://www.openbsd.org/cgi-bin/cvsweb/ports/www/webkit/patches/patch-Source_WebKit2_Platform_IPC_Connection_h?rev=1.1
and http://www.openbsd.org/cgi-bin/cvsweb/ports/www/webkit/patches/patch-Source_WebKit2_UIProcess_StatisticsRequest_cpp?rev=1.3

+#if CPU(PPC)
+    static int64_t uniqueRequestID;
+#else
     static std::atomic<int64_t> uniqueRequestID;
+#endif


sunset:~/src/WebKit/ $git grep std::atomic | grep 64
Source/WebKit2/Platform/IPC/Connection.h:    std::atomic<uint64_t> m_syncRequestID;
Source/WebKit2/Shared/mac/SecItemShim.cpp:    static std::atomic<int64_t> uniqueSecItemRequestID;
Source/WebKit2/UIProcess/StatisticsRequest.cpp:    static std::atomic<int64_t> uniqueRequestID;
Comment 2 Alberto Garcia 2014-09-10 01:58:11 PDT
(In reply to comment #0)
> With a variety of patches i can build webkit1 on ppc 32 bits (it blows at runtime but that's another story), but webkit2 fails with:
>
> webkit-2.4.0-gtk3/webkitgtk-2.4.0/.libs/libWebKit2Platform.a(libWebKit2Platform_l
> a-Connection.o)(.gnu.linkonce.t._ZNSt13__atomic_baseIyEppEv+0x2c): In function `_ZNSt13__atomic_baseIyEppEv':
> : undefined reference to `__atomic_fetch_add_8'

Did you try adding -latomic to the linker flags?
Comment 3 Sasa Ostrouska 2014-11-17 14:23:04 PST
Hi I don't know if this is in some way related to this bug, but I'm trying to compile this from 2.5.90 up to 2.6.3 ending always at make install phase with the same error.

sasa@slack141-314:/tmp/DLG/logs/webkitgtk-2.6.3-2$ cat makeinstall.txt 
[  0%] Built target WebKit2-forwarding-headers
[  1%] Built target WTF
[  1%] Built target LLIntOffsetsExtractor
[ 12%] Built target JavaScriptCore
[ 13%] Built target ANGLESupport
[ 76%] Built target WebCore
[ 77%] Built target WebCorePlatformGTK
[ 78%] Built target fake-generated-webkitdom-headers
[ 84%] Built target GObjectDOMBindings
[ 84%] Built target WebKit2-fake-api-headers
Linking CXX shared library ../../lib/libwebkit2gtk-4.0.so
CMakeFiles/WebKit2.dir/Platform/IPC/Connection.cpp.o: In function `IPC::Connection::createSyncMessageEncoder(IPC::StringReference, IPC::StringReference, unsigned long long, unsigned long long&)':
Connection.cpp:(.text+0x20f): undefined reference to `__atomic_fetch_add_8'
CMakeFiles/WebKit2.dir/UIProcess/StatisticsRequest.cpp.o: In function `WebKit::StatisticsRequest::addOutstandingRequest()':
StatisticsRequest.cpp:(.text+0xac3): undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
make[2]: *** [lib/libwebkit2gtk-4.0.so.37.2.4] Error 1
make[1]: *** [Source/WebKit2/CMakeFiles/WebKit2.dir/all] Error 2
make: *** [all] Error 2
sasa@slack141-314:/tmp/DLG/logs/webkitgtk-2.6.3-2$ 

I have build without problems the same versions on my x86-64 machines. Both x86-64 and i686 have slackware-14.1 linux os. I tried also adding -latomic to the cxxflags but have not helped out.

Any comments appreciated.
Comment 4 Alberto Garcia 2014-11-17 23:49:05 PST
(In reply to comment #3)
> Hi I don't know if this is in some way related to this bug, but I'm
> trying to compile this from 2.5.90 up to 2.6.3 ending always at make
> install phase with the same error.

This is how we are doing it in Debian:

http://anonscm.debian.org/cgit/pkg-webkit/webkit.git/tree/debian/patches/atomic_build_fix.patch?id=debian/2.6.2%2bdfsg1-2

It should be fixed in WebKit in a nicer way.
Comment 5 Alberto Garcia 2014-11-18 02:31:24 PST
Created attachment 241773 [details]
Patch

Can you try to build it with this patch? Thanks!
Comment 6 Sasa Ostrouska 2014-11-18 02:43:30 PST
@ Alberto, many thanks, I have used a wrong patch last night , the one from gentoo but its only specific to PPC, so after that I saw the debian patch pointed out by you here. I will retry the build tonight with your latest patch.
Comment 7 Sasa Ostrouska 2014-11-18 17:48:53 PST
Hello Alberto, this is what I get with your patch:

sasa@slack141-314:/tmp/DLG/logs/webkitgtk-2.6.3-3$ cat makeinstall.txt 
[  0%] Built target WebKit2-forwarding-headers
[  1%] Built target WTF
[  1%] Built target LLIntOffsetsExtractor
[ 12%] Built target JavaScriptCore
[ 13%] Built target ANGLESupport
[ 76%] Built target WebCore
[ 77%] Built target WebCorePlatformGTK
[ 78%] Built target fake-generated-webkitdom-headers
[ 84%] Built target GObjectDOMBindings
[ 84%] Built target WebKit2-fake-api-headers
[ 97%] Built target WebKit2
[ 97%] Built target WebKit2WebExtension-4-gir
[ 97%] Built target JavaScriptCore-4-gir
[ 97%] Built target WebKit2-4-gir
[ 97%] Built target gir
[ 97%] Built target jsc
[ 98%] Built target WebCorePlatformGTK2
[ 98%] Built target WebCoreTestSupport
[ 98%] Built target NetworkProcess
[ 98%] Built target PluginProcess
Linking CXX executable ../../bin/WebKitPluginProcess2
CMakeFiles/WebKitPluginProcess2.dir/Platform/IPC/Connection.cpp.o: In function `IPC::Connection::createSyncMessageEncoder(IPC::StringReference, IPC::StringReference, unsigned long long, unsigned long long&)':
Connection.cpp:(.text+0x324): undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/WebKitPluginProcess2] Error 1
make[1]: *** [Source/WebKit2/CMakeFiles/WebKitPluginProcess2.dir/all] Error 2
make: *** [all] Error 2
sasa@slack141-314:/tmp/DLG/logs/webkitgtk-2.6.3-3$ 

I will try to apply also the debian atomic_build_fix.patch to see if with it it builds.
Comment 8 Alberto Garcia 2014-11-19 01:19:50 PST
Created attachment 241850 [details]
Patch

(In reply to comment #7)
> Linking CXX executable ../../bin/WebKitPluginProcess2
> CMakeFiles/WebKitPluginProcess2.dir/Platform/IPC/Connection.cpp.o: In
> function `IPC::Connection::createSyncMessageEncoder(IPC::StringReference,
> IPC::StringReference, unsigned long long, unsigned long long&)':
> Connection.cpp:(.text+0x324): undefined reference to `__atomic_fetch_add_8'
> collect2: error: ld returned 1 exit status

Yeah, I think my previous patch was wrong, try this new one.
Comment 9 Sasa Ostrouska 2014-11-19 12:37:39 PST
@Alberto, many thanks, the build went through with the latest patch.
Comment 10 Alberto Garcia 2014-11-20 04:33:11 PST
Created attachment 241940 [details]
Patch

(In reply to comment #9)
> @Alberto, many thanks, the build went through with the latest patch.

Thanks for confirming it.

I reworked it a bit, instead of checking whether libatomic is
available, this new patch checks if we actually need it.
Comment 11 Sasa Ostrouska 2014-11-20 10:39:35 PST
Ok seems reasonable to me. I will try to apply this patch in the next build I do and will advise you if it went through ok.
Comment 12 Antoine Jacoutot 2014-11-21 05:38:54 PST
(In reply to comment #10)
> Created attachment 241940 [details]
> Patch
> 
> (In reply to comment #9)
> > @Alberto, many thanks, the build went through with the latest patch.
> 
> Thanks for confirming it.
> 
> I reworked it a bit, instead of checking whether libatomic is
> available, this new patch checks if we actually need it.

Hi Alberto. FWIW I tried this patch on OpenBSD/powerpc and it worked great.
Thanks.
Comment 13 Alberto Garcia 2014-11-21 15:00:54 PST
(In reply to comment #12)
> Hi Alberto. FWIW I tried this patch on OpenBSD/powerpc and it worked
> great.  Thanks.

Thanks for testing it!
Comment 14 WebKit Commit Bot 2014-11-24 06:49:24 PST
Comment on attachment 241940 [details]
Patch

Clearing flags on attachment: 241940

Committed r176519: <http://trac.webkit.org/changeset/176519>
Comment 15 WebKit Commit Bot 2014-11-24 06:49:27 PST
All reviewed patches have been landed.  Closing bug.