Does the GPL extend to (cross-)compilers?

FOSSBazaar is no longer being updated. The information on this site is preserved for your convenience but may be out of date. Please visit Linux Foundation's Open Compliance Program for current information and activities.

ArnoudEngelfriet's picture

Access to the full source code is an essential aspect of open source software, perhaps even the most essential aspect of all. But what good is source code if it cannot be compiled into an executable? Fortunately this is rarely a problem. Most open source software is designed to compile with the well-known gcc compiler, a standard component of most Linux distributions. With dozens of supported platforms, it is rare to have open source that you can't compile. But when you do, can you demand a copy of the compiler from the developer?

One case where this may occur is with embedded systems development. Specific processors or target platforms may need substantial tweaking to gcc, or even a custom compiler or toolchain to produce usable executables. Now, suppose the developer incorporates GPLv2 code into the executable. According to GPLv2, he has to make available the full source code of the executable when he distributes it as part of his embedded system. So our developer dutifully includes a CD-ROM with the source code, including Makefile and configuration script and a copy of the GPLv2.

The customer now has the full source code and perhaps even the technical means to update the executable as it is stored on the embedded system. But without the custom compiler, that won't do him much good. So can the customer demand a copy of the compiler?

The compiler itself is not distributed by our developer, so even when the compiler is a derivative of gcc itself, there is no requirement from GPLv2 as it applies to the compiler to make the source code of the compiler available.

However GPLv2 provides some interesting requirements in its definition of "source code" for the executable program that is in the embedded system. To quote:

"The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable."

The "plus" items include the Makefile, configure scripts and similar items. But do these items include the compiler and linker? Apparently so, according to for example GPL-Violations.org:

"[In the case of cross-compilation for embedded platforms], you have to provide the the exact version of your compiler toolchain that was used to create the executables that you have distributed. Please note that in most cases this will be GNU GCC, which is itself GPL licensed, so the GPL obligations will in turn apply to the toolchain, and you must release the complete corresponding source code to it as well."

This conclusion is based on the next sentence of the part I quoted above. This sentence reads:

"the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs"

This sentence is intended to prevent needless distribution of standard components that any programmer will have access to. It talks about compilers. But read this sentence very carefully. Is the word 'compiler' mentioned as an example of "anything distributed with the major components of the OS" or as an example of a major component?

I respectfully submit it is the latter. In my interpretation, the clause is written for items such as libgcc, glibc and other standard items that are present on a typical developer's system. Although any program links with libgcc, there is no need to include a copy because any developer worth his salt will already have it.

In addition, remember that this sentence provides an exception to the previous sentence that talks about "scripts". The word "script" has a specific meaning to programmers. Wikipedia formulates it as follows: " "Scripts" are often treated as distinct from "programs", which execute independently from any other application."

The GPL is a very carefully drafted document. If Stallman had meant "programs" in the broadest sense, he would have written "programs". By using "scripts", it is clear to me that he was referring to the kind of item that is application-specific, such as Makefiles and configuration data (autoconfig input files, for example) and that you need in addition to the source code proper.

Is the (cross-)compiler required ? Seems it is

Nice article, thank you! Disclaimer: IANAL, this is not a legal advice, consult your lawyer, and so on... I'd like to add about your interpretation of the following sentence : "the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs" First, I agree with you that the word "compiler" is to be taken as an example of what a "major component" is. Second, and this is wheere it starts to be really interesting, you will have noticed how the sentence ends: "... on which the executable _runs_". This can be taken quite straightforwardly : for an embedded device, there is no (native) compiler embedded in the firmware, so the compiler is not "normally distributed (...) with the major components (...) of the operating system on which the executable runs" : there is *no* compiler on that operating system! Third, even if a cross-compiler for the CPU on the device can be (quite easily) found, most devices have specially crafted versions of gcc that takes into account the specifics of this very processor (new instructions, missing instructions, workarounds for hw-bugs...). So I take it that either a cross-compiler targeting the device, and/or a native compiler that runs on the device, do not belong to this "special exception", and thus any or both are required to be delivered. And if this compiler is based on GPL/LGPL code, the license applies to it as well... It is to be noted, that some vendors are starting to get those facts right, and are doing deliveries that are very good wrt GPL/LGPL compliancy. Hopefully, we'll see more and more of vendors following suite. Regards.
ArnoudEngelfriet's picture

Thanks for your

Thanks for your contribution. If I understand you correctly, you argue that the compiler should be a component of the target operating operating system if you want to qualify for the exception.

I can certainly see the argument, but I do not think it is evidently true. I'm not sure a major component of the OS necessarily is something that runs on the same OS as the executable. For an embedded OS, a tool to upload new versions to the hardware platform could well be the most important component, yet it is not part of the OS itself.

While I agree that it is desirable that companies release their modified compilers for the benefit of open source developers, I remain unconvinced that this is a legal requirement under GPLv2.