[cfe-dev] unraveling libcxxabi/libcxx

David Fang fang at csl.cornell.edu
Wed Apr 3 17:31:25 PDT 2013


I also figured out how to run your testit script:

% env TRIPLE=powerpc-apple-darwin8 
CC=/Users/fang/local/src/LLVM-svn/gcc40-cmake-build/bin/clang++ 
HEADER_INCLUDE="-I/usr/local/experimental/llvm/lib/libcxxabi/include 
-I/usr/local/experimental/llvm/lib/libcxx/include/c++/v1" 
SOURCE_LIB="-L/usr/local/experimental/llvm/lib/libcxx/lib 
-L/usr/local/experimental/llvm/lib/libcxxabi -lc++abi" ./testit
/Users/fang/local/src/LLVM-svn/gcc40-cmake-build/bin/clang++ -std=c++0x 
-stdlib=libc++ -I/usr/local/experimental/llvm/lib/libcxxabi/include 
-I/usr/local/experimental/llvm/lib/libcxx/include/c++/v1 
-L/usr/local/experimental/llvm/lib/libcxx/lib 
-L/usr/local/experimental/llvm/lib/libcxxabi -lc++abi catch_array_01.cpp 
-o ./a.out
/usr/bin/ld: Undefined symbols:
___eprintf
clang-3.1: error: linker command failed with exit code 1 (use -v to see 
invocation)
catch_array_01.cpp failed to compile

I should also be able to change the variables to point to built 
directories instead of installed directories.

As for the link error, I found the ___eprintf symbol defined in 
/usr/lib/libstdc++.6.0.4.dylib, even though this symbol comes from 
<assert.h>. Apparently this symbol was provided in darwin8.

references:
http://www.opensource.apple.com/source/libstdcxx/libstdcxx-5.1/patches/eprintf.patch
http://gcc.gnu.org/ml/libstdc++/2005-11/msg00183.html
https://github.com/bdunogier/spotyxbmc2/blob/master/xbmc/osx/eprintf.cpp

For compatibility, I'll need to amend libc++ with the trivial 
implementation of ___eprintf for compatibility, as libstdc++ did.

Fang

> On OS X, you can:
>
> export DYLD_LIBRARY_PATH=<path-to-libcxx>/lib
> clang++ -std=c++11 -stdlib=libc++ -nostdinc++ -I<path-to-libcxx>/include -L<path-to-libcxx>/lib test.cpp
>
> (sub in libc++abi where appropriate).  The DYLD_LIBRARY_PATH symbol can contain multiple paths, using ':' as a separator.
>
> Howard




> On Apr 3, 2013, at 6:30 PM, David Fang <fang at csl.cornell.edu> wrote:
>
>> Hi Howard and all,
>>
>> I was able to build libcxxabi and libcxx on powerpc-darwin8.
>> I've documented my experiences here. http://www.csl.cornell.edu/~fang/sw/llvm/#libcxx
>>
>> I might need some explanation for how the test suite is expected to be run.  The 'testit' script in libcxxabi doesn't even refer to the libc++abi.dylib that was built, so there must be some implicit assumptions in this script?
>>
>> I'm hoping there's a way to test the dylib before having to install it.
>> Likewise with libc++.
>>
>> Fang
>>
>>> On Apr 2, 2013, at 8:35 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. :-)
>>>
>>> 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.
>>>
>>> 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).
>>>
>>> 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.
>>>
>>> Keep us posted, and blogs of your experience which might help future porters are welcome.
>>>
>>> Howard
>>>
>>
>> --
>> David Fang
>> http://www.csl.cornell.edu/~fang/
>>
>

-- 
David Fang
http://www.csl.cornell.edu/~fang/




More information about the cfe-dev mailing list