ELLCC (pronounced “elk”), the embedded compiler collection based on clang/LLVM, has reached a major milestone: The ability to create C++ programs for several target processors using a set of libraries based on libraries with non-gnu licences.
ELLCC incorporates a C/C++ compiler based on clang/LLVM (ecc). The current supported target processors are ARM (both little and big endian), i386, Microblaze (the Xilinx softcore processor), Mips (both big and little endian), PowerPC (32 bit only for now), and x86_64.
The first test case, using the LLVM lit test framework, looks pretty simple:
// Compile and run for every target. // RUN: %armexx -o %t %s && %armrun %t | FileCheck -check-prefix=CHECK %s // RUN: %armebexx -o %t %s && %armebrun %t | FileCheck -check-prefix=CHECK %s // RUN: %i386exx -o %t %s && %i386run %t | FileCheck -check-prefix=CHECK %s // RUN: %microblazeexx -o %t %s && %microblazerun %t | FileCheck -check-prefix=CHECK %s // RUN: %mipsexx -o %t %s && %mipsrun %t | FileCheck -check-prefix=CHECK %s // RUN: %mipselexx -o %t %s && %mipselrun %t | FileCheck -check-prefix=CHECK %s // RUN: %ppcexx -o %t %s && %ppcrun %t | FileCheck -check-prefix=CHECK %s // FAIL: %ppc64exx -o %t %s && %ppc64run %t | FileCheck -check-prefix=CHECK %s // RUN: %x86_64exx -o %t %s && %x86_64run %t | FileCheck -check-prefix=CHECK %s // CHECK: foo.i = 10 // CHECK: bye #include <cstdio> class Foo { int i; public: Foo(int i) : i(i) { } int get() { return i; } ~Foo() { printf("bye\n"); } }; int main(int argc, char** argv) { Foo foo(10); printf("foo.i = %d\n", foo.get()); }
It does look pretty simple, but it represents:
- ecc compiled from clang/LLVM (near) current
- libc++ from the LLVM project built using ecc
- libc++ABI from the LLVM project built using ecc
- libunwind for handling non-static destructors and exceptions built using ecc
- musl for the standard C library built using ecc
- compiler-rt for low level processor support built using ecc
I have some more cleanup to do, but after that the next step will be a self hosted ELLCC.
Hint: You forgot to escape your < and > in the #include statement 😉
Is ELLCC just a “distribution” of a pre-configured LLVM, or does it include additional source code? And if yes, why is ELLCC not “integrated” to LLVM?
Hi David, Thanks for spotting the #include problem. ELLCC is more than just a pre-configured LLVM, although it is that. It also is pre-configured for binutils, gdb, and qemu and all the libraries. It is meant to be an easy to use cross development environment, not a replacement or fork of LLVM.
// FAIL: %ppc64exx -o %t %s && %ppc64run %t | FileCheck -check-prefix=CHECK %s
why is ppc64 failing ?
I had problems with ppc64 early on and temporarily stopped building it. It may be fine now, I just need to try it again.
That is pretty damn sweet. Thanks for marching this forwards, it is greatly anticipated and appreciated.