Monthly Archives: July 2012

ELLCC is an easy to use Cross Compiler

One thing that I probably haven’t made clear enough is that ELLCC is designed to be an easy to use cross development environment. Let’s say you need to generate code that runs on various Linux targets. In the gcc world, you’d have to either build multiple copies of the gcc tool chain or find pre-built binary packages that support each of the targets individually. Life is much simpler in the ELLCC world.

Let’s say you have a program you want to build:


int main()
    printf("hello world\n");

On a Linux host you can use ecc to build in the normal way:

~] main% ecc hello.c
[~] main% ./a.out 
hello world
[~] main% file a.out
a.out: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, not stripped
[~] main%

Now, let’s say you want to target an ARM processor. The only difference is that you can specify the target on the command line:

[~] main% ecc -target arm-ellcc-linux hello.c
[~] main% qemu-arm a.out
hello world
[~] main% file a.out
a.out: ELF 32-bit LSB executable, ARM, version 1, statically linked, not stripped
[~] main%

Same for the Power PC:

[~] main% ecc -target ppc-ellcc-linux hello.c
[~] main% qemu-ppc a.out
hello world
[~] main% file a.out
a.out: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, not stripped
[~] main%

Note that I’m using QEMU’s Linux user mode emulation to run the programs for non-native targets. The results would be the same if you were to download the executables to your favorite smart phone.

ELLCC and the musl Standard C Library

ELLCC, my clang/LLVM based cross development tool chain for ARM, Microblaze, Mips, Power PC, and X86, now incorporates musl as its standard C library for Linux. musl is a MIT licensed, highly POSIX compliant library offering high performance and a small foot print. I spent several weeks evaluating musl before deciding to use it in ELLCC. The clarity and consistency of its code base and the quality of its design convinced me that musl would be an ideal addition to ELLCC. If you’re looking for a non-GPL library solution, I highly recommend musl.