Re: Building WebKit natives with debug symbols on 32 bit Linux

2014-06-06 Thread Peter Levart

Hi David,

Thanks for pointing me in the right direction. Although I've almost lost 
hope before finally succeeding. I tried various other approaches on the 
way, but finally, what I did was very simple. It could be possible to 
create a separate configuration (i.e. LINUX32) with some additional 
tweaks to some other scripts (some scripts use the configuration name as 
a logic token), but here I present a simpler variant with changes 
applied to current LINUX configuration.


In order to cross-compile on 64 bit Ubuntu 14.04 for 32 bit Linux target 
you need to patch some makefiles and build scripts:


http://cr.openjdk.java.net/~plevart/openjfx-8u-dev-rt/linux32on64tools/webrev.01/

Besides above changes to build scripts, the following environment 
variables have to be defined (in $HOME/.profile):


JAVA_HOME=/path/to/32bit/jdk
PATH=$JAVA_HOME/bin:$PATH
PKG_CONFIG_LIBDIR=/usr/lib/i386-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
QMAKESPEC=linux-g++-32
export JAVA_HOME PATH PKG_CONFIG_LIBDIR QMAKESPEC

You need to install the i386 versions of runtime libraries needed to 
execute the 32 bit JVM. I don't have the names at hand, but the list 
could quickly be compiled by trying to run some Java GUI program using 
32 bit JVM and then using apt-file on the missing library file to 
find-out the name of the package. /Wash, rinse, repeat.../ until all 
i386 JDK runtime dependencies are installed.


In addition, i386 versions of *-dev packages needed for compiling 
openjfx have to be installed. This is the most tricky part to get right, 
since installing them pulls-in some i386 runtime library dependencies 
which conflict with x86_64 versions of libraries that might already be 
installed on 64 bit system. "apt-get install" is clever on Ubuntu 14.04 
and *REMOVES* the installed dependency sub-tree of x86_64 packages 
before installing a conflicting i386 version of requested package. For 
some of *-dev:i386 packages this means that even the tools needed for 
building (gcc, binutils) get de-installed, but you can re-install them 
later without conflicts (that's strange, but APT packaging seem to work 
with at least 3 levels of dependency strengths). The most important part 
is that the following packages:


gcc, gcc-4.8, g++, g++-48, binutils (with dependencies)

are kept at x86_64 architecture (that's the whole purpose of 
cross-compilation). In addition, you also need to install the following 
packages, to be able to produce 32bit binaries with 64bit tools:


gcc-multilib, gcc-4.8-multilib, g++-multilib, g++-4.8-multilib


I think that's all. With this changes I managed to produce 32 bit 
libjfxwebkit.so with debugging symbols included (it's nearly 1.7 GiB 
!!!). You need at least 10 GiB of free RAM when attempting such build 
(the "ld" process grows to about 8 GiB of resident space when collecting 
object files into a shared library - no wonder it can't be done with 32 
bit "ld").


With 32bit debug build of openjfx I reproduced the crash mentioned in 
(https://javafx-jira.kenai.com/browse/RT-33599) and got the following 
backtrace from gdb:


...
...
#7  
#8  0x6591cc7e in WTFCrash () at 
../../../../src/main/native/Source/WTF/wtf/Assertions.cpp:345
#9  0x65950c3f in WTF::OSAllocator::reserveUncommitted (bytes=126976, 
usage=WTF::OSAllocator::UnknownUsage, writable=true, executable=false, 
includesGuardPages=false)

