ELLCC

Setting Up Target Support

Home
Blog
News
Documentation
Installation
Target Support
Bug Database
Source Repository
Contact
Setting up target support means building the appropriate libraries to support cross compilation of programs using ELLCC. You should have completed the ELLCC Installation steps before you try to setup target support as the ecc compiler is required at this point.

Building the Run Time Libraries

The ELLCC C run time library, libecc, is based on source code from several sources. The C standard library is based on the NetBSD C library. Support for operations, such as 64 bit additions and floating point, that a target does not support directly are provided by the LLVM project's compiler-rt.

Now build the libraries:

[~/ellcc] main% cd libecc/obj
[~/ellcc/libecc/obj] main% make install

This will build and install libraries for all the supported processors and operating systems. The bin directory should look something like this:

[~/ellcc] main% ls bin
arm-elf-as*          ecc-ranlib*       llvm-size*              qemu-ga*
arm-elf-ecc@         ecc-readelf*      llvm-stub*              qemu-i386*
arm-linux-ecc@       ecc-size*         llvm-tblgen*            qemu-img*
arm-netbsd-ecc@      ecc-strings*      macho-dump*             qemu-io*
armv7-elf-ecc@       ecc-strip*        microblaze-elf-as*      qemu-microblaze*
armv7-linux-ecc@     i386-elf-as*      microblaze-elf-ecc@     qemu-mips*
armv7-netbsd-ecc@    i386-elf-ecc@     microblaze-linux-ecc@   qemu-mipsel*
armv7sf-elf-ecc@     i386-linux-ecc@   microblaze-netbsd-ecc@  qemu-nbd*
armv7sf-linux-ecc@   i386-netbsd-ecc@  mips32r2-elf-ecc@       qemu-ppc*
armv7sf-netbsd-ecc@  llc*              mips32r2-linux-ecc@     qemu-ppc64*
bugpoint*            lli*              mips32r2-netbsd-ecc@    qemu-ppc64abi32*
c-index-test*        llvm-ar*          mips32r2sf-elf-ecc@     qemu-sparc*
clang-tblgen*        llvm-as*          mips32r2sf-linux-ecc@   qemu-system-arm*
ecc*                 llvm-bcanalyzer*  mips32r2sf-netbsd-ecc@  qemu-system-microblaze*
ecc++@               llvmc*            mips-elf-as*            qemu-system-mips*
ecc-addr2line*       llvm-config*      mips-elf-ecc@           qemu-system-mipsel*
ecc-ar*              llvm-config-2*    mips-linux-ecc@         qemu-system-ppc*
ecc-as*              llvm-cov*         mips-netbsd-ecc@        qemu-system-ppc64*
ecc-c++filt*         llvm-diff*        opt*                    qemu-system-sparc*
ecc-elfedit*         llvm-dis*         ppc64-elf-as*           qemu-system-x86_64*
ecc-embedspu*        llvm-dwarfdump*   ppc64-elf-ecc@          qemu-x86_64*
ecc-gdb*             llvm-extract*     ppc64-linux-ecc@        sparc-elf-as*
ecc-gdbserver*       llvm-ld*          ppc64-netbsd-ecc@       sparc-elf-ecc@
ecc-gdbtui*          llvm-link*        ppc-elf-as*             sparc-linux-ecc@
ecc-gprof*           llvm-mc*          ppc-elf-ecc@            tblgen*
ecc-ld*              llvm-nm*          ppc-linux-ecc@          x86_64-elf-as*
ecc-ld.bfd*          llvm-objdump*     ppc-netbsd-ecc@         x86_64-elf-ecc@
ecc-nm*              llvm-prof*        qemu*                   x86_64-linux-ecc@
ecc-objcopy*         llvm-ranlib*      qemu-arm*               x86_64-netbsd-ecc@
ecc-objdump*         llvm-rtdyld*      qemu-armeb*


Symbolic links have been added to ecc for every processor/operating system for which libraries have been successfully built. You can use the appropriate symbolic link to run the compiler and the appropriate include files and libraries will be used to build your programs.

A Quick Sanity Check

I use the bzip2 program as an initial sanity check for all the processors. I've modified the Makefile to build bzip2 for each processor and run it under QEMU. If the make succeeds, you are in business.

