Changes between Initial Version and Version 1 of Projects/CLANG


Ignore:
Timestamp:
Jul 1, 2011, 6:17:22 PM (9 years ago)
Author:
JoelSherrill
Comment:

new page

Legend:

Unmodified
Added
Removed
Modified
  • Projects/CLANG

    v1 v1  
     1= CLANG =
     2
     3
     4
     5[[TOC(Projects/CLANG, depth=2)]]
     6
     7
     8This page is intended to capture notes and information about using [http://clang.llvm.org/ Clang] to compile RTEMS. 
     9
     10All supporting files, patches, replacement files, etc. needed should be in http://www.rtems.org/ftp/pub/rtems/people/joel/clang/.  If something is missing, let Joel know.
     11= Base Tools =
     12
     13
     14For now, you need the regular RTEMS toolchain installed.  We are using the normal RTEMS binutils and gdb.  In addition, the way I have been building requires using the CPU-rtems4.11-gcc as a helper wrapper.
     15= Building Clang =
     16
     17
     18Check out LLVM and Clang using the instructions at http://clang.llvm.org/get_started.html#build. In my case, I started in a working directory (''/users/joel/llvm'') and checked out into ''/users/joel/llvm/llvm''. After the checkout completed, I performed the following commands:
     19
     20{{{
     21cd /users/joel/llvm
     22mkdir b-llvm
     23cd b-llvm
     24../llvm/configure --prefix=/users/joel/llvm/install
     25make
     26make install
     27}}}
     28
     29After this completed, I ensured that my PATH included /opt/rtems-4.11/bin and /users/joel/llvm/install/bin for subsequent builds.
     30= Building Newlib With Clang =
     31
     32
     33I created a script file named ''/users/joel/llvm/j-newlib'' with the following contents.
     34
     35{{{
     36CPU=i386
     37../newlib-1.19.0/configure --host=${CPU}-rtems4.11 \
     38  --prefix=/users/joel/llvm/install \
     39  --with-newlib \
     40  CC="clang -ccc-host-triple ${CPU}-rtems4.11 -ccc-gcc-name ${CPU}-rtems4.11-gcc" \
     41  CC_FOR_TARGET="clang -ccc-host-triple ${CPU}-rtems4.11 -ccc-gcc-name ${CPU}-rtems4.11-gcc" \
     42  CC_FOR_BUILD="clang " \
     43  PONIES=true \
     44  AR=${CPU}-rtems4.11-ar \
     45  AS=${CPU}-rtems4.11-as >c.log 2>&1 && \
     46make -j4 >b.log 2>&1 && \
     47make install >i.log 2>&1
     48
     49echo $?
     50}}}
     51
     52newlib must be patched as appropriate for the version of RTEMS being built.
     53
     54I used the ''j-newlib'' script to build newlib as follows:
     55
     56{{{
     57cd /users/joel/llvm
     58mkdir b-newlib
     59cd b-newlib
     60sh -x ../j-newlib
     61}}}
     62
     63clang cannot build the file newlib/libc/sys/rtems/crt0.c.  There is a replacement of that file on the ftp site.  I am not sure if this is a clang bug, questionable code in crt0.c or a combination of the two.
     64= Building RTEMS =
     65
     66
     67I have not successfully built RTEMS yet.  I assume the problem is that I must pass in some combination of CC, CC_FOR_TARGET, and CC_FOR_BUILD in a way that makes the RTEMS build happy.
     68= References =
     69
     70 *  [http://clang.llvm.org/ Clang Page]
     71 *  [https://www.studentrobotics.org/trac/wiki/Beagleboard_DSP/Building TIC6x+Newlib Toolchain Build Instructions]