Skip to content

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.

1 points14 comments
Open on Reddit
About this post
Posted
Archived
Score
1 · 100% up
Kind
Text
ID
wb4lli

Author

30
posts
118
comments
11
media
View profile

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 --help option 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 -dtb option to specify the specific device-tree (compiled) config for the selected machine.

And have a look at this guide.

1 points

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.

1 points

Graphics is too much to expect. Try using -append option to add the kernel option console=ttyAMA0 and also set -serial stdio and -display none, and hopefully this would give you TTY access.

1 points

Do to the aur package history and find the versions you need.

Also you can try distcc with linking done on arm hardware.

1 points

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!

1 points

The only "good" way to do this would be on a separate system that has the environment you need.

0 points

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...

1 points

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.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.