This is an archive of the discontinued LLVM Phabricator instance.

Make libc++'s libc++abi discovery work in the monorepo layout
AbandonedPublic

Authored by thakis on May 17 2019, 5:43 AM.

Details

Summary

The code currently checks for the presence of cxxabi.h in various
places to decide if libc++abi is getting built. In the monorepo layout,
that file is always present but libc++abi is only being built if it's
in LLVM_ENABLE_PROJECTS. So check LLVM_ENABLE_PROJECTS in monorepo
builds instead of checking for the presence of that file.

Diff Detail

Event Timeline

thakis created this revision.May 17 2019, 5:43 AM

The motivation here is being able to build libc++ against system libc++abi on macOS. We can explicitly define a few variables to get this to work, but with the old repo layout it Just Works. This is an attempt to make it just work with the monorepo layout as well.

smeenai added inline comments.May 17 2019, 12:17 PM
libcxx/CMakeLists.txt
150

This isn't quite true either. You could define LLVM_TOOL_LIBCXXABI_BUILD to OFF to prevent the build. It just defaulted to building instead of defaulting to not building.

152

Why do we need to check both of these?

153

What about LLVM_ENABLE_RUNTIMES? I think this might break that ... CC @phosek

thakis marked 3 inline comments as done.May 17 2019, 12:28 PM
thakis added inline comments.
libcxx/CMakeLists.txt
150

Isn't LLVM_TOOL_FOO_BUILD for stuff that went into llvm/tools in the old layout, while libcxx(abi) is in llvm/projects? I don't see references to LLVM_TOOL_ in llvm/projects/CMakeLists.txt.

152

It's what http://llvm-cs.pcc.me.uk/CMakeLists.txt#114 does, but give the previous comment we probably don't need to check the _USED one.

153

What's the difference between LLVM_ENABLE_RUNTIMES and LLVM_ENABLE_PROJECTS? They seem redundant to me at first glance.

But I suppose this should become if ("libcxxabi" IN_LIST LLVM_ENABLE_PROJECTS OR "libcxxabi" IN_LIST LLVM_ENABLE_RUNTIMES)?

thakis marked an inline comment as done.May 17 2019, 12:31 PM
thakis added inline comments.
libcxx/CMakeLists.txt
153

To rephrase this, what does it mean to have something in LLVM_ENABLE_RUNTIMES but not in LLVM_ENABLE_PROJECTS?

smeenai added inline comments.May 17 2019, 12:33 PM
libcxx/CMakeLists.txt
150

It ends up being used for both. llvm/project/CMakeLists.txt calls add_llvm_external_project, which calls add_llvm_subdirectory with the project argument set to LLVM and the type argument set to TOOL, which checks the LLVM_TOOL_*_BUILD variable.

153

The runtimes build does a two-stage where you build clang first and then use clang to build the runtimes. I believe that updated condition should be correct; @phosek can confirm that.

thakis marked 2 inline comments as done.May 17 2019, 12:46 PM
thakis added inline comments.
libcxx/CMakeLists.txt
150

Oh, subtle. Thanks for explaining. I added a comment mentioning that this isn't supported here yet; if someone wants to use LLVM_TOOL_LIBCXXABI_BUILD=NO they can add support at that point :)

153

Is this documented somewhere ? What is LLVM_ENABLE_PROJECTS set to in a runtimes build?

phosek added inline comments.May 20 2019, 11:51 AM
libcxx/CMakeLists.txt
153

LLVM_ENABLE_PROJECTS contains projects that are being built using the host compiler, LLVM_ENABLE_RUNTIMES contains projects that are being built using Clang that's built as part of the same build.

In our toolchain build for example, we would use:

-DLLVM_ENABLE_PROJECTS=clang;clang-tools-extra;lld -DLLVM_ENABLE_RUNTIMES=compiler-rt;libcxx;libcxxabi;libunwind

This means we build clang, clang-tools-extra and lld using the host compiler, and then use those to build compiler-rt, libcxx, libcxxabi and libunwind for all targets we support.

thakis abandoned this revision.Jul 8 2019, 5:37 AM

made obsolete by D63883 landing