User avatar
sakaki
Posts: 189
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: 2624
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: 189
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

arshad66
Posts: 2
Joined: Tue Dec 25, 2018 8:25 am

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

Tue Dec 25, 2018 9:06 am

Hi
i going to install a raspberry pi 3 (pi64 or gentoo) on windows using Qemu. but i got error. please ell me if it possible or not!?
please guide me how i load and Raspberry pi 64bit on emulator in windows ? which os or command to do it ?

thanks

arshad66
Posts: 2
Joined: Tue Dec 25, 2018 8:25 am

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

Tue Dec 25, 2018 10:22 am

Hi
I wanna install an operating system of Raspberry pi3 64 bit on emulator Qemu or Vmware on Windows.
please help me if it possible or not ? because i have tried so many Distribute of raspberry but i could not.
please guide me or help me to do it.

thanks in advance

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

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

Thu Dec 27, 2018 3:26 pm

arshad66,

my post above contains a link to running an arm64/aarch64 image under user-mode binfmt_misc QEMU, if that's what you want (https://github.com/sakaki-/gentoo-on-rp ... infmt_misc).

If you want system-mode, there's some basic support upstream now I believe. See e.g. this post. I'm afraid it's not something I've used.

hth, sakaki.

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

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

Tue Jan 01, 2019 3:49 am

Hi Sakaki,
Latest Gentoo64 1.31. has Rust 1.29.2
Can rustup be used to update to Rust 1.31.0?
https://blog.rust-lang.org/2018/12/06/R ... -2018.html

Since Chromium is now available does that mean Go is too?
Rust and Go are multicore aware, good for learning to code these ARMv8's ;)
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

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

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

Tue Jan 01, 2019 6:17 pm

Gavinmc42 wrote:
Tue Jan 01, 2019 3:49 am
Latest Gentoo64 1.31. has Rust 1.29.2
Can rustup be used to update to Rust 1.31.0?
It's generally best to use Gentoo's own package management to update, and not mix and match, otherwise the system can get confused. I have rust-1.31.1 masked at the moment. It'll be available through the usual genup approach in the near future.
Gavinmc42 wrote:
Tue Jan 01, 2019 3:49 am
Since Chromium is now available does that mean Go is too?
Rust and Go are multicore aware, good for learning to code these ARMv8's ;)
dev-lang/go is not on the image, as it isn't a hard runtime requirement of chromium. You can checkout the full list (just over 1,000) of packages shipped on the v1.3.1 image, here.

However, I have got dev-lang/go built for arm64 on the binhost, up to v1.11.2, so it is a quick install.

Code: Select all

[email protected] ~ $ sudo emerge -av dev-lang/go
Should do it.

hth, sakaki

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

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

Wed Jan 02, 2019 12:59 am

Thanks Sakaki,
I did figure out Go , It works quite well, I did hope it had been built already.
Interestingly, some lower level maths has been optimized with CPU assembler.
It's generally best to use Gentoo's own package management to update, and not mix and match, otherwise the system can get confused.
I get confused too :D That's when things get broken ;)
Rust and Cargo seem to be closely tied at least if any external crates/libraries are to be used.
Should be sorted once I get used to it.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Return to “Gentoo”