Why does FreeBSD use GCC as its default compiler?

I am under the impression that a core pillar of the FreeBSD philosophy is not to use any GNU software and in particular, GPL code.

Yet GCC which is both GNU and GPL comes bundled with FreeBSD.


2 Answers 2


FreeBSD 10 will use the BSD-licensed Clang compiler instead of GCC for 32- and 64-bit Intel x86 systems. The only thing preventing a wholesale switch on all CPU platforms FreeBSD releases on is developer time and interest.

As for FreeBSD 9 — which was just about to be released when this question was first posed — there was talk about making Clang the default compiler, but there were enough problems with it that they decided to ship Clang alongside GCC, and leave GCC the default for this release.

As for why FreeBSD didn't try moving to a non-GPL compiler years before, or perhaps even create their own, the reason is simple: it's hard.

Any undergrad CS student can write a compiler — it may even be a course requirement — but writing a good compiler is hard. Writing a good compiler is harder still when it needs to be for a language like C or C++. The task becomes still harder when you make the reasonable decision that the new compiler needs to at least approach the performance and capability of GCC, which has a couple of decades worth of development behind it.

Because of that, GCC 4.2 is still the default compiler on FreeBSD 9.

GCC 3.4, 4.4, 4.6, 4.7, and 4.8 are in the FreeBSD 9 Ports tree, by the way, and some version of GCC is likely to remain in Ports for many years to come. There's a lot of software packages out there — many of which are in FreeBSD Ports — which only build with GCC.

  • 1
    The compiler must not only be at least close to the performance but also language extensions have to be supported. Developers often use those for some reason (or none ;-))
    – johannes
    Nov 9, 2012 at 21:32

It's likely out of necessity. Until recently, the BSD-licensed C compilers were probably few or didn't come close to feature parity with gcc.

From FreeBSD Project Goals:

That code in our source tree which falls under the GNU General Public License (GPL) or Library General Public License (LGPL) comes with slightly more strings attached, though at least on the side of enforced access rather than the usual opposite. Due to the additional complexities that can evolve in the commercial use of GPL software we do, however, prefer software submitted under the more relaxed BSD copyright when it is a reasonable option to do so.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.