[LLVMdev] Purpose of LLVM_ENABLE_LIBCXX and LLVM_ENABLE_LIBCXXABI

Renato Golin renato.golin at linaro.org
Tue Jul 28 05:06:43 PDT 2015


On 28 July 2015 at 12:10, Schlottke-Lakemper, Michael
<m.schlottke-lakemper at aia.rwth-aachen.de> wrote:
> I am wondering about the meaning of the cmake flags LLVM_ENABLE_LIBCXX and LLVM_ENABLE_LIBCXXABI. Are they used to indicate that if the C/C++ compiler for building LLVM is clang, and if this clang has support for libc++ with libc++Abi, that both lib++ and libc++abi should be used (instead of linking to the default, which at least on Linux is libstdc++)? If not, what is the canonical way of building LLVM with libc++? I am asking since I seem to have problems linking libLLVMSupport.a to a program while using clang with libc++, whereas the used clang/LLVM compiler was originally built with clang and libstdc++.

Hi Michael,

Just cloning the libc++ / libc++abi / libunwind repositories in
llvm/projects (or symlinking them there) is enough for CMake to pick
it up, build and test on check-all. The libraries will be available on
build/lib.


> Related to the first question: do the above flags also make clang use libc++ by default, or is this configurable via a different set of flags?

No. I believe this is an old flag when that wasn't enable by default
(and now it's used to disable it if you have the dirs). But maybe
heavier users of libc++ can help you there.

You still have to use LDFLAGS="--stdlib=libc++ -lc++abi -lunwind" and,
if you're not installing it anywhere (but using the build directory),
add LD_LIBRARY_PATH=build/lib to your environment.

If you run into inconsistencies because libgcc_s / libgcc_eh are
included, or if libstdc++ is included as well, you may have to use
-nostdlibc++ to clean up the internal options, and then use --stdlib
and friends to create a new set.

It is confusing, but we don't want to make those libraries the default
on any environment that might still need/use libstdc++/libgcc by
default. This is more of a system-wide decision. For testing purposes,
though, it works well.

cheers,
--renato




More information about the llvm-dev mailing list