Compiler wars: LLVM and GCC compete on speed, security

Newest revision of LLVM compiler framework battles with GCC on performance

The latest version of the LLVM 3.5 compiler infrastructure, version 3.5, is now available for download as it faces potential competition from the up-and-coming version 5 of the GCC (GNU Compiler Collection). It's also staring down the prospect of an alternate version hardened against errors and memory leaks by way of formal mathematical proofs.

LLVM isn't a compiler for a given language, but rather a framework that can be used to generate object code from any kind of source code. The project can target a broad variety of instruction sets, so it's a powerful way to develop compilers for a given language that span hardware types. Version 3.5's new features mostly target the ARM back end and the way code is emitted for MIPS and AArch64 processor architectures, but some languages have also recently added LLVM support. LDC, for example, uses LLVM to compile the D language.

LLVM's most direct competition comes from GCC, another other major open source compiler infrastructure. Both LLVM and GCC support a broad number of languages and libraries, including C/C++, but also Objective-C and Fortran. But the two are licensed and developed in markedly different ways.

While LLVM is licensed more permissively, using a three-clause license in the MIT/BSD mold, the project has gone from a University of Illinois endeavor to one more or less directly sponsored by Apple, which hired LLVM developer Chris Lattner back in 2005. Hence the use of LLVM as part of a new JavaScript engine created by Apple.

GCC, on the other hand, is GPL-licensed and has a few more restrictions attached to its reuse, but it's developed by a steering committee where the developers are chosen on a personal basis rather than company affiliation. That said, the presiding developers come from a broad range of companies, including IBM, Red Hat, Suse, Google, and Cisco.

LLVM and GCC have competed on performance as well. Historically, GCC has been credited with better performance, although the latest version of LLVM aims to close the gap. Phoronix ran a comparison of the pre-release version of GCC 5 against LLVM 3.5 and found the biggest differences were in C/C++ compile times -- with LLVM way out in front -- but noted that LLVM did poorly with some encryption algorithms (due to items that didn't land in LLVM 3.5 in time) and in many other cases lagged behind GCC by either a little or a lot.

LLVM has also recently inspired a project named Vellvm, where the design of the program and its output are both formally verified. The compiler's input and production can then be independently proven as consistent to defend against introduced bugs. The CompCert compiler already does this, but only for C; a formally verified version of LLVM could in theory do this for any language.

The need for this kind of integrity in both languages and compilers is becoming clearer. Mozilla's Rust language, for instance, has been designed from the inside out to allow the creation of both system-level software and higher-level applications (such as browser engines) that are nowhere nearly as vulnerable to bugs or memory leaks. Guess which back end Mozilla uses for the Rust compiler? LLVM.

This story, "Compiler wars: LLVM and GCC compete on speed, security" was originally published by InfoWorld.

Notice to our Readers
We're now using social media to take your comments and feedback. Learn more about this here.