The default gcc (4.6.x) on Ubuntu 12.04 is quite old, especially given the quick advance in C++11 capabilities in gcc 4.7 and 4.8 (and, importantly, their respective libstdc++ libraries).

The LLVM project has recently decided (and implemented, earlier this week) to set gcc 4.7 and Clang 3.1 as the minimal versions LLVM & Clang themselves would build with, in order to be able to use C++11 capabilities in the implementation. Therefore, if you want to build trunk LLVM & Clang on Ubuntu 12.04, you need a newer gcc (even if you use Clang to self-build, still libstdc++ version 4.7 or later is required).

Luckily, building a new gcc and installing it locally (to not mess with the system installation) is fairly easy. Here's a short sequences of steps.

First, create a place to hold the installation, like $HOME/install/gcc-4.8.2.

You can also run gcc4.8 with the -### flag to see the exact compilation steps and notice which libraries get picked up, etc. (note that to see -lstdc++ a C++ source compiled with g++4.8 is needed instead).

As a bonus, trunk LLVM & Clang can be now build by passing this gcc to the configure script (the exact same idea works with the CMake-based configuration flow too):