clang for embedded, C runtime support, and crt*.o

Hi folks,

I have recently been looking at using clang to build firmware code targeting the ARM Cortex-M microcontrollers, where arm-gcc is the de facto standard tool.

I did find some good write-ups around online to follow and get me started, but I ran into an issue that goes beyond my current knowledge:

To get a build that produced a "working" ELF that would run on a micro, I ended up having to explicitly link in my arch-specific crt0.o, crti.0, crtn.o, crtbegin.o, and crtend.o, including sussing those out of the arm-gcc library path.
(here, the arch is thumb/v6-m/nofp or ARMv6-m)

Is that expected, if I want to use various GCC libraries? e.g. lib_nano, libnosys

The roundabout solution for linking is intricate enough that it makes me believe I might be missing some target or architecture-specific flag that would normally pull these objects in to get all of the pre-main symbols.
I've found a few bug tickets mentioning the crt items in the clang/compiler-rt ecosystem, but nothing seemed final or a standard solution.

I did a minimum working example using CMake to accomplish the build and show my workaround here:
https://github.com/apullin/clang_min_fw

As you can see in the CMakeLists, I had to fulfill these dependencies with ${CRT_SUPPORT_ROOT} and ${CRT_SUPPORT_LINK} .

Any insight on the topic would be appreciated.

Thanks,
Andrew Pullin