[libcxx] Linking against just-built libcxxabi

On OS X 10.9.5, I can only get all libcxx tests to pass if I link
against the system libcxxabi. If instead, I link against the
just-built libcxxabi (using Apple LLVM version 6.0 based on LLVM 3.5),
I see the following test failures:

Failing Tests (9):
    libc++ :: std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
    libc++ :: std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
    libc++ :: std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
    libc++ :: std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
    libc++ :: std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp
    libc++ :: std/localization/locales/locale.global.templates/use_facet.pass.cpp
    libc++ :: std/localization/locales/locale/locale.cons/char_pointer.pass.cpp
    libc++ :: std/strings/basic.string/string.capacity/max_size.pass.cpp
    libc++ :: std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp

Error messages include:

libc++abi.dylib: terminating
libc++abi.dylib: terminating with uncaught exception of type
std::bad_cast: std::bad_cast
libc++abi.dylib: terminating with uncaught exception of type
std::runtime_error: locale constructed with null
libc++abi.dylib: terminating with uncaught exception of type std::bad_alloc
Assertion failed: (false), function main, file
std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp,
line 50.
Assertion failed: (new_handler_called == 1), function main, file
std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp,
line 42.

To link against the just-built library, I'm adding the following CMake define:

    -DLIBCXX_CXX_ABI_LIBRARY_PATH=../libcxxabi_install/lib

Am I building libcxxabi correctly? All tests in its own test suite
pass. Or perhaps is libcxxabi only supported for certain OS X
versions?

Thanks,
Greg

-llvmdev, +cfe-dev

Hi,

I'm seeing the exact same thing you are. The problem has to do with
how CMake links libc++. After *trying* to build against a just-built
libc++abi I ran otool -L over libc++.dylib and the output was as
followed:

../build-libcxx/lib/libc++.dylib:
@rpath/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libc++abi.dylib (compatibility version 1.0.0, current version 49.1.0)
@rpath/libc++abi.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)

So two different versions of libc++abi were linked into libc++.

I'll commit a fix for this in the coming days but until then you can
use the patch attached. That seemed to fix it for me.
Be very careful with what you do with your custom build libc++ and
libc++abi. Installing these in the wrong place can prevent your system
from booting.

/Eric

link.patch (1.62 KB)

I'll commit a fix for this in the coming days but until then you can
use the patch attached. That seemed to fix it for me.

Very cool. I just applied the patch and all tests are now passing, thanks!

Be very careful with what you do with your custom build libc++ and
libc++abi. Installing these in the wrong place can prevent your system
from booting.

Good to know, thanks again!

-Greg