[~/ellcc/test] main% cd ..
[~/ellcc] main% cd test/src/bzip2-1.0.6/
[~/ellcc/test/src/bzip2-1.0.6] main% make
...
[Several builds and runs of bzip2]
...
If you got this far and the 'cmp's didn't complain, it looks
like you're in business. 

To install in /usr/local/bin, /usr/local/lib, /usr/local/man and
/usr/local/include, type

   make install

To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type

   make install PREFIX=/xxx/yyy

If you are (justifiably) paranoid and want to see what 'make install'
is going to do, you can first do

   make -n install                      or
   make -n install PREFIX=/xxx/yyy      respectively.

The -n instructs make to show the commands it would execute, but
not actually execute them.

Instructions for use are in the preformatted manual page, in the file
bzip2.txt.  For more detailed documentation, read the full manual. 
It is available in Postscript form (manual.ps), PDF form (manual.pdf),
and HTML form (manual.html).

You can also do "bzip2 --help" to see some helpful information.
"bzip2 -L" displays the software license.

make[1]: Leaving directory `/home/rich/ellcc/test/src/bzip2-1.0.6'
[~/ellcc/test/src/bzip2-1.0.6] main%

A More Complete Sanity Check

I've started to add unit and regression testing to ELLCC. The tests compile and run various programs for all the ELLCC targets as well as two sanity checks. For the first sanity check, libecc and the test programs are built by gcc rather than ecc and the entire test suite is run on the gcc compiled versions. The second sanity check involves running the test suite compiled by gcc but using the normal host libraries.

You can run the regression tests by going into the tests/obj directory:

[~/ellcc] main% cd test/obj
[~/ellcc/test/obj] main% ls
arm/    armv7sf/  host/  Makefile     mips/      mips32r2elsf/  mipsel/  pic32/  ppc64/  x86_64/
armv7/  gcc/      i386/  microblaze/  mips32r2/  mips32r2sf/    nios2/   ppc/    sparc/  x86_64.cov/

The various directories target the specific targets. The gcc/libecc tests are built under the gcc direcory and the gcc/hostlib tests are built under the host directory. Executables in these directories are run natively on the build system. The rest of the directories are used to build the target specific binaries that are run using the target specific qemu emulator.

To run the tests, simply type:

[~/ellcc/test/obj] main% make check

You'll get a lot of output but if the compilation and execution of each test works, the entire test run should complete without error.

...
PASS: 001wctype.c:432: Wchar(Ctype): Group XDIGIT IS xdigit
PASS: 001wctype.c:436: Wchar(Ctype): wctype(nonsense type) == 0
PASS: 001wctype.c:439: Wchar(Ctype): Map from UC to LC towlower
PASS: 001wctype.c:440: Wchar(Ctype): Map from ALLUC to ALLLC towlower
PASS: 001wctype.c:442: Wchar(Ctype): Map from LC to UC towupper
PASS: 001wctype.c:443: Wchar(Ctype): Map from ALLLC to ALLUC towupper
PASS: 001wctype.c:448: Wchar(Ctype): Map from UC to LC tolower
PASS: 001wctype.c:449: Wchar(Ctype): Map from ALLUC to ALLLC tolower
PASS: 001wctype.c:450: Wchar(Ctype): Map from LC to UC toupper
PASS: 001wctype.c:451: Wchar(Ctype): Map from ALLLC to ALLUC toupper
PASS: 001wctype.c:454: Wchar(Ctype): wctrans(nonsense trans) == 0
PASS: 001wctype.c:455: Wchar(Ctype): wctrans(tolower) != 0
Wchar unit tests completed
    457 tests run
    0 tests failed
make[4]: Leaving directory `/home/rich/ellcc/test/obj/x86_64/linux/libs/wchar'
make[3]: Leaving directory `/home/rich/ellcc/test/obj/x86_64/linux/libs'
make[2]: Leaving directory `/home/rich/ellcc/test/obj/x86_64/linux'
make[1]: Leaving directory `/home/rich/ellcc/test/obj/x86_64'
[~/ellcc/test/obj] main%

The sources for the various tests are under the test/src directory.

Good luck!