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:

#include 

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.

3 thoughts on “ELLCC is an easy to use Cross Compiler

Leave a Reply

Your email address will not be published.