[cfe-dev] unraveling libcxxabi/libcxx

Howard Hinnant hhinnant at apple.com
Tue Apr 2 18:13:26 PDT 2013


On Apr 2, 2013, at 9:04 PM, David Fang <fang at csl.cornell.edu> wrote:

> Hi,
> 
>>> I'm currently looking into porting libcxx to an ancient system
>>> (powerpc-darwin8), and I noticed that libcxx depends on libcxxabi. However, libcxxabi's sources include headers like <exception> which are expected to be in some C++ library.  Does it (mutually) depend on libcxx? Maybe this was obvious, but I take it libcxxabi needs a c++11 compiler to build, correct?  (This would be fine, as I have stage-1 clang built from gcc-4.0/libstdc++.)  Does one {libcxx,libcxxabi} need to be installed before the other, or should they be built cross-referencing each others include dirs? In terms of shared-library dependencies, libcxx should link to libcxxabi, right?
>>> 
>>> Is there better documentation somewhere that I don't know about? All I see are html pages at http://libcxxabi.llvm.org and http://libcxx.llvm.org/.
>> 
>> Contributions to better documentation (and your experiences in doing this) are welcome. :-)
> 
> Sure, once I have a better understanding (and success). (And maybe along with it some Makefile/autotool files...)
> 
>> Yes, libcxxabi is the lower-level library.  libcxx should link to libcxxabi.
>> 
>> Yes, currently libcxxabi is using -std=c++0x and probably needs it, though I can't think offhand of a specific need.  If you need to, try changing that to -std=c++03.  If there's any breakage it will almost certainly be compile-time breakage.  So that is a safe experiment.
> 
> One symbol that is referenced is std::get_unexpected(), which is both new and deprecated in c++11.

Yeah, my motto is:  If you're going to standardize, do it with sense of humor. :-)

> Another c++11 symbol needed is std::get_terminate().  I discovered this when I tried to use g++-4.0's libstdc++ headers and got compilation errors.
> 
>> libcxxabi is designed to be ABI compatible with a gcc-4.2 era libstdc++. And therefore could almost certainly use a libstdc++-4.2 set of headers if need be to build against (another untested theory).
> 
> I also encountered:
> ../src/cxa_exception.hpp:66:9: error: unknown type name '_Unwind_Exception'
> 
> and a search led me to various versions of "unwind.h".
> The one in clang does some include_next magic.
> I did however find one buried in /usr/lib/gcc/powerpc-apple-darwin8/4.0.1/include/unwind.h
> with the needed typedef.
> I'm trying that now, but stop me if I'm going down a wrong path!

This is a serious problem.  The unwind library is a part of the Itanium ABI, a public specification of the API:  http://mentorembedded.github.com/cxx-abi/

But at this point in time, Apple does not open source this part of the API (to the best of my knowledge anyway).  There may or may not be other open source implementations of this part of the API, I honestly do not know (maybe others here do?).

> 
>> As libcxxabi is the lower-level library, I would go with installing that first.  But understand you're traversing territory where few have gone before.
> 
> I'll try this, pointing to libcxx's headers just for the prototypes that are needed from <exception>.  As you said, there should be no symbol dependence to libcxx.

<nod>

Howard




More information about the cfe-dev mailing list