[cfe-dev] Initial *-rtems* Target Support

Joel Sherrill joel.sherrill at OARcorp.com
Mon Jul 4 07:30:21 PDT 2011


On 07/01/2011 05:41 PM, Douglas Gregor wrote:
> On Jun 30, 2011, at 2:07 PM, Joel Sherrill wrote:
>
>> Hi,
>>
>> Some of us over in the RTEMS community
>> (http://www.rtems.org) are curious about the
>> possibility of using clang to compile RTEMS.
>> For those who don't know RTEMS is an embedded
>> real-time operating system which targets about
>> 15 architectures and many more CPU models.
>> So this is the beginnings of investigating using
>> clang on RTEMS.
> Very cool.
>
>> As background, the RTEMS targets in gcc are usually
>> very close cousins to the bare metal targets like
>> CPU-*-elf* or CPU-*-eabi*.  We use newlib and build
>> newlib at the same time as gcc.
>>
>> clang does not support most of the architectures
>> supported by RTEMS.  The intersection is x86,
>> mips, powerpc, sparc, sparcv9, arm, thumb, and blackfin.
>> Iin some cases, it does not cover the architectural
>> variants we care most about.  For example, the
>> space community uses hardened SPARC V7 CPUs a lot
>> with RTEMS and only V8 is supported by clang right now.
>> The first goal is to get RTEMS itself to compile
>> with clang targeting i386 w/FPU.
>>
>> I have managed to get newlib built and installed using
>> clang to target i386-rtems4.11.  Building RTEMS is next
>> on the list and I will need assistance from others to
>> get through this hurdle.  In the interest of being open
>> and hopefully getting help, I am submitting patches
>> which should be OK to merge.  I don't think they are
>> too radical. :)
>>
>> The attached patches add initial *-*-rtems* target
>> support.  I modelled it after the FreeBSD support
>> which supports multiple architectures.
>>
>> I don't know what format you want commit logs in but
>> this is the information:
>>
>>     Add initial *-*-rtems* target.
>>
>> The only tricky part to the patch is that RTEMS tools
>> are never self-hosted so we do NOT want /usr/include
>> ever added to an include search path.  That's in
>> lib/Frontend/InitHeaderSearch.cpp around line 590.
>>
>> Hopefully this isn't too bad to get merged. :)
>
> Looks fine to me. I've committee the patches to LLVM (r134282) and Clang (r134283).
>
Well there appears to be one issue.   __rtems__ is not showing
up as defined.  :(

Hopefully this is the correct way to see the cpp predefines.

$ clang -ccc-host-triple i386-rtems4.11 -ccc-gcc-name i386-rtems4.11-gcc 
-dM -E - </dev/null | grep -i rtems

In tools/clang/lib/Basic/Targets.cpp around line 1679, I think I did the
right incantation to get it defined.  Any suggestions on what
I missed?

Thanks.

> 	- Doug


-- 
Joel Sherrill, Ph.D.             Director of Research&  Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
    Support Available             (256) 722-9985





More information about the cfe-dev mailing list