at ../../../../src/main/native/Source/WTF/wtf/OSAllocatorPosix.cpp:58
#10 0x65ac9033 in WTF::PageAllocationAligned::allocate (size=65536, 
alignment=65536, usage=WTF::OSAllocator::UnknownUsage, writable=true)
at 
../../../../src/main/native/Source/WTF/wtf/PageAllocationAligned.cpp:55
#11 0x65b5bff7 in JSC::DFG::Allocator::allocateSlow 
(this=0x70df9f78) at 
../../../../src/main/native/Source/JavaScriptCore/dfg/DFGAllocator.h:204
#12 0x65b5a7c0 in JSC::DFG::Allocator::freeListAllocate 
(this=0x70df9f78) at 
../../../../src/main/native/Source/JavaScriptCore/dfg/DFGAllocator.h:190
#13 0x65b58e4a in JSC::DFG::Allocator::allocate 
(this=0x70df9f78) at 
../../../../src/main/native/Source/JavaScriptCore/dfg/DFGAllocator.h:109
#14 0x65b53d53 in operator new (size=84, allocator=...) at 
../../../../src/main/native/Source/JavaScriptCore/dfg/DFGNodeAllocator.h:45
#15 0x65b5bbb1 in JSC::DFG::Graph::addNodeJSC::CodeOrigin, JSC::DFG::OpInfo> (this=0x68a9effc, type=0, 
_DFG_value1=@0x68a9de3c: JSC::DFG::Phi,
_DFG_value2=..., _DFG_value3=...) at 
../../../../src/main/native/Source/JavaScriptCore/dfg/DFGGraph.h:166
#16 0x65ce34a7 in JSC::DFG::CPSRethreadingPhase::addPhiSilently 
(this=0x68a9dfd8, block=0x88d5970, codeOrigin=..., variable=0x89501b0)
at 
../../../../src/main/native/Source/JavaScriptCore/dfg/DFGCPSRethreadingPhase.cpp:133
#17 0x65ce532c in 
JSC::DFG::CPSRethreadingPhase::addPhi<(JSC::OperandKind)1> 
(this=0x68a9dfd8, block=0x88d5970, codeOrigin=..., variable=0x89501b0, 
index=5)
at 
../../../../src/main/native/Source/JavaScriptCore/dfg/DFGCPSRethreadi

Re: Building WebKit natives with debug symbols on 32 bit Linux

2014-05-28 Thread Kevin Rushforth
Note that there is a bug filed on building webkit with debug symbols on 
Windows/32 and Linux/32:


https://javafx-jira.kenai.com/browse/RT-36147

If you have a 64-bit Linux system, then it should work.

-- Kevin


David Hill wrote:

On 5/28/14, May 28, 9:47 AM, Peter Levart wrote:

Hi Again,

The idea that comes to my mind is the following: would it be possible 
to cross-compile the openjfx on the 64 bit Linux using 64 bit tools, 
but targeted at 32 bit Linux? What would have to be changed in build 
environment to accomplish that? I imagine the environment would have 
to have access to headers and development libraries of the 32 bit 
Linux system - that's no problem - I would just mount the root of a 
32 bit Ubuntu to some directory, but then I would have to force all 
tools to use that path instead of the running system one. And the gcc 
would have to be given some cross-compiling options too, I guess...



In theory this is easy :-)

We already have a cross compile mechanism in gradle, used for the 
Linux arm and Android builds. (see buildSrc/armv* for example).


You would start with one of the build files as a template - 
linux.gradle, sed/copy it to linux32.gradle  with something like:


cd buildSrc
sed -s 's/LINUX/LINUX32/' linux.gradle > linux32.gradle

After that, it would be a matter of tweaking the cc and ld flags 
contained in the file, to tell gcc to be 32bit and to use the right 
libraries. Looks like adding -m32 to commonFlags is all it should need:


// A set of common parameters to use for both compiling and linking
def commonFlags = [
"-m32",  // < 32 bit output
"-fno-strict-aliasing", "-fPIC", "-fno-omit-frame-pointer", // 
optimization flags
"-W", "-Wall", "-Wno-unused", "-Wno-parentheses", 
"-Werror=implicit-function-declaration"] // warning flags


and tweak where the libraries are installed:

// Libraries end up in the sdk/rt/lib/$OS_ARCH directory for Linux
LINUX32.libDest = "lib/i386"
LINUX32.arch = "i386"  # << this is an addition not needed in 
linux.gradle


You specify the crossbuild like this:
gradle  -PUSE_DEPEND=false -PBUILD_NATIVES=true 
-PCOMPILE_TARGETS=linux32


But...
   looks like we need to disable
LINUX32.compileFXPackager = false;
because build.gradle has some stuff hardcoded in it (would need a jira 
for that if people care).


And - you need the i386 development packages installed. I had already 
added this to get my cross compilers to work,

apt-get install libstdc++6:i386
but needed to add other to get more of the build to complete and ran 
into apt-get telling me all my i386 deps were broken. Perhaps it would 
work better if I was on a newer distro (I am on 12.04)

https://wiki.openjdk.java.net/display/OpenJFX/Building+OpenJFX
has the list of packages, in theory, you just need to add :i386 to 
each one.


Since I can't get the i386 packages, at this point you are on your own 
:-)


Dave



Peter

On 05/28/2014 03:39 PM, Peter Levart wrote:

Hi,

