User avatar
sakaki
Posts: 85
Joined: Sun Jul 16, 2017 1:11 pm

Emerging aarch64 rust-1.25.0 for RPi3, via QEMU PC chroot (tutorial)

Sat Apr 28, 2018 6:10 pm

Hello,

To get aarch64 rust-1.25.0 to build for my gentoo-on-rpi3-64bit project's binhost recently, I had to resort to emerging in a user-mode QEMU binfmt_misc chroot on my PC (it now isn't really feasible to build this natively on an RPi3, as it needs over 3GiB of swap (and isn't distcc-friendly), so the emerge time was literally stretching out to multiple days). Been a while since I tried this for aarch64 (gave up last time due to too many unimplemented syscalls), but I was pleasantly surprised to see that it now works pretty well.

As such, and since the technique (which lets you easily leverage the memory, CPU and peripherals bandwidth of your PC) may be of interest to others, I have written up a short wiki tutorial, here.

Here's a screenshot of the build in progress on my PC workstation (it hit 80 concurrent threads / 12 GiB memory at peak, incidentally ^-^):

Image

This isn't a silver bullet unfortunately; user-mode QEMU has problems with certain programs, such as javac, atm (see e.g. this bug report), so no icedtea currently. But most things work.

Best, sakaki

Acknowledgement: I used the following articles as reference, thank you all:

User avatar
Gavinmc42
Posts: 2107
Joined: Wed Aug 28, 2013 3:31 am

Re: Emerging aarch64 rust-1.25.0 for RPi3, via QEMU PC chroot (tutorial)

Sun Apr 29, 2018 1:25 am

Wow Sakaki,
Am I right that this could speed up porting 32bit stuff to Aarch64 Pi's?
Furthermore, on a sufficiently powerful x86-64 host,
I might have to get one of those instead of this old Core Duo with second hand CPU ;)
Going to need some serious hardware upgrades, 2GB just does not cut it any more - 12GB :o
Will need some 4K screens for Pi testing anyway.

How did I miss that buildkernel script too, I was trying to do that the other day without a config.
Thanks again for a comprehensive wiki.

RPF should hire you to do Raspbian64 build scripts for them ;)
Eben, you listening? :idea:
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
sakaki
Posts: 85
Joined: Sun Jul 16, 2017 1:11 pm

Re: Emerging aarch64 rust-1.25.0 for RPi3, via QEMU PC chroot (tutorial)

Sun Apr 29, 2018 1:55 pm

Gavinmc42 wrote:
Sun Apr 29, 2018 1:25 am
Wow Sakaki,
Am I right that this could speed up porting 32bit stuff to Aarch64 Pi's?
Yes, absolutely, for example I built 64-bit firefox-59.0.2 that way yesterday for the RPi3, in 1 hr 44 mins from source (just pushed to the binhost, btw). That's more than an order of magnitude faster than building locally on an RPi3 (assuming the latter didn't swap itself to death first ^-^).

The technique is quite a popular one in the embedded development community (see e.g. this post from 2012, for 32-bit arm), and QEMU's syscall mapping etc. has gotten good enough for aarch64 to allow it to be used for (most) 64-bit build targets for the RPi3 now.

It is worth getting a reasonably spec'd machine to use as the PC buildserver, if you go down this route. With sufficient memory, you can even mount the target rootfs in RAM while working on it ^-^

best, sakaki

Return to “Gentoo”

Who is online

Users browsing this forum: No registered users and 0 guests