The GNU Project has announced the release of GCC 5.1. The first major release of GCC 5 comes with many new features and improvements, including improved support for C++11/14, a new libstdc++ ABI, and a machine-code JIT embeddable library.
Among the most important changes introduced by GCC 5.1:
-
The C compiler defaults to
gnu11
instead ofgnu89
, the oldest ANSI ratified C standard. -
The C++ runtime introduces a new ABI, which is enabled by default and is the result of replacing existing classes with new C++11-compliant
std::string
andstd::list
classes, among other things. This change will not affect developers that rebuild all of their code, while developers that use third-party libraries that use the old ABI will need to use-D_GLIBCXX_USE_CXX11_ABI=0
. The new libstdc++ provides a dual ABI, which means that code built with an older GCC version will continue to work with the latestlibstdc++
. Providers of libraries and plugins may opt to support the same dual ABI concept, thus freeing developers from the need to rebuild their software. -
Better support for C++11 and C++14:
libstdc++
now fully supports C++11 and provides experimental support for C++14. Furthermore, G++ supports many C++14 features such as variable templates, aggregates with non-static data member initializers, sized deallocation functions, etc. -
GCC 5 provides an optional, complete implementation of Go 1.4.2.
-
GCC 5 can be built as a shared library, called
libgccjit
, to be embedded as a JIT-compiler to machine code. This option is still considered experimental and “shouldn’t be used in production yet.”, but it gives way to many interesting possilbities, such as building a machine-code compiler for a custom language in Python. It is not clear from the inspection of the official GCC 5.1 distribution if the same license exception that applies to the GCC runtime library also applies tolibgccjit
. The runtime library exception enables the production and distribution of programs that link the GCC runtime library without this requiring that those programs be released under the GPL3, GCC’s license. -
Finally, GCC 5.1 add many optimizations including the following: identical functions are unified in a new Identical Code Folding (ICF) pass; write-only variables are detected and optimized out; memory usage and link times have been improved; register allocation was improved; etc. You can get a more complete overview of the changes
GCC’s main competitor is LLVM, now at version 3.6. Phoronix ran a series of benchmarks to compare the pre-release version of GCC 5 against LLVM 3.5 and found that both compilers were comparable except in a few tests such as C-Ray multi-threaded ray-tracer, where GCC had the lead in performance. On the other hand, LLVM’s Clang ourperformed GCC in compilation time. The main defining difference between the two compilers is arguably the licensing model, though, since GCC is licensed under the GPL3 whereas LLVM applies a more MIT/BSD-like kind of license.