cross-rs / cross-toolchains

Additional Dockerfiles and crosstool-ng config files to build additional toolchains.
Apache License 2.0
88 stars 16 forks source link

libatomic.a included in arm-unknown-linux-gnueabihf:0.2.5 contains armv7 instructions #39

Open regwhitton opened 1 year ago

regwhitton commented 1 year ago

Hello.

When cross compiling for a 2011 Raspberry Pi 1 (armv6) using docker, if the program includes libatomic.a then when the program is run on the target architecture it outputs "Illegal Instructions" and stops.

Looking through the past issues, there are a number that have similar symptoms, but in this case the root cause seems to be this library. Only libatomic.a and libatomic.so seem to include armv7 instructions. My work-around is to replace libatomic.a from the Raspberry Pi distribution: https://downloads.raspberrypi.org/raspios_lite_armhf/root.tar.xz

Perhaps, the docker file could include a check of the sysroot contents.

$ docker run --rm -it ghcr.io/cross-rs/arm-unknown-linux-gnueabihf:0.2.5 bash
root@e1eb3b13927c:/# readelf -A /x-tools/arm-unknown-linux-gnueabihf/arm-unknown-linux-gnueabihf/sysroot/lib/libatomic.a | grep 'Tag_CPU_arch: v7' | head -1
  Tag_CPU_arch: v7
root@e1eb3b13927c:/# readelf -A /x-tools/arm-unknown-linux-gnueabihf/arm-unknown-linux-gnueabihf/sysroot/lib/libatomic.so | grep 'Tag_CPU_arch: v7' | head -1
  Tag_CPU_arch: v7