I'm new to this list and I have searched the archives, but haven't 
found a discussion about this. If I have missed it, please just 
direct me to the archived thread.


I'm trying to debug a crash in a native part of WebKit-JavaFX 
bindings (https://javafx-jira.kenai.com/browse/RT-33599). I have 
only been able to reproduce it on 32 bit platforms (Windows and 
Linux so far). I'm trying to build the WebKit natives with debugging 
symbols, so that I can pin-point the location of the crash in code 
using gdb. I have managed to do this successfully on 64 bit Linux, 
producing 1.7 GB large libjfxwebkit.so. But on 32 bit Linux, where 
only I can reproduce the crash, the build fails with linker error: 
"memory exhausted" when trying to assemble the libjfxwebkit.so from 
object files. So far I have not been successful in my attempts to 
circumvent this build error. I fave tried the following:


- added '--no-keep-memory' to linker options. The man page says 
about it:
   ld normally optimizes for speed over memory usage by 
caching the symbol tables of input files in memory.  This option 
tells ld to instead optimize for memory usage, by
   rereading the symbol tables as necessary.  This may be 
required if ld runs out of memory space while linking a large 
executable.


- booted the 64bit Ubuntu system and chrooted into a 32 bit 
environment. Some say that with 64 bit kernel, each 32 bit 
user-space process has more address space than with 32 bit kernel.


- both of the above


My question to the list is: How do you guys produce 32 bit 
libjfxwebkit.so with debugging symbols? Have you been able to? Do 
you have any special tricks in your sleeves?



Regards,

Peter








Re: Building WebKit natives with debug symbols on 32 bit Linux

2014-05-28 Thread David Hill

On 5/28/14, May 28, 9:47 AM, Peter Levart wrote:

Hi Again,

The idea that comes to my mind is the following: would it be possible to 
cross-compile the openjfx on the 64 bit Linux using 64 bit tools, but targeted 
at 32 bit Linux? What would have to be changed in build environment to 
accomplish that? I imagine the environment would have to have access to headers 
and development libraries of the 32 bit Linux system - that's no problem - I 
would just mount the root of a 32 bit Ubuntu to some directory, but then I 
would have to force all tools to use that path instead of the running system 
one. And the gcc would have to be given some cross-compiling options too, I 
guess...


In theory this is easy :-)

We already have a cross compile mechanism in gradle, used for the Linux arm and 
Android builds. (see buildSrc/armv* for example).

You would start with one of the build files as a template - linux.gradle, 
sed/copy it to linux32.gradle  with something like:

cd buildSrc
sed -s 's/LINUX/LINUX32/' linux.gradle > linux32.gradle

After that, it would be a matter of tweaking the cc and ld flags contained in 
the file, to tell gcc to be 32bit and to use the right libraries. Looks like 
adding -m32 to commonFlags is all it should need:

// A set of common parameters to use for both compiling and linking
def commonFlags = [
"-m32",  // < 32 bit output
"-fno-strict-aliasing", "-fPIC", "-fno-omit-frame-pointer", // 
optimization flags
"-W", "-Wall", "-Wno-unused", "-Wno-parentheses", 
"-Werror=implicit-function-declaration"] // warning flags

and tweak where the libraries are installed:

// Libraries end up in the sdk/rt/lib/$OS_ARCH directory for Linux
LINUX32.libDest = "lib/i386"
LINUX32.arch = "i386"  # << this is an addition not needed in linux.gradle

You specify the crossbuild like this:
gradle  -PUSE_DEPEND=false -PBUILD_NATIVES=true -PCOMPILE_TARGETS=linux32

But...
   looks like we need to disable
LINUX32.compileFXPackager = false;
because build.gradle has some stuff hardcoded in it (would need a jira for that 
if people care).

And - you need the i386 development packages installed. I had already added 
this to get my cross compilers to work,
apt-get install libstdc++6:i386
but needed to add other to get more of the build to complete and ran into 
apt-get telling me all my i386 deps were broken. Perhaps it would work better 
if I was on a newer distro (I am on 12.04)
https://wiki.openjdk.java.net/display/OpenJFX/Building+OpenJFX
has the list of packages, in theory, you just need to add :i386 to each one.

Since I can't get the i386 packages, at this point you are on your own :-)

Dave



Peter

On 05/28/2014 03:39 PM, Peter Levart wrote:

Hi,

I'm new to this list and I have searched the archives, but haven't found a 
discussion about this. If I have missed it, please just direct me to the 
archived thread.

