Initial *-rtems* Target Support

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.

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. :slight_smile:

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. :slight_smile:

And we can get some assistance to get over the hurdles
we might encounter trying to get a working clang built
RTEMS.

Thanks in advance.

clang-rtems-20110629.diff (4.85 KB)

llvm-rtems-20110629.diff (1.12 KB)

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. :slight_smile:

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. :slight_smile:

Looks fine to me. I've committee the patches to LLVM (r134282) and Clang (r134283).

  - Doug

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. :slight_smile:

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. :slight_smile:

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. :frowning:

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.