libc++ has landed

David Chisnall theraven at freebsd.org
Wed May 23 09:32:58 UTC 2012


Hi Everyone,

I have just finished merging libc++ and all of the things that it depends on into 9-STABLE.  Since 9.1 is due to branch Real Soon Now™, it would be good if it could see a bit of testing before then.  Because it uses C++11, libc++ will only work if built with clang, so it is disabled in the default build for now.  To build it, you will need to add the following to your /etc/src.conf:

CC=clang
CXX=clang++
CPP=clang-cpp
WITH_LIBCPLUSPLUS=yes

You can then just make && make install in lib/libcxxrt and lib/libc++.  This requires a (very) recent libc, containing the xlocale APIs, so you'll also need to reinstall lib/libc and include.  If you want to try mixing libstdc++ and libc++, then you will need to also recompile / install libstdc++ from stable.  This depends on some rtld-elf fixes, so it's probably worth rebuilding world to make sure that you have everything.  

Once all of this is installed, there are two things you can test.  The simplest is the libstdc++ / libcxxrt combination.  To do this, just add this to /etc/libmap.conf:

libsupc++.so.1  libcxxrt.so.1

This will use libcxxrt instead of libsupc++.  These libraries implement the low-level parts of C++ (RTTI, exceptions, and so on).  The other thing that you can try is compiling other C++ code using libc++.  This is trivial to do with clang++, just add -stdlib=libc++ to both your CXXFLAGS and LDFLAGS.

David


More information about the freebsd-stable mailing list