How to use `compiler-rt` on 32-bit ARM?

Hi, I’m trying to cross-compile a program to a few Linux architectures, to generate one LTO static binary. To do this I compile llvm, clang, musl, libcxx, libcxxabi, libunwind, compiler-rt, my program’s dependencies, and then my program.

I got it to work for x86_64 and for aarch64. However, for armv7, compiler-rt builds successfully but it doesn’t create a crtbegin object file, so compiling (linking) anything fails. On aarch64, I get a .../lib/linux/clang_rt.crtbegin-aarch64.o file, but there is no equivalent file with armv7.

Is this just something that doesn’t work yet? I understand compiler-rt is a little experimental but I see the documentation mentions that “ARM” is supported. I couldn’t figure out how to use libgcc in this way instead.

Build scripts are here: btdu/ci/docker/ at llvm-musl · CyberShadow/btdu · GitHub

Edit: I see armv7 is in a if(APPLE) block, but arm isn’t. But, arm doesn’t build (error: DMB is only supported on ARMv6+).

Edit: I got it to work by adding -march=armv6.

How does -march=armv6 help with an armv7 build?

I have been using

-m32 -fPIC

cmake -G Ninja -S compiler-rt -B arm-rt

and my build gives these:

ls lib/arm-linux-gnueabihf
clang_rt.crtbegin.o clang_rt.crtend.o libclang_rt.builtins.a liborc_rt.a

Sorry for the confusion. It helps an “arm” build.

Note that the triple specified in that command in CMAKE_C_COMPILER_TARGET starts with arm-, however --target actually says armv7. If the triple is changed to match, that will cause CMakeLists to not build those object files.

In the end I switched this around and put armv6 in the triple but for compiler-rt I changed the triple to arm-... and put -march=armv6 in cflags.