[libcxx-commits] [PATCH] D120719: [runtimes] Always configure libc++abi before libc++

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 4 09:45:15 PST 2022


ldionne added a comment.

In D120719#3360285 <https://reviews.llvm.org/D120719#3360285>, @beanz wrote:

> In D120719#3359971 <https://reviews.llvm.org/D120719#3359971>, @ldionne wrote:
>
>> For example, we use `add_subdirectory()` and expect that it's going to set up some targets, which we then use after the call to `add_subdirectory()`. It's just how CMake works -- it is not sufficiently declarative to be fully order independent.
>
> I'm curious what you mean by this. There are lots of ways that CMake allows you to reference targets before they are defined. The only things you really can't do are check if a target exists and query target properties. Many places where you do those two things can be converted to generator expressions and resolved at generation time instead.

For instance, in D120727 <https://reviews.llvm.org/D120727>, I do:

  if (TARGET cxxabi_shared)
    add_library(libcxx-abi-shared ALIAS cxxabi_shared)
  endif()

Assuming we don't enforce that libc++abi is configured before libc++, it's possible that `cxxabi_shared` doesn't exist when we get to that line. If CMake were a bit more lazy, I could just drop the `if (TARGET` and write this instead:

  add_library(libcxx-abi-shared ALIAS cxxabi_shared)

But in the current state of things, CMake fails to configure because it doesn't know about `cxxabi_shared` yet:

  CMake Error at /Users/ldionne/code/llvm/libcxx/cmake/Modules/HandleLibCXXABI.cmake:115 (add_library):
    add_library cannot create ALIAS target "libcxx-abi-shared" because target
    "cxxabi_shared" does not already exist.
  Call Stack (most recent call first):
    /Users/ldionne/code/llvm/libcxx/CMakeLists.txt:509 (include)

I don't really know how to work around that. Also note that I don't want to do

  add_library(libcxx-abi-shared INTERFACE)
  target_link_libraries(libcxx-abi-shared INTERFACE cxxabi_shared)

or something similar, because I need the original properties of `cxxabi_shared` to be forwarded through (for example I need to be able to get the `TARGET_LINKER_FILE` of `libcxx-abi-shared`).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120719/new/

https://reviews.llvm.org/D120719



More information about the libcxx-commits mailing list