3

The August 2020 version of Raspberry Pi OS ships with arm-linux-gnueabihf-gcc-8. Checking arm-linux-gnueabihf-gcc-8 -v I see that it has this option set: --with-arch=armv6. However, the new Raspberry Pi 4 comes with an ARMv7 processor.

Why does the operating system come with a compiler that will build programs for an older ARM version? Is it because the OS itself is compiled for ARMv6?

David
  • 693
  • 4
  • 21
  • 1
    "the new Raspberry Pi 4 comes with an ARMv7 processor" -> Actually the Pi 3 and 4 have an ARMv8 processor, the Pi 2 is ARMv6, and the single core models are ARMv6 – goldilocks Sep 20 '20 at 15:35
  • 1
    If I check cat /proc/cpuinfo I see that the processor is an ARMv7 Processor rev 3 (v7l). But I see that the Raspberry Pi website states the Pi 4 comes with an ARMv8 processor. Do you know where there is this discrepancy? – David Sep 20 '20 at 15:44
  • 1
    No. Could be the kernel. May be of interest: https://raspberrypi.stackexchange.com/q/100076/5538 – goldilocks Sep 20 '20 at 18:23
  • For a very long time on the PC gcc shipped targetting 386 by default instead of 486. It should be noted though that gcc still allow programmers to write feature detection code so even though the target is 386 you can still use more advanced features like MMX – slebetman Sep 21 '20 at 01:03
  • My guess is that in 32bit mode the /proc/cpuinfo reports the 32bit version the processor supports, which is ARMv7. The ARMv8 is 64bit and you need a 64bit kernel to use that and /proc/cpuinfo will show ARMv8 then. – Goswin von Brederlow Sep 27 '20 at 15:48

1 Answers1

2

Is it because the OS itself is compiled for ARMv6?

Yes.

Why...

The same reason the OS is compiled for ARMv6: Because it is intended for use on all models, including the ARMv6 Zeros, etc.

There is probably not much point in using an ARMv7 compiler on an ARMv6 system regardless of the underlying hardware. The system libraries and kernel are ARMv6.

Also worth noting that the version of ARMv6 used is (no expert, but pretty sure), not that much different from ARMv7. When the ARMv7 model came out, some people were eager to prove that using an ARMv7 kernel and OS was faster than using the ARMv6 one, but I do not think that panned out -- which is part of the reason adoption of the ARMv7 distros was lackluster, and more about people having different flavours as options, not performance (many distros already had ARMv7 repos but few have ARMv6; Raspbian was originally a repackaging of Debian ARMv6).

goldilocks
  • 58,859
  • 17
  • 112
  • 227
  • The main difference between the armv6 and armv7 distributions is the FPU and hardfloats. That actually makes a major difference in speed for floating point heavy software. – Goswin von Brederlow Sep 27 '20 at 15:44
  • @GoswinvonBrederlow ARM1176JZF-S, the arm6 implementation used used in the Broadcom 2835 SoC (ie., all the single core models including the original), has an FPU coprocessor, which is why Raspbian uses the armhf Debian variant (arm6 w/ hardware floating point support), as opposed to armel. – goldilocks Sep 27 '20 at 15:57
  • 1
    The ARM1176JZF-S in the RPi1 has an older FPU requiring - mfpu=vfp wile the RPi2 has the next generation using -mfpu=neon. There is a significant difference to the two. – Goswin von Brederlow Sep 27 '20 at 16:00
  • 1
    Apparently only arm7 potentially has a hardware divider too: http://wanderingcoder.net/2010/07/19/ought-arm/ Dunno if that applies to the Pis. Regarding "major difference in speed", I've never seen any benchmarks that demonstrated more than a 20-30% for "some things", but in general 10-15%. – goldilocks Sep 27 '20 at 16:03