Chris Lattner Offered LLVM to GCC in 2005. Richard Stallman Didn’t See the Email Until 2015.

Chris Lattner speaking at FOSDEM 2011, next to a simple diagram of three front ends and three back ends meeting at one central block.


In November 2005, Chris Lattner offered to make LLVM part of GCC, the GNU Compiler Collection. LLVM was the compiler infrastructure he had started as a graduate student at the University of Illinois. Writing from his new Apple email address, he proposed code that would let GCC hand programs to LLVM’s optimizer and code generator. He also floated something bigger: if GCC’s developers wanted LLVM for the long term, LLVM’s own copyright could go to the Free Software Foundation (FSF).

LLVM never made it into GCC. On 9 February 2015, Richard Stallman, who founded the free-software GNU Project and the FSF, was shown the old proposal during a discussion about Emacs and said he had never seen it. “I am stunned to see that we had this offer,” he wrote. “Now, based on hindsight, I wish we had accepted it.”

By then LLVM no longer needed GCC. It sat underneath Apple’s developer tools, the Swift language and the Rust compiler, and how it got there says more about a design decision made in 2000 than about one missed email.

A thesis about compiling more than once

LLVM began as a research project at the University of Illinois at Urbana-Champaign, where Lattner was a research assistant from 2000, working with Vikram Adve. From its beginning in December 2000, Lattner later wrote, LLVM “was designed as a set of reusable libraries with well-defined interfaces.” His 2002 master’s thesis described a low-level virtual instruction set that keeps type information, so a program can be optimized not only when it is compiled but also at link time, after linking, at run time and during idle time on the machine.

LLVM 1.0 was announced on 24 October 2003, “under a non-restrictive open source license,” after three years of work at Illinois. A 2004 paper by Lattner and Adve introduced the project as “LLVM (Low Level Virtual Machine).” The expansion has since been dropped, and the project’s website is blunt: “Despite its name, LLVM has little to do with traditional virtual machines. The name ‘LLVM’ itself is not an acronym; it is the full name of the project.”

One representation in the middle

In a chapter he wrote for the book “The Architecture of Open Source Applications,” Lattner starts from the classic three-phase compiler, “whose major components are the front end, the optimizer and the back end.” The front end understands a programming language, the back end understands a processor, and the optimizer works in between. Without a shared form in the middle, he wrote, “supporting N targets and M source languages would need N*M compilers.” With one, a new language needs only a front end and a new processor only a back end.

LLVM’s shared middle is LLVM IR, its intermediate representation, which Lattner calls “both well specified and the only interface to the optimizer.” It exists as readable text, as a data structure in memory and as a compact binary “bitcode” file. Because the IR can be written as text, one optimization can be tested on its own: the chapter’s example feeds a few lines of IR to a tool called opt, runs a single constant-propagation pass and checks that adding 4 and 5 comes out as 9.

GCC, by contrast, was hard to take apart. Its back end walked the front end’s syntax trees to produce debugging information, and its code relied heavily on global variables. “It is not realistically possible to embed GCC into other applications,” Lattner wrote. LLVM’s pieces could be lifted out and reused.

The offer

Lattner finished his Ph.D. in 2005 and joined Apple’s developer tools group that summer. His message to the GCC mailing list on 18 November 2005, “LLVM/GCC Integration Proposal,” was concrete. A configuration option, –enable-llvm, would replace GCC’s own optimizers and code generator with LLVM’s, and about 4,000 lines of C++ would translate GIMPLE, one of GCC’s internal representations of a program, into LLVM IR.

The new code would use the GNU General Public License (GPL): “The patch I’m working on is GPL licensed and copyright will be assigned to the FSF,” Lattner wrote. LLVM itself would “not initially be assigned to the FSF”; it kept “a BSD-like license,” permissive terms similar to those of the Berkeley Software Distribution (BSD). The bigger step had a condition: “If people are seriously in favor of LLVM being a long-term part of GCC,” he wrote, “I personally believe that the LLVM community would agree to assign the copyright of LLVM itself to the FSF.”

Twenty-three replies followed, seven of them from Lattner, most on technical questions; Stallman did not post. In another thread, GCC developer Diego Novillo wrote that the lack of an FSF copyright assignment for LLVM “must absolutely be resolved before we even think of adding LLVM to any branch.” In March 2006, asked by GCC developer Mark Mitchell about the assignment, Lattner replied that forms had apparently been sent out, but he had not seen them yet. The record does not show the assignment being completed.

Building beside GCC

On 11 July 2007 Lattner announced that Apple had approved open-sourcing “the new C front-end for LLVM we’ve been working on.” Called Clang, it was built, like LLVM, “as a set of reusable libraries.” Mac OS X 10.8 and iOS 6, his résumé says, “were built with Clang.”

In July 2010 he started a new programming language and, as he puts it, “implemented much of the basic language structure in secrecy.” Apple announced Swift on 2 June 2014. Its compiler hands code to LLVM, “at which point LLVM can continue to optimize it and generate machine code,” Swift’s documentation says. Rust’s compiler guide says much the same of rustc: “Usually, rustc uses LLVM for code generation, but there is also support for Cranelift and GCC.”

Stunned, nine years later

The 2005 email resurfaced on emacs-devel, the Emacs developers’ mailing list, in a thread about supporting LLDB, the LLVM project’s debugger, in Emacs. Stallman opposed the change; as the Linux news site LWN.net reported, he saw “a systematic effort to attack GNU packages.” LLVM’s license was compatible with the GPL, LWN noted, but it lacked copyleft, the rule that modified versions must stay under the same free license. Another participant, Liang Wang, then pointed to Lattner’s old offer.

Stallman asked for a copy of the 2005 message. His reply, quoted at the top of this article, ends: “I wish I had known about the offer. Oh well.” The record, then, does not show Stallman turning Lattner down.

What the missed email does not explain

It is tempting to read the whole history through that missed message. The record does not support that reading: what GCC developers asked for first was paperwork, a copyright assignment that was still unfinished months later.

What the record does show is a choice made five years before the email. A compiler built as libraries around one well-specified intermediate representation could be reused without GCC at all, as Clang, Swift and the Rust compiler later showed. Infrastructure travels as far as its interfaces let it. Could someone else use the pieces of what you are building without taking the whole thing?

Related stories

Sources

Share this article
FacebookThreadsLinkedInX

Leave a Reply

Your email address will not be published. Required fields are marked *