Cross toolchain

Identify issues

Source

Handling cross compiler versions/defaults

For now cross gcc uses update-alternatives to select default version. Since my (Marcin) changes landed in gcc-4.[45] versions (also in gcc-4.6 now) the newest version is selected by default. This affects Debian where 4.4 is default and 4.5 can be provided. In Ubuntu it is solved by 'gcc-defaults-armel-cross' package.

Marcin notes

Status

Currently we have two ways of doing cross toolchain in Debian/Ubuntu world:

EmDebian way

Should work in any Debian derived distribution due to simpleness of it. The problem is that it is manual process which can be automated but is still impossible to do on buildd - and as such it can not be added into Debian repository. EmDebian developers solved that by having daemon which rebuilds toolchain packages after their updates in Debian archive.

Another problem is manual fetching of eglibc and linux packages fortarget arch. But this part can be solved by using multiarch capable APT (apt-get -o APT::architecture=armel download libc6-dev).

Ubuntu way

Ubuntu way handles building of cross toolchain in other way - by fullbootstrap of it. Due to fact that final gcc (gcc stage3 in bootstrap terminology) requires target headers to be available in /usr/$ARCH/ directories I split toolchain into two packages:

So far packages for gcc 4.4 and 4.5 are created. 4.6 version will follow soon - it will be basically copy of 4.5 one.

But how to get Ubuntu source packages working under Debian?

Experimental requirements

First we need binutils 2.21 and gcc-4.5 from experimental - they contain all my changes which I did for Ubuntu 10.10 'maverick' and all later ones. Many things got cleaned, code duplication which was present for cross targets got eliminated in favour of reusing native packaging as much as possible. Effect is that we have -dbg packages for all libraries and soon also -dbgsym ones. Some work may still need to be done to make sure that cross toolchain for all of Debian architectures can be built and used.

In-progress packaging

Next requirements are armel-cross-toolchain-base and gcc-4.5-armel-cross from my git repository at git.linaro.org server. Latter one is same as Ubuntu one but has build dependencies lowered (Ubuntu has eglibc 2.12, Debian has 2.11 for example). Worse situation is with armel-cross-toolchain-base one...

How it works

To bootstrap cross toolchain I reuse sources which are available in *-source binary packages for binutils/eglibc/gcc-4.5/linux-2.6 components. For binutils and gcc-4.[456] there is no problem as changes are present.

Eglibc/Linux problems

Worse situation is with eglibc and linux-2.6 -source packages as they do not provide Debian packaging inside. I opened bug against linux-2.6 but so far it got refused with answer like "wait for multiarch it will solve your problem". I assume similar answer will be for eglibc but I will report wishlist bug anyway. So far as a work around I included whole eglibc packaging (4MB) inside of armel-cross-toolchain-base and same with linux-2.6. Effect is ugly, non-maintainable but at least I have something to test.

Build problems

Current Debian builds of final eglibc fails on building "nscd/others". It is linking problem as ld is not able to find ld-linux.so for some symbols. It links fine if I call failing line with library added.

If build fails on "build-linux" stage then it is a reason of not whole linux-2.6 packaging copy but it was solved by making it complete.

Bootstrap order and dependencies

1. binutils-cross sysrooted 2. gcc1-cross (requires 1) 3. linux-headers-cross 4. eglibc1-cross (requires 2) 5. gcc2-cross (requires 4, gives libgcc packages) 6. eglibc-final-cross (requires 5, gives all eglibc packages) 7. binutils-cross without sysroot (gives binutils-cross packages)

Why two builds of binutils? gcc1 and gcc2 are build with sysroot enabled as we do not have access to /usr/ARCH directories during build. So we need binutils which will also use sysroot.

Patches used

patches/binutils/add-gnu-oids.texi.diff

Solves missing file in -source package - I should fix binutils for not needing this as we apply it again (it is normally applied during normal binutils builds due to missing file in upstream tarball of 2.21 release).

patches/eglibc: 0001-limit-packages-for-backport-version.patch local-no-notneeded-packages.patch debian-local-no-notneeded-packages.patch

Disables building of documentation, sources, udebs as we do not need them. Need to clean them or change to shell action.

local-kill-locales.patch debian-local-kill-locales.patch

Disable building of localedata for all languages except first one. The process of building them takes lot of time and we do not use this data in cross toolchain.

debian-local-remove-manual.diff

Debian does not ship eglibc manual in eglibc-source but also does not ship manual/ directory which was created by one of debian patches. This patch handles this. Need to report bug.

lucid-force-gcc-4.4.patch

Force using of gcc-4.4 to build eglibc under Lucid. Was used only for Linaro toolchain PPA and got dropped on Friday (solved by applying it into eglibc). Need to merge ubuntu/natty version into debian branch.

ubuntu-backport-50-patched-sources.patch

Do not apply patches when PATCHED_SOURCE=yes is given. Added to Ubuntu eglibc some time ago on my request.

ubuntu-backport-51-stages.patch

Stages support for bootstrapping cross compiler. Taken from Ubuntu packaging.

patches/gcc-4.5: handle-doc-for-stages.diff

Moves GFDL)INVARIANT_FREE variable outside of stages support so it got used under Debian. Need to report bug and get it merged.

no-gold.diff

Do not use gold to build compiler - it fails on building because there is no lto plugin built during gcc2 stage. Merge request sent long time ago, need to check it again and discuss with Matthias Klose.

patches/linux: linux-stage1.diff

Adds support for building linux-libc-dev package only.

Multiarch future

There is ongoing work on having multiarch dpkg working for both Debian and Ubuntu distributions. When it will get to final state both ways of building cross compiler will have to be changed because there will be no need to manually fetch target arch packages because we could just build-depend on them. But thats future - first stage of deploying multiarch will not give us this because whole build infrastructure of both distributions needs to be changed first.

But what we will have to do when we will have final multiarch support? I think that there will be will be able to abandon armel-cross-toolchain-base package in favour of binutils-cross one as there will be no need to cross build eglibc or linux headers (we will just build-depend on target packages).

On Ubuntu side I will still maintain (then deprecated) packages due to LTS support which I promised to our users. But this part will not affect Ubuntu 'current' or Debian 'wheezy'.