On Fri, Jun 24, 2011 at 5:49 AM, Wookey <wookey@wookware.org> wrote:
+++ Marc-André Moreau [2011-06-23 17:40 -0400]:

[I wrote a response to this for 4hrs last night then my mail server
crashed and lost it all - <mutter>. trying agin...]

> Hi,
>
> I am Marc-Andre from the FreeRDP project, an open source RDP client. I want to
> work on optimizing FreeRDP for ARM using the NEON processor extensions.

Welome

> It is my first time cross-compiling, so thank you for your understanding.

Welcome to the joyful world of cross-building :-)

Hehe, thank you for the long detailed answer, it is really appreciated :)

> I have asked some questions on IRC, and read various pages from the wiki, but I
> haven't managed to successfully cross-compile FreeRDP yet. Compiling directly
> on the pandaboard works, but it is atrociously slow. I have made a chroot
> environment following and adapting the instructions from the following wiki
> page: https://wiki.linaro.org/Platform/DevPlatform/CrossCompile/UsingXdeb

Nothing wrong with this method, and it is reliable, but I find it
quicker and easier to use multistrap and do:
multistrap -f

Will look into that, it could save me time 

> I have tried both xdeb and xapt, both causing problems.

> xapt:
>
> I managed to fetch and convert packages with xapt, using the following command:
> sudo xapt -a armel -k -b --suite natty --mirror http://ports.ubuntu.com/
> libssl-dev libx11-dev libxv-dev libxkbfile-dev libxcursor-dev libasound2-dev
> libxcb1 libxcb1-dev libdirectfb-dev libc6 libc6-dev zlib1g zlib1g-dev
>
> The problem is then that xapt will fail to install the converted packages,
> saying the package architecture is different from the current architecture, as
> well as missing dependencies. I worked around the problem with this ugly hack:
>
> cd /var/lib/xapt/output/
> sudo dpkg -i --force-all *.deb

You are suffering from this problem:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=629595 which is
because we are in the middle of a transition to multiarch packages.
When xapt/dpkg-cross were written it was assumed that thay would
simply ignore multiarched packages. However in practice it turns out
that that's not the case and currently they need to be converted back
to old-style locations. that needs the -m option supplying to xapt.
The version in natty is too old to have option.

So if you do sudo xapt -a armel -b libssl-dev libx11-dev libxv-dev \
libxkbfile-dev libxcursor-dev libasound2-dev libxcb1 libxcb1-dev \
libdirectfb-dev libc6 libc6-dev zlib1g zlib1g-dev libcups2-dev

on a wheezy box/chroot then all that stuff get downloaded, converted
and installed correctly.

Ok, so I should assume that this stuff is broken for pretty much anyone using natty? 

> Following this, I could get the FreeRDP configure script to work, even though
> it would fail to detect X11 properly:
>
> PKG_CONFIG_PATH=/usr/arm-linux-gnueabi/lib/pkgconfig ./configure --host=
> arm-linux-gnueabi --with-neon

X11 is detected OK for me:
FreeRDP configure result:

Cryptography : openssl
TLS          : enabled
Sound        : yes
Printer      : no
CUnit        : no
X11          : yes
DirectFB     : no


> When trying to build after that, it will still fail to link in the end,
> complaining about missing libraries such as zlib, X11, crypto, etc. I tried
> installing various packages more with xapt, but I couldn't get it to work.

If I do PKG_CONFIG_LIBDIR=/usr/arm-linux-gnueabi/lib/pkgconfig dpkg-buildpackage -aarmel

then it all builds OK (on wheezy), except that the printer support is
not found. The confiure script needs checking to find out why that's
failing. That path-setting shouldn't be neeed either but it's not
working without it, even with the cross-version of pkg-config
installed. Again, needs further investigation.

You can work round the cups non-identificatin with
HAVE_CUPS=1 PKG_CONFIG_LIBDIR=/usr/arm-linux-gnueabi/lib/pkgconfig dpkg-buildpackage -aarmel

I can deal with the fact that CUPS support is broken, I mainly need to get the basic stuff working so that I can optimize graphical rendering, but that's good to know :P 

To get this working on natty you would need to get the current xapt, an
ubuntu port of which is available here:

http://wookware.org/software/repo/ natty main
or just here:
http://wookware.org/software/repo/pool/main/e/emdebian-crush/xapt_2.2.16ubuntu1_all.deb

however there is then a link failure, when it tries to link the wrong
arch of libpthread.so:
/usr/lib/gcc/arm-linux-gnueabi/4.5.2/../../../../arm-linux-gnueabi/bin/ld:
skipping incompatible /usr/lib/x86_64-linux-gnu/libpthread.so when searching for -lpthread
/usr/lib/x86_64-linux-gnu/libpthread.a: could not read symbols: File format not recognized
collect2: ld returned 1 exit status

