Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 523840 - net-libs/webkit-gtk - add MIPS N32 support
Summary: net-libs/webkit-gtk - add MIPS N32 support
Status: RESOLVED NEEDINFO
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] GNOME (show other bugs)
Hardware: MIPS Linux
: Normal enhancement (vote)
Assignee: Gentoo Linux Gnome Desktop Team
URL: https://bugs.webkit.org/show_bug.cgi?...
Whiteboard:
Keywords: KEYWORDREQ, NeedPatch
Depends on:
Blocks:
 
Reported: 2014-09-27 08:02 UTC by Tom Li
Modified: 2016-03-09 15:32 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Add MIPS N32 Platform (webkit-gtk-2.4.3-mips-n32-platform.patch,566 bytes, patch)
2014-09-27 08:05 UTC, Tom Li
Details | Diff
Disable fastMalloc() for MIPS N32 (webkit-gtk-2.4.3-mips-n32-malloc.patch,544 bytes, patch)
2014-09-27 08:06 UTC, Tom Li
Details | Diff
debian-fix-mips-build.patch (debian-fix-mips64-build.patch,2.02 KB, patch)
2014-09-30 10:17 UTC, Pacho Ramos
Details | Diff
webkit-gtk-2.4.6-disable-fastMalloc-for-mips.patch (webkit-gtk-2.4.6-disable-fastMalloc-for-mips-n32.patch,643 bytes, patch)
2014-10-09 08:25 UTC, Vicente Olivert Riera (RETIRED)
Details | Diff
webkit-gtk-2.4.6-add-mips64-support.patch (webkit-gtk-2.4.6-fix-mips.patch,2.16 KB, patch)
2014-10-09 08:26 UTC, Vicente Olivert Riera (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Li 2014-09-27 08:02:20 UTC
net-libs/webkit-gtk doesn't play well for MIPS N32.

1. Platform.h refuses to build for N32

The Webkit doesn't treat MIPS N32 as the supported architure. Although the JIT won't
work on MIPS N32, but disable it should be fine.

2. fastMalloc() is broken

Just like IA64, fastMalloc() returns non-aligned address and causes crashing.
Comment 1 Tom Li 2014-09-27 08:05:40 UTC
Created attachment 385582 [details, diff]
Add MIPS N32 Platform
Comment 2 Tom Li 2014-09-27 08:06:04 UTC
Created attachment 385584 [details, diff]
Disable fastMalloc() for MIPS N32
Comment 3 Tom Li 2014-09-27 08:06:58 UTC
The second patch is depends on webkit-gtk-2.4.1-ia64-malloc.patch, need tweak it.
Comment 4 Pacho Ramos gentoo-dev 2014-09-27 13:45:52 UTC
Upstream don't care at all about mips... are this patches shared with any other distribution/people willing to keep webkit in a good shape there?
Comment 5 Anthony Basile gentoo-dev 2014-09-27 15:11:03 UTC
(In reply to Pacho Ramos from comment #4)
> Upstream don't care at all about mips... are this patches shared with any
> other distribution/people willing to keep webkit in a good shape there?

This patch looks very unintrusive and is based on the IA64 fix.  I should be easy to maintain and could be applied even uncondtionally (ie we don't need if use mips).  The benefit would be we can finally compile apps depending on webkit-gtk.

Before we add it, I'd like to know from Tom Li what plagtform he tested on?  Was it the lemote yeeloong?  And what apps he was able to build afterwards.

I'll take responsibility for keeping that patch up if we do add it.
Comment 6 Pacho Ramos gentoo-dev 2014-09-27 16:18:35 UTC
In that case nice :D

But we need to know if that apps are buildable and really *work* (probably disabling "jit"). I think that is not the case for ia64 and probably others... but we would need to drop so many keywords :| (and, well, some apps like evolution-3.12 still "work" because it's not fully migrated to webkit yet...)
Comment 7 Anthony Basile gentoo-dev 2014-09-27 16:37:17 UTC
(In reply to Pacho Ramos from comment #6)
> In that case nice :D
> 
> But we need to know if that apps are buildable and really *work* (probably
> disabling "jit"). I think that is not the case for ia64 and probably
> others... but we would need to drop so many keywords :| (and, well, some
> apps like evolution-3.12 still "work" because it's not fully migrated to
> webkit yet...)

Precisely, which is why I'd like to know the platform and what was tested.  I will reproduce those tests at my end.
Comment 8 Gilles Dartiguelongue (RETIRED) gentoo-dev 2014-09-27 17:19:31 UTC
The patch looks small enough, so if you get the go from mips, I'm fine with it.
Comment 9 Matt Turner gentoo-dev 2014-09-27 17:41:05 UTC
Can we enable N64 ABI support as well, so we can keyword ~mips without caveats?
Comment 10 Pacho Ramos gentoo-dev 2014-09-28 12:03:57 UTC
I see no issues at all :)

I was simply trying to ensure we won't need to drop it on the next version bump when people in mips starts to rely on webkit (in general, I tend to review patches from openBSD and Debian to try to follow a common pathway with them and, also, try to report a bug upstream (bugzilla.webkit.org) if none exists to, at least, let them know)
Comment 11 Anthony Basile gentoo-dev 2014-09-28 14:22:37 UTC
(In reply to Matt Turner from comment #9)
> Can we enable N64 ABI support as well, so we can keyword ~mips without
> caveats?

(In reply to Tom Li from comment #1)
> Created attachment 385582 [details, diff] [details, diff]
> Add MIPS N32 Platform

When I test I'll just change 

+    && (defined(_ABIO32) || defined(_ABIN32))

to

+    && (defined(_ABIO32) || defined(_ABIN32) || defined(_ABIN64))


I'd still like to hear back from the original report Tom Li.  What platform was used and what consumers of webkit-gtk were tested?
Comment 12 Tom Li 2014-09-30 09:15:23 UTC
> I'd like to know the platform and what was tested. And what apps he was able to build afterwards.

I tested on Lemote Yeeloong with Loongson 2F processor. 

After apply the patches, I can use ANY webkit-gtk based programs such as midori, yelp, uzbl, both GTK2 and GTK3 branches are working correctly.

> try to report a bug upstream (bugzilla.webkit.org) if none exists to, at least, let them know

https://bugs.webkit.org/show_bug.cgi?id=29954

It provided a similar hack for <Platform.h> and mentioned the crashing problem. But years passed, it is still no progress. 

I think there should be more bug reports, I read at least three bug reports when I try to make it works. Also, some Debian developers fixed some of the memory alignment issues
on MIPS. But I can't find all of them now :(

BTW, webkit is still buggy, if I compile the Linux kernel with 64KB instead of 16KB page size, webkit may crash. I read the git log, and it seems the previous patches in webkit was not a complete fix, and developers never test it on 64KB page size kernel. It is another problem and should discuss at the Webkit Bugzilla.

> Upstream don't care at all about mips...

Absolutely.

> Can we enable N64 ABI support as well

It may work. But I'll never use it. The ecosystem for MIPS N64 is terrible, many programs don't work properly. Before there is any tester, nobody knows if it actually works.
Comment 13 Pacho Ramos gentoo-dev 2014-09-30 10:16:04 UTC
Thanks for all the work and testing :)
Comment 14 Pacho Ramos gentoo-dev 2014-09-30 10:17:08 UTC
Created attachment 385818 [details, diff]
debian-fix-mips-build.patch

This is the only mips related patch I found in Debian
Comment 16 Anthony Basile gentoo-dev 2014-10-07 18:01:16 UTC
I didn't get to clean those patches up.  Note we have 2.2.6, 2.4.4 and 2.4.6.  The original patches were for 2.4.3 and didn't apply cleanly.  I didn't identify work out the equivalent for 2.4.4.  (Running low on time due to real life!)
Comment 17 Vicente Olivert Riera (RETIRED) gentoo-dev 2014-10-09 08:24:43 UTC
Hello,

I have cleaned the patches and now the apply for webkit-gtk-2.4.6, and they work fine:

# emerge -1Oq =net-libs/webkit-gtk-2.4.6

 * IMPORTANT: 1 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.

>>> Verifying ebuild manifests
>>> Running pre-merge checks for net-libs/webkit-gtk-2.4.6
>>> Emerging (1 of 1) net-libs/webkit-gtk-2.4.6::gentoo
>>> Installing (1 of 1) net-libs/webkit-gtk-2.4.6::gentoo

Patches attached in the two comments below.
Comment 18 Vicente Olivert Riera (RETIRED) gentoo-dev 2014-10-09 08:25:49 UTC
Created attachment 386280 [details, diff]
webkit-gtk-2.4.6-disable-fastMalloc-for-mips.patch
Comment 19 Vicente Olivert Riera (RETIRED) gentoo-dev 2014-10-09 08:26:58 UTC
Created attachment 386282 [details, diff]
webkit-gtk-2.4.6-add-mips64-support.patch
Comment 20 Vicente Olivert Riera (RETIRED) gentoo-dev 2014-10-20 13:55:19 UTC
I have installed www-client/midori[webkit2] which consumes net-libs/webkit-gtk:3 and this is what happens when I try to run it:

$ midori 
Gtk-Message: Failed to load module "pk-gtk-module"
Gtk-Message: Failed to load module "canberra-gtk-module"
The configuration couldn't be loaded: No such file or directory
Bus error

The last line is the one which is actually causing the problem. However, I have installed app-admin/packagekit-gtk and media-libs/libcanberra just in case. Then, when I try to run it again, I get the following:

$ midori
The configuration couldn't be loaded: No such file or directory
Bus error
Error receiving IPC message on socket -1 in process 31902: Bad file descriptor

It seems the last line (the one about the IPC message on socket) it's only a log line which is not fatal, and the real problem stills being the "Bus error" line. And I think it's a webkit problem because I have tried to use the Javascript console provided by webkit and this is what happened:

$ jsc-3 
>>> "hello"
Bus error
Comment 21 Matt Turner gentoo-dev 2014-10-20 16:35:12 UTC
(In reply to Vicente Olivert Riera from comment #20)
> Bus error

This means unaligned access.
Comment 22 Anthony Basile gentoo-dev 2014-10-20 17:27:29 UTC
(In reply to Matt Turner from comment #21)
> (In reply to Vicente Olivert Riera from comment #20)
> > Bus error
> 
> This means unaligned access.

Why am I not surprised.  Why isn't the kernel handling this?  Poor alignment should be a perf hit, but not kill a process.
Comment 23 Anthony Basile gentoo-dev 2014-10-20 17:33:04 UTC
(In reply to Vicente Olivert Riera from comment #20)
> 
> $ jsc-3 
> >>> "hello"
> Bus error

Can you run this in gdb and get a backtrace so we can at least see what's causing the bus error.
Comment 24 Tom Li 2014-10-21 13:08:01 UTC
> $ jsc-3 
> >>> "hello"
> Bus error

This is the problem which is fixed by the patches, but...why?
Comment 25 Tom Li 2014-10-21 13:14:26 UTC
(In reply to Anthony Basile from comment #22)
> (In reply to Matt Turner from comment #21)
> > (In reply to Vicente Olivert Riera from comment #20)
> > > Bus error
> > 
> > This means unaligned access.
> 
> Why am I not surprised.  Why isn't the kernel handling this?  Poor alignment
> should be a perf hit, but not kill a process.

All address on MIPS must be aligned. Unaligned access could cause serious problem on MIPS, even kernel doesn't have chance to handle all of them in the current implementation. There was some patches to let kernel handle more unaligned access, but no one accept it.
Comment 26 Vicente Olivert Riera (RETIRED) gentoo-dev 2014-10-23 10:38:05 UTC
(In reply to Anthony Basile from comment #23)
> (In reply to Vicente Olivert Riera from comment #20)
> > 
> > $ jsc-3 
> > >>> "hello"
> > Bus error
> 
> Can you run this in gdb and get a backtrace so we can at least see what's
> causing the bus error.

# gdb jsc-3
GNU gdb (Gentoo 7.7 p1) 7.7
[...]
Reading symbols from jsc-3...Reading symbols from /usr/lib/debug//usr/bin/jsc-3.debug...done.
done.
(gdb) run
Starting program: /usr/bin/jsc-3 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib32/libthread_db.so.1".
[New Thread 0x75cce470 (LWP 22999)]
[New Thread 0x753aa470 (LWP 23000)]
>>> "hello"

Program received signal SIGBUS, Bus error.
0x77bf7ff4 in JSC::ExecutionCounter::deferIndefinitely() () from /usr/lib32/libjavascriptcoregtk-3.0.so.0
(gdb) bt
#0  0x77bf7ff4 in JSC::ExecutionCounter::deferIndefinitely() () from /usr/lib32/libjavascriptcoregtk-3.0.so.0
#1  0x77ca22f8 in llint_entry_osr () from /usr/lib32/libjavascriptcoregtk-3.0.so.0
#2  0x77cb0cb0 in JSC::LLInt::CLoop::execute(JSC::ExecState*, void*, bool) () from /usr/lib32/libjavascriptcoregtk-3.0.so.0
#3  0x77cb0354 in callToJavaScript () from /usr/lib32/libjavascriptcoregtk-3.0.so.0
#4  0x77ca0e08 in JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*, JSC::Register*) () from /usr/lib32/libjavascriptcoregtk-3.0.so.0
#5  0x77c9c40c in JSC::Interpreter::execute(JSC::ProgramExecutable*, JSC::ExecState*, JSC::JSObject*) () from /usr/lib32/libjavascriptcoregtk-3.0.so.0
#6  0x77d8c3a4 in JSC::evaluate(JSC::ExecState*, JSC::SourceCode const&, JSC::JSValue, JSC::JSValue*) () from /usr/lib32/libjavascriptcoregtk-3.0.so.0
#7  0x10008cc4 in jscmain(int, char**) ()
#8  0x10004730 in main ()
(gdb)
Comment 27 Pacho Ramos gentoo-dev 2015-01-23 17:32:12 UTC
Looks like the patches weren't really working no? :|