Is `compiler_rt` supposed to support older ARM versions (ARMv4)?

I have a library building for the arm7tdmi CPU that targets the Thumb instruction set almost entirely. It builds executables properly with Zig 0.16.0, but recent updates to compiler_rt between then and Zig master have introduced the use of ARM instruction variants that aren’t supported in ARMv4. When building with this version of compiler_rt, Zig throws an error about an invalid instruction mov r3, r1, which zig cc says ‘requires ARMv6 or later’.

Here’s a minimal reproduction:

pub export fn _start() noreturn {
    while (true) {}
}

Build with zig build-exe repro.zig -target thumb-freestanding -mcpu=arm7tdmi. The error disappears if you target arm-freestanding, change the CPU model to a newer one (or leave Zig to use the generic one), or disable compiler_rt with -fno-compiler-rt (though that raises linker errors instead).
I was also able to get the error to go away (and the library to build correctly) by changing the offending instructions in my copy of compiler_rt to use the flag-setting movs which is supported in Thumb, even in ARMv4.

My question: is compiler_rt intended to support older versions of ARM?

Thanks for any help you can provide.

Smells like a bug to me, which should be opened. If it turns out to be a deliberate change, then the resolution will say so and give the reasoning, or perhaps a change you can make to resolve it.

Link to the issue: https://codeberg.org/ziglang/zig/issues/36411

1 Like