[clang] [compiler-rt] [libcxx] [llvm] [libc++] Replace LIBCXX_ENABLE_STATIC_ABI_LIBRARY & friends by a new LIBCXX_CXX_ABI choice (PR #112978)

Louis Dionne via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 5 06:37:54 PST 2024


================
@@ -230,11 +230,22 @@ else()
 endif()
 
 set(LIBCXX_SUPPORTED_ABI_LIBRARIES none libcxxabi system-libcxxabi libcxxrt libstdc++ libsupc++ vcruntime)
-set(LIBCXX_CXX_ABI "${LIBCXX_DEFAULT_ABI_LIBRARY}" CACHE STRING "Specify C++ ABI library to use. Supported values are ${LIBCXX_SUPPORTED_ABI_LIBRARIES}.")
-if (NOT "${LIBCXX_CXX_ABI}" IN_LIST LIBCXX_SUPPORTED_ABI_LIBRARIES)
-  message(FATAL_ERROR "Unsupported C++ ABI library: '${LIBCXX_CXX_ABI}'. Supported values are ${LIBCXX_SUPPORTED_ABI_LIBRARIES}.")
-endif()
-
+set(LIBCXX_CXX_ABI "${LIBCXX_DEFAULT_ABI_LIBRARY}" CACHE STRING
+  "Specify the C++ ABI library to use for the shared and the static libc++ libraries. Supported values are ${LIBCXX_SUPPORTED_ABI_LIBRARIES}.
+   This CMake option also supports \"consumption specifiers\", which specify how the selected ABI library should be consumed by
+   libc++. The supported specifiers are:
+   - `shared`: The selected ABI library should be used as a shared library.
+   - `static`: The selected ABI library should be used as a static library.
+   - `merged`: The selected ABI library should be a static library whose object files will be merged directly into the produced libc++ library.
+
+   A consumption specifier is provided by appending it to the name of the library, such as `LIBCXX_CXX_ABI=merged-libcxxabi`.
+   If no consumption specifier is provided, the libc++ shared library will default to using a shared ABI library, and the
+   libc++ static library will default to using a static ABI library.")
+set(LIBCXX_ABILIB_FOR_SHARED "${LIBCXX_CXX_ABI}" CACHE STRING "C++ ABI library to use for the shared libc++ library.")
+set(LIBCXX_ABILIB_FOR_STATIC "${LIBCXX_CXX_ABI}" CACHE STRING "C++ ABI library to use for the static libc++ library.")
----------------
ldionne wrote:

I actually wanted to rename `LIBCXX_CXX_ABI` to `LIBCXX_ABILIB` in a future patch, that's why I went with `LIBCXX_ABILIB_foo`. I am not a huge fan of `LIBCXX_CXX_ABI` since I find it easily confused with the various `LIBCXXABI_` variables, for example `LIBCXXABI_LIBCXX_PATH` (which makes my head spin). `LIBCXX_CXX_ABI` could also be a choice of e.g. Itanium ABI vs MSVC ABI instead of the library implementing the ABI.

The second aspect of this name choice is to disambiguate what the setting is *used for* vs the type of ABI library we're searching. For example, `LIBCXX_CXX_ABI_STATIC` could either represent the abilib to use for linking into the static library (which it is), or it could represent the static variant of the abilib we've found (which it isn't). By using `FOR_SHARED` and `FOR_STATIC` as a suffix, I felt that it disambiguated this pretty clearly (although it makes the names less cute).

Let me know if that makes sense to you or if you still prefer `LIBCXX_CXX_ABI` -- if so, we might be able to figure out another naming scheme altogether.

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


More information about the cfe-commits mailing list