[libcxx-commits] [libcxx] [libcxx] Support ABI symbol sizes on macOS (PR #75623)
Will Hawkins via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Apr 12 20:22:34 PDT 2024
================
@@ -227,6 +229,21 @@ if (LIBCXX_ENABLE_SHARED)
target_link_libraries(cxx_shared PUBLIC libcxx-abi-shared)
endif()
+ 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).
+ target_link_libraries(cxx_shared PRIVATE "-Wl,-map,${CMAKE_CURRENT_BINARY_DIR}/../lib/abi/linker.map")
+ # Use CMAKE_CONFIGURE_DEPENDS so that CMake will regenerate if/when the map file changes.
+ # Regeneration is important because the addition of the --mapfile option (see lib/abi/CMakeLists.txt)
+ # to generate_abi_list.py depends on the file's existence. Unfortunately, there is a limitation in
+ # CMAKE_CONFIGURE_DEPENDS where regeneration is not triggered when a file that previously did
+ # not exist is generated. As a workaround, "touch" an empty file.
+ if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/../lib/abi/linker.map")
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/../lib/abi/linker.map")
+ endif()
+ set_property(DIRECTORY . APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/../lib/abi/linker.map")
+ endif()
+
----------------
hawkinsw wrote:
That sounds good to me, too. The result is that the user will have to build at least once before they are able to generate the abi list on a mac. I will add some error handling to the `generate_abi_list.py` if the map file cannot be found describing the problem for the user.
https://github.com/llvm/llvm-project/pull/75623
More information about the libcxx-commits
mailing list