How to effectively cross compile from x86 for aarch64

This forum is for discussion about general software issues.

How to effectively cross compile from x86 for aarch64

Postby feedc0de » Tue May 24, 2022 12:31 pm

Hi.

I want to compile a single archlinux arm package on my x86 archlinux host, as I have plenty of cores, ram and storage there.

I do not want to compile on my arm devices them selves, nor do I want distcc in my compilation process.

What is the general way to tell makepkg on x86 to compile for aarch64 and how does it work with all the arm dependencies that my package might night during building or to run?



I considered the following wiki pages:
https://wiki.archlinux.org/title/Cross- ... guidelines
Here the wiki tells about changing the PKGBUILD file by changing variables? I would prefer to keep the PKGBUILD unchanged and control my target architecture by environment variables or arguments to makepkg (-si)

https://archlinuxarm.org/wiki/Distcc_Cross-Compiling
But I want to compile locally on my powerful x86 machine without any other machine interfering.

https://archlinux.org/packages/communit ... x-gnu-gcc/
How to use this compiler with makepkg?
feedc0de
 
Posts: 9
Joined: Mon May 02, 2022 7:01 pm

Re: How to effectively cross compile from x86 for aarch64

Postby feedc0de » Tue May 24, 2022 2:36 pm

Maybe I found a way myself now using qemu+chroot,

I installed 3 packages:
arch-install-scripts (for arch-chroot)
qemu-user-static (AUR)
binfmt-qemu-static (AUR)

Then I rsynced the odroid-hc4's rootfs to my build-machine, copied 2 static qemu bins into the chroot:
sudo cp /usr/bin/qemu-aarch64-static /usr/bin/qemu-arm-static odroid-hc4/usr/bin/ -v

and then simply chrooted into the aarch64's rootfs from my x86 host, build is already running :D

sudo arch-chroot odroid-hc4/
feedc0de
 
Posts: 9
Joined: Mon May 02, 2022 7:01 pm

Re: How to effectively cross compile from x86 for aarch64

Postby solskogen » Wed May 25, 2022 9:36 am

That's gonna be a lot slower than using distcc...
solskogen
 
Posts: 161
Joined: Mon Nov 18, 2013 10:41 am

Re: How to effectively cross compile from x86 for aarch64

Postby feedc0de » Wed May 25, 2022 11:27 am

but single gcc calls take up to 20gb of memory and with swap on my odroids this is even slower.

maybe I could run distcc on multiple x86 machines all running qemu?

or what was the general idea behind the distcc setup?
feedc0de
 
Posts: 9
Joined: Mon May 02, 2022 7:01 pm

Re: How to effectively cross compile from x86 for aarch64

Postby solskogen » Wed May 25, 2022 11:29 am

20GB? That seems like *a lot*
I could rather use a cross compiler on x86_64 instead of using qemu.
solskogen
 
Posts: 161
Joined: Mon Nov 18, 2013 10:41 am

Re: How to effectively cross compile from x86 for aarch64

Postby feedc0de » Wed May 25, 2022 11:53 am

that was my original question, if you know how to cross compile (but with makepkg, I do want arch .pkg.* files in the end), feel free to guide me :D
feedc0de
 
Posts: 9
Joined: Mon May 02, 2022 7:01 pm

Re: How to effectively cross compile from x86 for aarch64

Postby solskogen » Wed May 25, 2022 12:44 pm

Install distcc and a cross compiler on the fast host, use the SBC (you don't even need to compile on the ARM, just use the fast machine of yours) just like the wiki says.
solskogen
 
Posts: 161
Joined: Mon Nov 18, 2013 10:41 am

Re: How to effectively cross compile from x86 for aarch64

Postby zebul666 » Tue Aug 09, 2022 9:52 am

yes.
sometimes, I even go further and use a systemd-container (with archlinuxarm install), to compile on the x86_64 fast machine to get the speed of disk and size of ram while still using distcc to cross compile on that host

I don't know if what I am saying is clear...
zebul666
 
Posts: 48
Joined: Fri Jul 10, 2015 4:55 pm

Re: How to effectively cross compile from x86 for aarch64

Postby solskogen » Wed Aug 10, 2022 8:53 am

That means running it in qemu which is a LOT slower than using distcc.
solskogen
 
Posts: 161
Joined: Mon Nov 18, 2013 10:41 am


Return to General

Who is online

Users browsing this forum: No registered users and 11 guests