I'm trying to debug a crash in a native part of WebKit-JavaFX bindings 
(https://javafx-jira.kenai.com/browse/RT-33599). I have only been able to reproduce it on 
32 bit platforms (Windows and Linux so far). I'm trying to build the WebKit natives with 
debugging symbols, so that I can pin-point the location of the crash in code using gdb. I 
have managed to do this successfully on 64 bit Linux, producing 1.7 GB large 
libjfxwebkit.so. But on 32 bit Linux, where only I can reproduce the crash, the build 
fails with linker error: "memory exhausted" when trying to assemble the 
libjfxwebkit.so from object files. So far I have not been successful in my attempts to 
circumvent this build error. I fave tried the following:

- added '--no-keep-memory' to linker options. The man page says about it:
   ld normally optimizes for speed over memory usage by caching the 
symbol tables of input files in memory.  This option tells ld to instead 
optimize for memory usage, by
   rereading the symbol tables as necessary.  This may be required if 
ld runs out of memory space while linking a large executable.

- booted the 64bit Ubuntu system and chrooted into a 32 bit environment. Some 
say that with 64 bit kernel, each 32 bit user-space process has more address 
space than with 32 bit kernel.

- both of the above


My question to the list is: How do you guys produce 32 bit libjfxwebkit.so with 
debugging symbols? Have you been able to? Do you have any special tricks in 
your sleeves?


Regards,

Peter






--
David Hill 
Java Embedded Development

"A computer lets you make more mistakes faster than any invention in human history - 
with the possible exceptions of handguns and tequila"



Re: Building WebKit natives with debug symbols on 32 bit Linux

2014-05-28 Thread Richard Bair
> My question to the list is: How do you guys produce 32 bit libjfxwebkit.so 
> with debugging symbols? Have you been able to? Do you have any special tricks 
> in your sleeves?

Oh man, you’re in unchartered waters. Building webkit is a royal pain in the 
neck :-(. You’ve already ventured farther than I have. Maybe Peter Z. or one of 
the guys on our team (in Russia) who have been working more with webkit will 
have a good answer, but in general most people on the FX team don’t even build 
webkit, we just use the bits provided in the weekly builds.

Richard

Re: Building WebKit natives with debug symbols on 32 bit Linux

2014-05-28 Thread Peter Levart

Hi Again,

The idea that comes to my mind is the following: would it be possible to 
cross-compile the openjfx on the 64 bit Linux using 64 bit tools, but 
targeted at 32 bit Linux? What would have to be changed in build 
environment to accomplish that? I imagine the environment would have to 
have access to headers and development libraries of the 32 bit Linux 
system - that's no problem - I would just mount the root of a 32 bit 
Ubuntu to some directory, but then I would have to force all tools to 
use that path instead of the running system one. And the gcc would have 
to be given some cross-compiling options too, I guess...


Peter

On 05/28/2014 03:39 PM, Peter Levart wrote:

Hi,

I'm new to this list and I have searched the archives, but haven't 
found a discussion about this. If I have missed it, please just direct 
me to the archived thread.


I'm trying to debug a crash in a native part of WebKit-JavaFX bindings 
(https://javafx-jira.kenai.com/browse/RT-33599). I have only been able 
to reproduce it on 32 bit platforms (Windows and Linux so far). I'm 
trying to build the WebKit natives with debugging symbols, so that I 
can pin-point the location of the crash in code using gdb. I have 
managed to do this successfully on 64 bit Linux, producing 1.7 GB 
large libjfxwebkit.so. But on 32 bit Linux, where only I can reproduce 
the crash, the build fails with linker error: "memory exhausted" when 
trying to assemble the libjfxwebkit.so from object files. So far I 
have not been successful in my attempts to circumvent this build 
error. I fave tried the following:


- added '--no-keep-memory' to linker options. The man page says about it:
   ld normally optimizes for speed over memory usage by 
caching the symbol tables of input files in memory.  This option tells 
ld to instead optimize for memory usage, by
   rereading the symbol tables as necessary.  This may be 
required if ld runs out of memory space while linking a large executable.


- booted the 64bit Ubuntu system and chrooted into a 32 bit 
environment. Some say that with 64 bit kernel, each 32 bit user-space 
process has more address space than with 32 bit kernel.


- both of the above


My question to the list is: How do you guys produce 32 bit 
libjfxwebkit.so with debugging symbols? Have you been able to? Do you 
have any special tricks in your sleeves?



Regards,

Peter