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

Petr Hosek via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 18 10:18:23 PDT 2024


================
@@ -0,0 +1,34 @@
+#===============================================================================
+# Define targets for linking against the selected C library
+#
+# After including this file, the following targets are defined:
+# - libcxx-libc-headers: An interface target that allows getting access to the
+#                        headers of the selected C library.
+# - libcxx-libc-shared: A target representing the selected shared C library.
+# - libcxx-libm-shared: A target representing the selected shared C math library.
+# - libcxx-libc-static: A target representing the selected static C library.
+# - libcxx-libm-static: A target representing the selected static C math library.
+#===============================================================================
+
+# Link against a system-provided libc
+if (LIBCXX_LIBC STREQUAL "system")
+  add_library(libcxx-libc-headers INTERFACE)
+
+  add_library(libcxx-libc-static INTERFACE)
+  add_library(libcxx-libm-static INTERFACE)
+
+  add_library(libcxx-libc-shared INTERFACE)
+  add_library(libcxx-libm-shared INTERFACE)
+
+# Link against the in-tree LLVM libc
+elseif (LIBCXX_LIBC STREQUAL "llvm-libc")
+  add_library(libcxx-libc-headers INTERFACE)
+  target_link_libraries(libcxx-libc-headers INTERFACE libc-headers)
----------------
petrhosek wrote:

In the [sorting logic you implemented](https://github.com/llvm/llvm-project/blob/1c55586e9a475a09b7d769e7fc9a254e7150c972/runtimes/CMakeLists.txt#L26), we put libc before libc++ so they should if libc is enabled. I added a check to cover the case when libc is disabled like we do for libc++abi.

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


More information about the libcxx-commits mailing list