<p dir="ltr">Nice work, Wookey!  If experience cross-building for armhf is any guide, all you need for NSS is a host build of shlibsign; see <a href="https://github.com/mkedwards/crosstool-ng/blob/master/patches/nss/3.12.10/0001-Modify-shlibsign-wrapper-for-cross-compilation.patch">https://github.com/mkedwards/crosstool-ng/blob/master/patches/nss/3.12.10/0001-Modify-shlibsign-wrapper-for-cross-compilation.patch</a> .  There's also scriptage in that repo for the build sequence and cross parameters: <a href="https://github.com/mkedwards/crosstool-ng/blob/master/scripts/build/cross_me_harder/510-nss.sh">https://github.com/mkedwards/crosstool-ng/blob/master/scripts/build/cross_me_harder/510-nss.sh</a>.  It's ugly in places (cross pkgconfig was kind of wonky at the time) but may help you get past NSS and on to apt.</p>

<p dir="ltr">Cheers,<br>
- Michael</p>
<div class="gmail_quote">On Feb 26, 2013 6:11 PM, "Wookey" <<a href="mailto:wookey@wookware.org">wookey@wookware.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
State of the Debian/Ubuntu arm64 port<br>
=====================================<br>
<br>
*** Arm64 lives! ***<br>
<br>
Executive summary<br>
-----------------<br>
<br>
 * There is now a bootable (raring) image to download and run<br>
 * Everything has been rebuilt against glibc 2.17 so it works<br>
 * A bit more work is needed to make the rootfs useable as a native buildd<br>
 * Multiarch crossbuilding and the build-profile mechanism is mature enough to cross-build<br>
    a port from scratch (this is a big deal IMHO)<br>
 * All packages, sources and tools are in a public repo and this work should be reproducible.<br>
 * This image is fully multiarched so co-installing armhf for a<br>
    64/32 mix should work nicely, as should multiarch crossbuilding to<br>
    legacy x86 architectures. :-) (but I haven't tried that yet...)<br>
<br>
<br>
 * Linaro wants 'the distros' to take this work forward from here so people interested in<br>
    Debian and Ubuntu on 64-bit arm hardware need to step up and help out.<br>
<br>
<br>
Bootable images<br>
---------------<br>
<br>
A milestone was reached this week: Enough packages were built for arm64 to debootstrap an<br>
image which booted to a prompt! After a bit of fettling (and switching to multistrap) I got<br>
an image with all the packages configured which boots with upstart to a login prompt (I<br>
admit, I did get quite excited about this, as it represents the coming together of nearly 3<br>
years work on multiarch, crossbuilding, bootstrapping, cyclic dependencies and arm64 :-)<br>
<br>
The images are available for download:   <a href="http://wiki.debian.org/Arm64Port#Pre-built_Rootfs" target="_blank">http://wiki.debian.org/Arm64Port#Pre-built_Rootfs</a><br>
And there are destructions there for making your own.<br>
<br>
All these packages were cross-built on raring, untangling cyclic dependencies with build<br>
profiles (see <a href="http://wiki.debian.org/DebianBootstrap" target="_blank">wiki.debian.org/DebianBootstrap</a> for how that works), making this the first<br>
(non x86) self-bootstrapped debian port ever (so far as I know). All (?) previous ports have<br>
been done using something else like OpenEmbedded (armel, armhf), RedHat/HardHat (arm, alpha,<br>
mips), something IBMy (s390) to get an initial linux rootfs on which debian packages are<br>
built.<br>
<br>
The new bootstrap process is (almost) just a list of sbuild commands. In practice there are<br>
still a few rough edges around cross- build-dependencies so of the 140 packages needed for<br>
the bootstrap, 9 had to be built manually with 'dpkg-buildpackage -aarm64 -d' (to skip<br>
build-dep checks) instead of 'sbuild --host arm64 <package>'.<br>
<br>
The current bootstrap packageset status is here:<br>
  <a href="http://people.linaro.org/~wookey/buildd/raring-arm64/status-bootstrap.html" target="_blank">http://people.linaro.org/~wookey/buildd/raring-arm64/status-bootstrap.html</a><br>
<br>
There is no armv8 (arm64/aarch64) hardware available yet, so this image can currently only<br>
be run in a model. ARM provide a free-beer prorietary 'Foundation model' so we do have<br>
someting to test with. It's sluggish but perfectly useable. Booting the images takes a<br>
couple of minutes on my fairly average machine.<br>
<br>
The images are using the Linaro OE release kernels which seem to work fine for this purpose.<br>
Thanks to Marcin for modified bootloader lines in .axf files.<br>
<br>
<br>
<br>
Image status<br>
------------<br>
<br>
I was impressed that things basically 'just worked' on first boot. There is of course plenty<br>
of breakage, I'm sure, and I haven't looked very hard yet, but it's a lot better than I<br>
expected after months of just building stuff and testing nothing. (Things that are poorly:<br>
nano can't parse it's own syntax-coluring files for example, and multiarch perl has the<br>
wrong @INC path compiled in; I'm sure there is more). Consider this alpha-grade until it's<br>
been used a bit more.<br>
<br>
Things that are not yet built which would make the images a lot more useful are apt and a<br>
dhcp client. apt needs gnupg needs curl needs nss. The nss cross-build needs fixing to<br>
unbung that. A debian chroot without apt turns out to be disappointing quite quickly :-)<br>
Expect an updated image with more packages very soon.<br>
<br>
<br>
Multiarch crossbuilding<br>
-----------------------<br>
<br>
It's really nice to have building and crossbuilding using exactly the same mechanisms<br>
and tools, with all files having one canonical location, and dependency mechanisms that<br>
are reliable. The more I've used this, the more I've been impressed by it. There is<br>
still work to do to expand the set of cross-buildable stuff, but it's a solid base to<br>
work from.<br>
<br>
Getting this port working has been 'interesting' because it's attempting 4 new things all at<br>
once: multiarch (file layouts and dependencies), crossbuilding (tools and packaging support<br>
in a distro that historically was always natively built), arm64 (aarch64) support in<br>
packages that need it, and build-profiles to linearise the build-order.<br>
<br>
The arm64 part of this is a relatively small part as the heavy lifting has been done<br>
upstream (gcc, (e)glibc, binutils, kernel, libffi, autotools and a lot of minor fixes in<br>
various packages). Thanks are due to doko (Matthias Klose) for sterling work getting all<br>
that integrated into the debian and ubuntu toolchain packages, and infinity (Adam Conrad)<br>
for merging various eglibc branches. There were also hordes of very boring patches of the<br>
form 'update config.sub and guess before building'.<br>
<br>
Most of the work has been in making things cross-build (exactly the same fixes needed for<br>
armel/hf too so I've had plenty of help there from canonical types who want cross-building<br>
for arm to work nicely), and particular thinks to Neil Williams for taking on the perl<br>
cross-build challenge and creating the debian-perl-cross package to manage the<br>
cross-configury, whilst also working with upstream to make the whole thing a bit less 1996.<br>
<br>
Multiarchifying has been going on nicely in libraries and -dev packages, but things like<br>
perl and python needed significant work, along with a lot of boring bugs saying 'mark this<br>
package MA: foreign' and 'build-dep on python:any or perl-base:any'. Thanks are due to doko<br>
for the python multiarching and Niko Tyni for the perl multiarchification. Getting all 3<br>
'aspects' of multiarch perl, cross-built perl and arm64 perl config to work at the same time<br>
was quite hard work, and there are still bugs there. Wider usage of multiarched perl would<br>
no doubt sort this out reasonably quickly. I started a wiki page to track the status of<br>
multiarched cross-buildable perl: <a href="http://wiki.debian.org/Multiarch/Perl" target="_blank">http://wiki.debian.org/Multiarch/Perl</a> . Help would be<br>
welcome.<br>
<br>
The build-profile work is described on the <a href="http://wiki.debian.org/DebianBootstrap" target="_blank">http://wiki.debian.org/DebianBootstrap</a> page.<br>
Progress has been greatly helped by GSOC projects last year, with good work on the tools<br>
(crossbuild-essential packages, build-profile support) from P.J McDermott and an impressive<br>
contribution from Johannes Schauer on dependency analysis tools around libdose, and apt<br>
build-profile support.<br>
<br>
<br>
All of this apart from multiarch perl, crossbuildable perl and build-profile stuff (and<br>
a few pending patches) is already in raring.<br>
<br>
<br>
Building stuff yourself<br>
-----------------------<br>
<br>
Setting up an arm64 build environment is very simple. Use sbuild-createchroot or mk-sbuild<br>
and point at the bootstrap repo, with a bit of config and some updated tools packages from<br>
the repo (amd64 only supplied). Details are given on<br>
<a href="https://wiki.linaro.org/Platform/DevPlatform/CrossCompile/arm64bootstrap" target="_blank">https://wiki.linaro.org/Platform/DevPlatform/CrossCompile/arm64bootstrap</a><br>
<br>
Once you've created a tarball chroot builds are simply done with<br>
sbuild -c quantal-amd64-sbuild -d quantal --host=arm64 <package.dsc> or<br>
sbuild -c quantal-amd64-sbuild -d quantal --host=arm64 <package>_<version>  (I'd love it<br>
 if sbuild got smart enough to work out the version itself when given a distro - Roger<br>
says he's working on it)<br>
<br>
To deal with the chore of 'find version, run sbuild, sign result, upload to repo, import to<br>
repo, deal with reprepro bitching if you re-upload the same version of something' for every<br>
package build, I wrote 'dimstrap' which is a simple-minded tool to wrap that up and either do<br>
one-off builds or run through a list. It is part of the xbuilder package here:<br>
<a href="https://launchpad.net/~linaro-foundations/+archive/cross-build-tools/" target="_blank">https://launchpad.net/~linaro-foundations/+archive/cross-build-tools/</a> It also includes the<br>
logfile-parsing script ('generate html') which generates the nice status pages:<br>
<a href="http://people.linaro.org/~wookey/buildd/raring-arm64/status-bootstrap.html" target="_blank">http://people.linaro.org/~wookey/buildd/raring-arm64/status-bootstrap.html</a><br>
<br>
<br>
Image building<br>
--------------<br>
<br>
The config and instructions provided (in<br>
<a href="http://wiki.debian.org/Arm64Port#Building_your_own_rootfs_image" target="_blank">http://wiki.debian.org/Arm64Port#Building_your_own_rootfs_image</a> ) is<br>
for multistrap. Debootstrap sort-of produces working images too but<br>
takes a lot longer to unpack/configure, and misses out various vital<br>
packages (like libperl5.14). I'm sure it could be kicked into<br>
submission. In theory multistrap (apt really) should have got all the<br>
arch all packages from the main repo, but in practice it refused to do<br>
that so I had to rebuild them or copy them over anyway (grumble).<br>
<br>
Any package that installs replaced conffiles seems to generate invalid<br>
dpkg status entries (ifupdown did this to me). I've not got to the<br>
bottom of that yet. Deleting the offending line gets you an image that<br>
works.<br>
<br>
Issues<br>
------<br>
<br>
General:<br>
<br>
The build-profile patches for dpkg and apt need to be pushed into the distro to make<br>
that feature permanent. A thread on debian-devel is working on that<br>
(<a href="http://debian.2.n7.nabble.com/Bootstrappable-Debian-proposal-of-needed-changes-td2848200.html" target="_blank">http://debian.2.n7.nabble.com/Bootstrappable-Debian-proposal-of-needed-changes-td2848200.html</a>).<br>

The main issue is what syntax to use '<>' or '[]' and how to deal with multiple overlapping<br>
profiles. The patches to debian control cannot go in until at least the syntax is agreed and<br>
the tools will parse them without barfing. Johannes ands I will send an updated spec<br>
soonish.<br>
<br>
The missing piece of bootstrapping with regard to build-deps is packages that build-dep on<br>
gcc-4.6 or binutils. When cross-building this should be satisfied by <triplet>-gcc-4.6 or<br>
<triplet>-binutils. Nothing makes that happen currently. A scheme has been mooted but<br>
nothing is implemented yet.<br>
<br>
There is debate about whether cross-toolchains should build against multiarch libraries<br>
(libgcc, libstdc++) like everything else, or have their own internal copies. Doko and I<br>
disagree on this matter. That will need to be worked out at some point.<br>
<br>
We won't get that much further with fixing cross- object-introspection, which is a<br>
non-trivial job.<br>
<br>
Image-related:<br>
<br>
The images do essentially work but very little has been tested so far.<br>
<br>
Multiarch perl still needs work.<br>
<br>
nss needs cross-building in order to get apt cross-built<br>
<br>
I've not got networking working yet. Info is here:<br>
<a href="https://fedoraproject.org/wiki/Architectures/ARM/AArch64/FoundationModel_Networking" target="_blank">https://fedoraproject.org/wiki/Architectures/ARM/AArch64/FoundationModel_Networking</a><br>
lack of a dhcp client in the image hasn't helped there.<br>
<br>
<br>
More info<br>
---------<br>
<br>
The canonical arm64 port info page is:<br>
<a href="http://wiki.debian.org/Arm64Port" target="_blank">http://wiki.debian.org/Arm64Port</a><br>
<br>
Full arm64 cross-build status (i.e everything that has been tried) is here:<br>
<a href="http://people.linaro.org/~wookey/buildd/raring-arm64/status.html" target="_blank">http://people.linaro.org/~wookey/buildd/raring-arm64/status.html</a><br>
<br>
All the patches generated so far are here:<br>
<a href="http://people.debian.org/~wookey/bootstrap/patches/" target="_blank">http://people.debian.org/~wookey/bootstrap/patches/</a><br>
<br>
(most that can, have been filed as bugs - there is a backlog of stuff<br>
filed in Launchpad but not yet forwarded to the Debian BTS - yes I am<br>
a bad boy - blame the fact that you can't use reportbug or bts from<br>
inside ARM due to their idiotic email policies).<br>
<br>
<br>
Future work<br>
-----------<br>
<br>
Firstly we should say thank you to Linaro for sponsoring this work in various ways over<br>
the last 3 years. We wouldn't be at this point now if it wasn't for that. However<br>
Linaro has a lot of things to do and is trying hard not to do distro's work for them,<br>
concentrating on upstream things. This makes sense for commercially-backed distros like<br>
Red Hat and Ubuntu, but rather less for Debian where we _are_ the distro just as much<br>
as anyone else is, and ultimately someone has to spend the time to get stuff working.<br>
<br>
Anyway, I was supposed to stop work on this some time back, but have largely failed to<br>
do so (cross-building is so moreish - there is always one more build to try before<br>
bedtime!) and appreciate being given enough slack to get this to a point of actual<br>
utility. However I expect to have much less time to spend on this from now on, except<br>
insofar as it still co-oncides with things Linaro wants doing. I'd love to hear from<br>
people who actually want to use this, to get more packages built, the Debian<br>
cross-toolchains sorted, build-profiles finalised, and a whole pile of stuff fixed once<br>
Wheezy is released. I'm pretty sure there are quite a lot of people who want multiarch<br>
Debian or Ubuntu on their arm64 machines (or models).<br>
<br>
I hear rumours that actual hardware may appear sometime around the middle of the year<br>
with some bagsied for Debian. Setting up the ports infrastructure for that would be<br>
good. I don't know if anyone is interested in building slowly on models in the<br>
meantime, or if we should just carry on crossing and see how far we get. This table<br>
shows that 471 packages in raring can be expected to cross-build already:<br>
<a href="http://people.canonical.com/~cjwatson/cross/armhf/raring/" target="_blank">http://people.canonical.com/~cjwatson/cross/armhf/raring/</a><br>
<br>
Todo:<br>
<br>
Fix up multiarch/cross perl<br>
Fix nss<br>
Build missing packages for apt<br>
Build missing packages for build-essential<br>
Build Debian cross-toolchain<br>
Get all this working in unstable as well as raring<br>
Setup buildds<br>
Build all the other packages<br>
Set up automated bootstraping runs (eventually)<br>
<br>
<br>
Current setup<br>
-------------<br>
<br>
Builds have all been run locally using the sbuild/chroot setup described above and on<br>
the Arm64Port page, which should be easy for anyone to reproduce. The main irritation<br>
is keeping up with raring: out of sync libraries are not MA-installable.  Logs are<br>
uploaded to <a href="http://people.linaro.org" target="_blank">people.linaro.org</a> (rsync). The reprepro repo is on <a href="http://people.debian.org" target="_blank">people.debian.org</a><br>
(dupload).  This stuff should probably move to <a href="http://ports.debian.org" target="_blank">ports.debian.org</a> and <a href="http://ports.ubuntu.com" target="_blank">ports.ubuntu.com</a>,<br>
but neither of those are set up for cross-building so I'm not quite sure how this will<br>
work.<br>
<br>
I could go on at great length about the machinery of profiled bootstrap builds, and<br>
interactions between tools, but it's not very exciting, so will resist. Suffice it to<br>
say that whilst it's all pretty slick I'd still like better buildd tools.<br>
<br>
<br>
Build-profile changes<br>
---------------------<br>
<br>
The build-profile patches are not yet upstreamable so are collecting in the repo.<br>
The patch set so far is here: <a href="http://people.debian.org/~wookey/bootstrap/patches/profiles/packages/" target="_blank">http://people.debian.org/~wookey/bootstrap/patches/profiles/packages/</a><br>
<br>
<br>
Other thanks:<br>
Other people who have helped make this happen in various ways but not got a mention above:<br>
Colin Watson, Dmitry Ledkovs, Steve Langasek, Harry Leibel, Thibaut Girka, Roger Leigh,<br>
Marcus Shawcroft, James Morrisey, Jonathan Austin, Steve McIntyre, Peter Pearse, Aurelien<br>
Jarno, and whoever does sysadmin at people.{linaro,debian}.org<br>
<br>
I hope I didn't forget anyone, or any important information.<br>
<br>
Feedback from anyone attempting to get this working outside my computer is very<br>
welcome. I have almost certainly forgotten to write down some things, and upload<br>
correct versions of some other things.<br>
<br>
<br>
Wookey<br>
--<br>
Principal hats:  Linaro, Emdebian, Wookware, Balloonboard, ARM<br>
<a href="http://wookware.org/" target="_blank">http://wookware.org/</a><br>
<br>
_______________________________________________<br>
cross-distro mailing list<br>
<a href="mailto:cross-distro@lists.linaro.org">cross-distro@lists.linaro.org</a><br>
<a href="http://lists.linaro.org/mailman/listinfo/cross-distro" target="_blank">http://lists.linaro.org/mailman/listinfo/cross-distro</a><br>
</blockquote></div>