| Both sides previous revision Previous revision Next revision | Previous revision |
| newc_stack [2012/05/24 08:04] – theraven | newc_stack [2013/09/19 11:45] (current) – theraven |
|---|
| ====== The New C++11 Stack ====== | ====== The New C++11 Stack ====== |
| |
| %%FreeBSD%% 10 aims to ship with a new C++ stack, replacing the old GNU one. Hopefully a preview of this will appear somewhere along the 9.x series. | %%FreeBSD%% 10 ships with a new C++ stack, replacing the old GNU one. |
| |
| ===== Rationale ===== | ===== Rationale ===== |
| Why do we need a new C++ stack? There are two main reasons: functionality and licensing. %%FreeBSD%% 9.0 includes the last GPLv2 (+ linking exemption) release of GNU libstdc++. GPLv2 isn't ideal for %%FreeBSD%% and GPLv3 (the license of the newer versions) is considered unacceptable, so a replacement is desirable. | Why do we need a new C++ stack? There are two main reasons: functionality and licensing. %%FreeBSD%% 9.0 includes the last GPLv2 (+ linking exemption) release of GNU libstdc++. GPLv2 isn't ideal for %%FreeBSD%% and GPLv3 (the license of the newer versions) is considered unacceptable, so a replacement is desirable. |
| |
| This year, a new version of the C++ standard was introduced. C++11 is not supported at all by the 2007 version of libstdc++ that we currently ship, yet is going to be important moving forward. | In 2011, a new version of the C++ standard was introduced. C++11 is not supported at all by the 2007 version of libstdc++ that we currently ship, yet is going to be important moving forward. |
| |
| ===== Overview ===== | ===== Overview ===== |
| * [[https://github.com/pathscale/libcxxrt|libcxxrt]] as the ABI library | * [[https://github.com/pathscale/libcxxrt|libcxxrt]] as the ABI library |
| |
| These components have all been imported into the base system in -CURRENT. | These components have all been imported into the base system in -CURRENT. They were merged into 9-STABLE prior to 9.1 and are in 9.1 and later, but libc++ is not built by default in 9.x. They are all built by default in 10.0, replacing their GNU equivalents, on any platforms where clang is the default compiler. Our old GCC is not capable of building libc++ (which uses C++11 internally), so this stack is not built by default on other architectures. |
| |
| ===== Building the New Stack ===== | ===== Building the New Stack on 9.x ===== |
| |
| Because libc++ uses a number of C++11 features, it needs to be built with a compiler that supports C++11. Currently, the base system defaults to building with gcc. You need to follow the instructions for [[BuildingFreeBSDWithClang|building with clang]] to switch to a more modern compiler. You also need to add this line to ''%%/etc/make.conf%%'': | Because libc++ uses a number of C++11 features, it needs to be built with a compiler that supports C++11. In 9.x, the base system defaults to building with gcc. You need to follow the instructions for [[BuildingFreeBSDWithClang|building with clang]] to switch to a more modern compiler. You also need to add this line to ''%%/etc/make.conf%%'': |
| |
| <code> | <code> |
| </code> | </code> |
| |
| ===== Using the New Stack ===== | ===== Using the New Stack on 9.x ===== |
| |
| To use the new stack, you will need to use ''%%clang++%%'' as your C++ compiler and linker-driver. Add ''%%-stdlib=libc++%%'' to your compile and link flags and, in theory, it will Just Work™. In practice, please report any problems that you encounter to theraven@. | To use the new stack, you will need to use ''%%clang++%%'' as your C++ compiler and linker-driver. Add ''%%-stdlib=libc++%%'' to your compile and link flags and, in theory, it will Just Work™. In practice, please report any problems that you encounter to theraven@. |