[cfe-dev] Objective-C runtime

David Chisnall theraven at sucs.org
Fri Sep 17 16:00:55 PDT 2010


On 17 Sep 2010, at 23:29, Ariel V Feinerman wrote:

> Can I use a custom runtime with the clang-llvm included in Xcode or vice versa Apple runtime in other OS with the clang-llvm (I wish to get full Objective C 2.0 support in win, linux or mac with the same lib) from llvm.org or source? In general, how do clang-llvm, llvm-gcc or gcc know what type of runtime you use? They may have some different interfaces.

By default, clang will target the GNU runtime on non-Darwin platforms and the NeXT / Apple runtimes when on on Darwin.  You can control this in the same way that you do with GCC, by providing the -fgnu-runtime or -fnext-runtime flag, to select between the GNU and NeXT (Apple) runtimes explicitly.

Providing -fobjc-nonfragile-abi will also make some changes to the runtime.  On Darwin it will use Apple's 'Modern' runtime, while not specifying it will generate code for the 'Legacy' runtime.  If you specify -fobjc-nonfragile-abi and -fgnu-runtime, then clang will generate code for the GNUstep runtime, which you can find in GNUstep svn as libobjc2.  This provides all of the ObjC 2 features except for GC, and a few others not found in the Mac runtimes.

Apple GCC never merged the code for supporting non-NeXT/Apple runtimes, so Apple GCC (which is used by llvm-gcc) only supports the NeXT / Apple runtimes.  Dragon Egg uses FSF GCC, so it will be able to target the GNU and Apple runtimes.  FSF GCC does not currently support Objective-C 2, but Nicola Pero is currently working on that.

If you want to cross-compile from XCode, then you will need to do a bit more than just select a different runtime (for example, make sure you are including only headers for your target platform, and probably using a non-Darwin version of binutils).

David



More information about the cfe-dev mailing list