[clang] [libc] [libcxx] [libc][libcxx] Support for building libc++ against LLVM libc (PR #99287)

Petr Hosek via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 18 01:11:45 PDT 2024


================
@@ -293,6 +293,7 @@ option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON)
 option(LIBCXX_ENABLE_MONOTONIC_CLOCK
   "Build libc++ with support for a monotonic clock.
    This option may only be set to OFF when LIBCXX_ENABLE_THREADS=OFF." ON)
+option(LIBCXX_USE_LLVM_LIBC "Build libc++ against LLVM libc." OFF)
----------------
petrhosek wrote:

I introduced `LIBCXX_LIBC` which currently accepts `system` or `llvm-libc`. `system` is currently no-op but that can be expanded later. In the future we may also want to introduce additional options e.g. `musl` replacing the existing `LIBCXX_HAS_MUSL_LIBC` option but I'd prefer to do it in a separate change. 

I'm not sure if it's better to set the `-nostdlibinc` and `-nolibc` on the libc side (as interface flags on the targets) or on the libc++ side (as interface flags on the proxy targets), I can see an argument for doing either way. Right now I set those on the libc side which has the upside of not needing to duplicate those flags in libunwind and libc++abi which should eventually support LLVM libc as well.

In the future we'll probably want to move `HandleLibC.cmake` to the top-level `cmake/Modules` directory so they can be shared by libc++abi and libunwind, although we'll need to rethink the target and variables names because the `LIBCXX_` and `libcxx-` prefix is undesirable (maybe we can use `RUNTIMES_` and `runtimes-`)?

https://github.com/llvm/llvm-project/pull/99287


More information about the cfe-commits mailing list