Error trying to build libc++abi, unknown type: _Unwind_Exception

On linux x64, I cannot build libc++abi, I get the following errors:

../src/cxa_exception.hpp:66:9: error: unknown type name '_Unwind_Exception'
        _Unwind_Exception unwindHeader;
        ^
../src/cxa_exception.hpp:100:9: error: unknown type name '_Unwind_Exception'
        _Unwind_Exception unwindHeader;
        ^
../src/cxa_default_handlers.cpp:33:13: error: use of undeclared identifier
      '_Unwind_Exception'
            _Unwind_Exception* unwind_exception =
            ^
../src/cxa_default_handlers.cpp:33:32: error: use of undeclared identifier
      'unwind_exception'
            _Unwind_Exception* unwind_exception =
                               ^
../src/cxa_default_handlers.cpp:34:34: error: unknown type name
      '_Unwind_Exception'
                reinterpret_cast<_Unwind_Exception*>(exception_header + 1) - 1;
                                 ^
../src/cxa_default_handlers.cpp:36:18: error: use of undeclared identifier
      'unwind_exception'; did you mean 'native_exception'?
                (unwind_exception->exception_class & ...
                 ^~~~~~~~~~~~~~~~
                 native_exception
../src/cxa_default_handlers.cpp:35:18: note: 'native_exception' declared here
            bool native_exception =
                 ^
../src/cxa_default_handlers.cpp:36:36: error: member reference type 'bool' is
      not a pointer
                (unwind_exception->exception_class & ...
                 ~~~~~~~~~~~~~~~~ ^
../src/cxa_default_handlers.cpp:41:21: error: use of undeclared identifier
      'unwind_exception'; did you mean 'native_exception'?
                    unwind_exception->exception_class == ...
                    ^~~~~~~~~~~~~~~~
                    native_exception
../src/cxa_default_handlers.cpp:35:18: note: 'native_exception' declared here
            bool native_exception =
                 ^
../src/cxa_default_handlers.cpp:41:39: error: member reference type 'bool' is
      not a pointer
                    unwind_exception->exception_class == ...
                    ~~~~~~~~~~~~~~~~ ^
9 errors generated.

This is fixed by adding -I /usr/lib/gcc/x86_64-linux-gnu/4.6/include
on my (ubuntu 12.04) machine.

There's another error related to __mode__(__unwind_word__) that I
fixed by applying the patch here:
http://llvm.org/bugs/show_bug.cgi?id=8703

Now it gets stuck on:

../src/cxa_demangle.cpp:5244:1: error: declaration of anonymous class must be a
      definition
class __int128
^
../src/cxa_demangle.cpp:5244:1: warning: declaration does not declare anything
      [-Wmissing-declarations]
class __int128
^~~~~
1 warning and 1 error generated.

__int128 is a GNU keyword which clang 3.1 supports. This usage of it as an identifier will need to be renamed.

Thanks, done. Committed revision 155044.

Howard

Thanks Howard,

I can now build libcxxabi.

However, I can't link it "/usr/bin/ld: cannot find -lc++" (verbose
output below) which is the same error I get trying to compile a hello
world with libc++ and the reason I tried building libcxxabi in the
first place :S

I've spent hours searching about this on google and trying things, but
so far I've made no progress.

Cheers,
Dan

...
clang version 3.1 (trunk 154706)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang: warning: argument unused during compilation: '-nodefaultlibs'
"/usr/bin/ld" -z relro --hash-style=gnu --build-id --eh-frame-hdr -m
elf_x86_64 -shared -o libc++abi.so.1.0
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crti.o
/usr/lib/gcc/x86_64-linux-gnu/4.6/crtbeginS.o
-L/usr/lib/gcc/x86_64-linux-gnu/4.6
-L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu
-L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu
-L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../.. -L/lib -L/usr/lib
abort_message.o cxa_aux_runtime.o cxa_default_handlers.o
cxa_demangle.o cxa_exception.o cxa_exception_storage.o cxa_guard.o
cxa_handlers.o cxa_new_delete.o cxa_personality.o cxa_unexpected.o
cxa_vector.o cxa_virtual.o exception.o private_typeinfo.o stdexcept.o
typeinfo.o -soname libc++abi.so.1 -lpthread -lrt -lc -lc++ -lgcc
--as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s
--no-as-needed /usr/lib/gcc/x86_64-linux-gnu/4.6/crtendS.o
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crtn.o
/usr/bin/ld: cannot find -lc++