Plugging into GCC
There are a lot of good reasons for wanting to add plugins to the GCC compiler. The implementation of better optimization techniques is an obvious example, but there is more than that. The EDoc++ project has put together a static analysis tool which performs checking of exception handling in C++ code - and generates documentation while it's at it. Mozilla uses its Dehydra tool to find potential problems in the browser's code base. The LLVM compiler can be thought of as a sort of GCC plugin, currently. The Middle End Lisp Translator project is working on a Lisp-like language which, in turn, can be used within plugins for static analysis and code transformations. The list goes on; just about any project working on the processing of programs can benefit from hooking into the GCC platform.
The concern that has long been expressed by the FSF (which owns the copyrights on GCC) is that a general plugin mechanism would make it possible for companies to traffic in binary-only GCC modules. Rather than contribute a new analysis or optimization tool - or a new language - to the community, companies might have an incentive to distribute their work separately under a restrictive license. That runs very much counter to what the FSF is trying to accomplish, so opposition from that direction is not particularly surprising.
But the pressure for some sort of plugin API is not going away, so the GCC developers have been thinking about ways to make it possible without upsetting Richard Stallman. One alternative which has been discussed is to require plugins to be written in a high-level scripting language - Python or Perl, perhaps. Then plugins would, for all practical purposes, have to be distributed in source form. Even if they carried a hostile license, it would be possible to study them and learn how they actually work.
Another possibility is to take a page from the Linux kernel's book and keep the plugin API unstable. If the API changed with every GCC release, GCC would become a moving target which would be much harder for proprietary vendors to keep up with. An unstable API may be the way things go in any case - there may be no other way to allow GCC itself to continue to progress quickly - but experience with the kernel shows that an unstable API is not, by itself, enough to scare off a determined proprietary software vendor. It might reduce the number of proprietary GCC modules, but it would not eliminate them.
Alternatively, one could require plugin modules to declare their license to the GCC core, which could then reject plugins that lack a suitable license. Again, experience with the kernel suggests that there are limits to how far one can get with this approach. Proprietary plugin vendors could distribute a version of GCC with the license check patched out - or just have their plugin lie about its license.
Yet another possibility is to not worry about the problem at all; it is not clear that the world is full of vendors waiting for an opportunity to abuse a GCC plugin API. As GCC developer Ian Lance Taylor puts it:
Someday, perhaps, the FSF will feel sufficiently confident to allow unrestricted plugin access to GCC, but that does not appear to be in the cards at this time.
What does appear to be happening, though, is an attempt to enable plugins by way of some licensing trickery. The GCC suite is covered by the GPL, a fact which does not, in itself, affect the licensing of any program which is compiled by GCC. But GCC is more than just the compiler; it also includes a runtime library needed to make most GCC-compiled programs actually run. Linking to the runtime library could cause the resulting program to be a derived product of that library; since the runtime library is licensed under the GPL, that could be a concern for anybody compiling non-GPL-licensed code. To address that concern, the runtime code has long carried an exception to the GPL:
That is the language which enables the distribution of proprietary software built with GCC. The plan, said to be under consideration currently, is to change the wording of that exemption; essentially, it would no longer apply to code compiled with the use of proprietary GCC plugins. The new license is not finalized, but Mr. Taylor guesses it will look something like this:
The actual wording of the new runtime license has been a long time in coming; the FSF's lawyers want to get it right so that it discourages undesired conduct while staying out of the way for everybody else. It also does not appear to be the FSF's highest priority at the moment. So nobody really knows when it might become official - though there have been notes to the list suggesting that it could happen in the near future.
What we do seem to know is that it will happen, sooner or later, and the
addition of a plugin mechanism to GCC will become possible. So the
developers are starting to think about how the API will work. There are a
couple of existing GCC plugin frameworks already, and plenty of thoughts on
how they could be improved; see, for example, this discussion for an idea of what is being
talked about. But the details are likely to be of interest mostly to GCC
hackers, while the end result will be beneficial to a much wider community
of developers and users.
