Clang: compiler-rt and libunwind guidance on linux

I’m working on a package that builds clang, libc++, and extra tooling from trunk for use on Arch Linux. This is mostly to get up-to-date tooling like clangd, clang-format, & lldb, but I also want to experiment with newly implemented features.

I’m currently able to successfully bootstrap a toolchain that does not link against libgcc_s or libatomic at all (using compiler-rt, builtins, libc++, libc++abi, & libunwind everywhere). But I’m not certain that this is the most desirable configuration, and thus far I haven’t found a lot of guidance as to what tradeoffs are involved. I’m most worried that mixing code built this way with existing system packages could cause problems.

The default build on linux defaults to libgcc as the runtime library, but I feel like I’ve read that compiler-rt implements additional functionality that clang can take advantage of. Is there specific functionality that compiler-rt enables that isn’t provided by existing system libraries? What is the downside to using libgcc here?

If I do enable compiler-rt, I’m not sure about which unwinder to use. On the one hand I can imagine libgcc_s causing problems due to overlap between compiler-rt-provided functionality and libgcc_s functionality, but on the other hand it seems like mixing libraries built with different unwinders might be problematic. And then I see that some system packages link against savannah’s libunwind anyway, so maybe mixing unwinders isn’t a big deal? (I also don’t feel great about having both my package and the savannah package install a copy of libunwind, though it seems I can avoid a conflct by only installing the static llvm libunwind.)

I’m torn between trying to build a toolchain that uses as many llvm-provided tools as possible and one that is maximally compatible. I’ve tried tons of combinations, and I’ve noticed that the sanitizers & lldb tests pretty much always break in at least a few places if I do anything other than a vanilla build, which doesn’t give me the greatest confidence.

I’m also looking to learn more about the project in general, so it would also help me to better understand what’s going on at this level. Can anyone shed some light?

Thank you!

Is there specific functionality that compiler-rt enables that isn’t provided by existing system libraries?

I forgot that the docs do explicitly mention these builtins, but I’m curious if there is more. Or is it all the builtins listed on that language extensions page?