[libcxx-commits] [libcxx] [libcxx] Support ABI symbol sizes on macOS (PR #75623)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jan 7 22:11:42 PST 2024


================
@@ -193,6 +193,26 @@ split_list(LIBCXX_LINK_FLAGS)
 
 # Build the shared library.
 if (LIBCXX_ENABLE_SHARED)
+
+  if (APPLE)
+    # If we are on an Apple platform, let's ask the linker to generate a map
+    # that we can use to determine the size of the abi symbols (see generate-cxx-abilist target).
+    if (CMAKE_CXX_COMPILER_TARGET)
+      set(triple "${CMAKE_CXX_COMPILER_TARGET}")
+    else()
+      set(triple "${LLVM_DEFAULT_TARGET_TRIPLE}")
+    endif()
+    cxx_abi_identifier(abi_identifier
+      "${triple}"
+      "${LIBCXX_CXX_ABI}"
+      "${LIBCXX_ABI_VERSION}"
+      "${LIBCXX_ABI_UNSTABLE}"
+      "${LIBCXX_ENABLE_EXCEPTIONS}"
+      "${LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS}"
+    )
+    add_link_flags("-Wl,-map,${CMAKE_CURRENT_SOURCE_DIR}/../lib/abi/${abi_identifier}.linker.map")
----------------
ldionne wrote:

Do we need the name of this map file to be unique across ABI-affecting properties? Can't we just always call it e.g. `linker.map`?

Also, I think we should avoid generating files in `CMAKE_CURRENT_SOURCE_DIR` since that will pollute the source directory. Instead we should probably generate into `CMAKE_CURRENT_BINARY_DIR` or something like that.

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


More information about the libcxx-commits mailing list