If I understand correctly, xapt is broken on natty, so I could give this build of xapt a try, but then when trying to build FreeRDP I'll still have the problem described above? 

Again - needs looking into.

> xdeb:
>
> I tried the following:
> root@workstation:/# xdeb -a armel --prefer-apt libssl-dev libx11-dev libxv-dev
> libxkbfile-dev libxcursor-dev libasound2-dev
>...
> No source package found: libssl-dev
>
> Or, alternatively, the following:
> root@workstation:/# xdeb -a armel --convert libssl-dev libx11-dev libxv-dev
> libxkbfile-dev libxcursor-dev libasound2-dev
>..
> IOError: [Errno 2] No such file or directory: './libssl-dev'
>
> Here is my sources.list file:
> root@workstation:/# cat /etc/apt/sources.list
> deb http://archive.ubuntu.com/ubuntu natty main universe
> deb-src http://archive.ubuntu.com/ubuntu natty main universe
> deb [arch=armel] http://ports.ubuntu.com/ natty main universe
> deb-src [arch=armel] http://ports.ubuntu.com/ natty main universe

That looks OK (except the last line should be:
deb-src http://ports.ubuntu.com/ natty main universe
(It doesn't actually break anything - just makes no sense - Have I
left that in a doc somewhere?)

Hum... not sure where I read that, are you referring to the [arch=armel] part? I read in certain places that it was something new that should be there, but it didn't change anything. 

So for xdeb you want this command:

xdeb -a armel --prefer-apt --only-explicit freerdp

On wheezy that dies quickly with a package conflict:
he following packages have unmet dependencies:
 heimdal-dev : Conflicts: libkrb5-dev but 1.9.1+dfsg-1+b1 is to be
installed
 libdb-dev : Depends: libdb5.1-dev but it is not going to be installed
            Conflicts: libdb4.8-dev but 4.8.30-8 is to be installed
 libdb4.8-dev : Conflicts: libdb-dev but 5.1.4 is to be installed
 libkrb5-dev : Conflicts: heimdal-dev but 1.4.0-6 is to be installed
 unixodbc-dev : Conflicts: libiodbc2-dev but 3.52.7-2 is to be installed
 E: Broken packages

Not sure what's going on there, but it's not much use.

On natty things go much better and it downloads, crosses and builds a
load of stuff until falling over with :

pkg-deb: building package libosmesa6-armel-cross' in ./libosmesa6-armel-cross_7.10.2-0ubuntu2_all.deb'.
dpkg-cross: package libegl1-mesa-drivers doesn't provide any useful files. Skipping.

Which is due to this bug:
https://bugs.launchpad.net/ubuntu/+source/xdeb/+bug/731079
(xdeb stops if it comes across a package it thought it should cross
which is in fact dpkg-cross 'NULL'). This is rather annoying and I
think I have a fix mostly-done but it's not merged yet - need to check
where that got to. You can fix it by adding the offending package to
the xdeb blacklist )that's how it currently expects to work):
so add libosmesa6 to /etc/xdeb/xdeb.conf in the 'blacklist' section.

However after doing that it doesn't get much further before:
.:terminate called after throwing an instance of 'std::out_of_range'

> I'm stuck at this point. Can anybody point me towards possible solution paths
> on how to cross-compile FreeRDP for ARM, given the above information?

So, the easiest way to get cross-building is to do it on a debian
wheezy machine/chroot where the tools and build work OK. As you want
to do neon dev then you may need to install a new-enough
cross-toolchain, which probably means a linaro one.

I see the linaro wiki and website refer to ubuntu a lot, and not necessarily debian. There is also much more support and documentation for ubuntu rather than debian for the pandaboard. I understand it would be much easier to get it to compile in the first place with debian wheezy, but I would prefer staying with ubuntu, if it is possible. I tried just tried xapt in oneiric, it doesn't seem to be fixed :( Besides xapt, what would be seriously broken in ubuntu natty? Maybe I could just compile the latest version of xapt myself on natty?

I'll look into the natty build failures and see if we can get that
going for you. This is clearly a package that ought to cross OK.

So, now you know why people native-build :-) there are an awful lot
fewer things to go wrong and the tools are much more mature. There is
plenty of work going on at the moment to improve the situation, and at
least your source package is farily well-behaved (many aren't). It
does look like it needs a couple of fixes though so a plain
dpkg-buildpackage -aarmel would work as expected.

So, is a wheezy-based build sufficient for you for the time being? Or
do you have to have it building on natty to do useful dev?

My main problem would be debian support on the pandaboard which is much less documented than ubuntu. I'd prefer working around the various issues found in natty and work with natty instead, if we can work around all the current problems. If it's just too much of a pain, I'll have to give wheezy a try, but I don't think it'll be as easy to get wheezy up and running on the pandaboard. 

Wookey
--
Principal hats:  Linaro, Emdebian, Wookware, Balloonboard, ARM
http://wookware.org/