Using ELLCC

Using ecc as a cross compiler is as simple as adding the -target option. The -target option takes a configuration as an argument. A configuration is of the form
<arch>-<environment>

Available configurations are:

Processor -target option OS Endian Float
32 bit ARMv6 arm32v6-linux Linux Little Hard
32 bit ARMv6 arm32v6sf-linux Linux Little Soft
32 bit ARM arm32v7ebsf-linux Linux Big Soft
32 bit ARM arm32v7eb-linux Linux Big Hard
32 bit ARM arm32v7sf-linux Linux Little Soft
32 bit ARM arm32v7-linux Linux Little Hard
ARM Cortex-M3 cortex-m3-linux Linux Little Soft
64 bit ARM AArch64 arm64v8-linux Linux Little Hard
32 bit Mips mips32r2el-linux Linux Little Hard
32 bit Mips mips32r2elsf-linux Linux Little Soft
32 bit Mips mips32r2-linux Linux Big Hard
32 bit Mips mips32r2sf-linux Linux Big Soft
32 bit PowerPC ppc32-linux Linux Big Hard
32 bit X86 x86_32-linux Linux Little Hard
64 bit X86 x86_64-linux Linux Little Hard
32 bit X86 x86_32-w64-mingw32 Windows Little Hard
64 bit X86 x86_64-w64-mingw32 Windows Little Hard

You can either put the ~/ellcc/bin directory in your PATH or run ecc with a full path name. You can use the -target option to select the processor

~/ellcc/bin/ecc -target arm32v7-linux hello.c

or you can make a symbolic link like this

ln -s ecc arm32v7-linux-ecc

to avoid having to specify the “-target” explicitly.
Here is an example:

[~] main% cat hello.c
#include <stdio.h>

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

To compile a program, a typical command line looks like this:

[~] main% ~/ellcc/bin/ecc -target mips32r2-linux hello.c

This will create a Mips executable “a.out”, which you can run using the QEMU Linux user mode emulator for the Mips:

[~] main% ~/ellcc/bin/qemu-mips a.out
hello world
[~] main% 

All of these configurations are defined by configuration files in ellcc/libecc/config. These files are just text files in YAML format. You can make your own configuration by copying one of the existing files and modifying it as required.