[cfe-dev] Rewrite Objective-C to C

Dado Colussi dado.colussi at gmail.com
Thu Nov 13 08:10:26 PST 2008


On Mon, Nov 10, 2008 at 5:44 PM, David Chisnall  
<csdavec at swansea.ac.uk> wrote:
On 10 Nov 2008, at 14:41, Dado Colussi wrote:

Hello everybody,

I am new to this list, and my inexperience in compiler technology is
likely to shine in my questions. Here we go...

I am interested in trying to use clang to convert Objective-C code to
C, and compiling the generated C code with 3rd party compiler. I have
managed to convert and compile a very simple hello application on my
Mac using Apple's runtime after having tweaked the generated code. I
have failed with anything more complex than the hello in one file.

What problem are you trying to solve?  If you want to compile ObjC  
code on OS X with a different compiler, then this is possible.  If you  
want to target a different platform, then you will need to tweak the  
rewriter to support the GNU runtime (not difficult, and something  
that's on my todo list, but very low down).

If you are targeting OS X, then you must have a good reason for  
picking your other compiler instead of GCC or LLVM.  Presumably  
language support isn't the reason.  If it is performance, then you  
will have some other issues since the rewriter does not produce  
particularly good code.  As I recall, it looks up the selectors from  
strings on every message send (which is very expensive) while this is  
usually done at module load time.  If you are using GNUstep instead of  
Cocoa then you will find most headers are safe to use with #include  
instead of #import (the FSF-GCC guys tried to drop support for #import  
a few years ago, made everyone change their code, and then realised  
that it was a silly idea since Apple weren't going to drop #import in  
their branch and break everyone's code), but third-party frameworks  
may not be.  One option here is to use the clang preprocessor and then  
the rewriter on the preprocessed output and then pass this to your  
other compiler.

David


Hi David,

I am trying to exploit optimizations of vendor specific compilers for  
an application with intensive mathematics. As I am ultimately  
targeting a different platform, it seems that I would have to tweak  
the rewriter, as well as write a new runtime because GNU runtime has  
license issues in commercial use when compiled with other compilers  
than GCC.

Thanks for your help!

/Dado

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20081113/ff6f8b68/attachment.html>


More information about the cfe-dev mailing list