Cross compiling for a specific architecture and libc version
I've tried so many different things without success that I resort to asking here. I'm trying to get python3.10 on my raspberry pi which runs an ARM1176 processor with the armv6l architecture.
My first and most obvious attempt was to run a QEMU machine with the same OS and architecture, that way I could just compile there. I couldn't get a VM with the same architecture, the closest I got to it was running something similar to
qemu-system-arm -machine raspi1ap -cpu arm1176 -kernel "./vmlinuz" -initrd "./initrd.gz" -cdrom file=debian-11.4.0-armhf-netinst.iso
This would just give me a black screen and max a processor, even though I got the kernel and initrd from the right place for the iso (I got it working this way for another architecture). Prior to this I did get one ARM machine to boot and compile okay, but I didn't have the right machine and cpu parameters so the executables wouldn't run on the pi.
Then, I went on to the second most obvious option which is to use the AUR packages for ARM cross-compilation. I managed to install them, but the executables wouldn't run because I had the wrong version of libc with them. I tried matching the gcc version from the pi, which is 10.2.1, the git from the AUR gave me 10.2.0 but that version required libc>=2.33 when the pi has libc version 2.31.
One final attempt was to run a QEMU machine of the same Debian version but x86_64, and within it to cross-compile. That also failed because they don't include the machine armv6 anymore in their cross-compilers, so you would need to get the cross-compiler from some other shady source.
About this post
- Posted
- Archived
- Score
- 1 · 100% up
- Kind
- Text
- ID
- wb4lli
14 comments
Wow! I just noticed that Arch Linux ARM dropped ARMv5 and ARMv6 support.
ARMv5 removal is really an end of an era, though with their limited RAM, I don't think these devices can even boot compressed kernels anymore.
The official Python Docker image support arm32v6, so that's an option.
If you're booting an ARMv6 VM, then maybe use a more generic machine than the raspi1ap. I haven't booted an ARM VM for a while, and I didn't need to use this really at the time, so I don't remember much.
What I can recommend is to use qemu
--helpoption to list machines, match this to available device-tree configs in the distro image/tarball you're using.The vexpress machines should be a good choice if you have one that is matching the architecture.
Use qemu's
-dtboption to specify the specific device-tree (compiled) config for the selected machine.And have a look at this guide.
Hmm well it seems none of the machines that support arm1176 as a processor are really giving me anything but a black screen. It's the same if I use -nographic and add the TTY boot option, just a single CPU maxing out and a black screen.
Graphics is too much to expect. Try using
-appendoption to add the kernel optionconsole=ttyAMA0and also set-serial stdioand-display none, and hopefully this would give you TTY access.Do to the aur package history and find the versions you need.
Also you can try distcc with linking done on arm hardware.
It doesn't have the exact version I need for gcc, and the closest gcc requires a different version of glibc than the raspberry pi toolchain has...
I'll look into distcc, thanks!
The only "good" way to do this would be on a separate system that has the environment you need.
You mean a physical processor with the same architecture? I'm trying to avoid exactly this because it would take a huge amount of time...
No, I just mean another host with the necessary technology stack installed and configured to build for your target platform. If you try switching back and forth between technology stack components for both your system and the target system, you will be off onto another nightmare.