[llvm-dev] What is compiler-rt for?

David Chisnall via llvm-dev llvm-dev at lists.llvm.org
Wed Sep 2 03:22:44 PDT 2015


On 2 Sep 2015, at 10:59, mats petersson via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> It is there to allow the compiler to run on platforms that would otherwise not have the relevant functionality. If you already have a C++ compiler to build Clang with on the target system, you (most likely) have everything you need. But what if you are cross-compiling to a target with limited/no support for C++ on the target?

It’s not just cross compiling.  On most operating systems, the OS vendor is responsible for providing a set of libraries that perform functionality expected by the compiler.  This includes functions that provide missing CPU functionality (and which would be too expensive to inline everywhere, or which all programs must do in precisely the same way, irrespective of the compiler used), for example some complex floating point operations or atomics, and the generic unwind frameworks.

Most OS vendors *do* provide these (and so do some third-party toolchains, such as MinGW).  GCC provides an implementation of these that most Linux distributions ship.  On FreeBSD or OS X, these are provided by compiler-rt.  If you are bringing up a new platform, then compiler-rt gives you some of these components.

Note that nothing in compiler-rt is specific to C++.  The closest thing is the unwind library, which provides the generic part of the unwinder, which is also used for other languages (Objective-C, Ada, Java with GCJ, and so on). 

David



More information about the llvm-dev mailing list