aboutsummaryrefslogtreecommitdiff
path: root/libcxx/src
diff options
context:
space:
mode:
authorLouis Dionne <ldionne.2@gmail.com>2022-03-01 08:42:13 -0500
committerLouis Dionne <ldionne.2@gmail.com>2022-05-13 08:32:09 -0400
commita80e65e00ada7a9c16acf17a5fd40b4f12ced3a8 (patch)
tree4353e52081ad05a3ef0890c95c5e8378a8e0fc6b /libcxx/src
parent4be105c98a9c7e083cd878ee1751e11160b97b4a (diff)
downloadllvm-a80e65e00ada7a9c16acf17a5fd40b4f12ced3a8.zip
llvm-a80e65e00ada7a9c16acf17a5fd40b4f12ced3a8.tar.gz
llvm-a80e65e00ada7a9c16acf17a5fd40b4f12ced3a8.tar.bz2
[libc++] Overhaul how we select the ABI library
This patch overhauls how we pick up the ABI library. Instead of setting ad-hoc flags, it creates interface targets that can be linked against by the rest of the build, which is easier to follow and extend to support new ABI libraries. This is intended to be a NFC change, however there are some additional simplifications and improvements we can make in the future that would require a slight behavior change. Differential Revision: https://reviews.llvm.org/D120727
Diffstat (limited to 'libcxx/src')
-rw-r--r--libcxx/src/CMakeLists.txt38
1 files changed, 8 insertions, 30 deletions
diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index f091dbf..41d07d1 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -156,11 +156,6 @@ if(NOT LIBCXX_INSTALL_LIBRARY)
set(exclude_from_all EXCLUDE_FROM_ALL)
endif()
-# If LIBCXX_CXX_ABI_LIBRARY_PATH is defined we want to add it to the search path.
-add_link_flags_if(LIBCXX_CXX_ABI_LIBRARY_PATH
- "${CMAKE_LIBRARY_PATH_FLAG}${LIBCXX_CXX_ABI_LIBRARY_PATH}")
-
-
if (LIBCXX_GENERATE_COVERAGE AND NOT LIBCXX_COVERAGE_LIBRARY)
find_compiler_rt_library(profile LIBCXX_COVERAGE_LIBRARY)
endif()
@@ -197,10 +192,6 @@ if (LIBCXX_ENABLE_PARALLEL_ALGORITHMS AND NOT TARGET pstl::ParallelSTL)
endif()
function(cxx_set_common_defines name)
- if(LIBCXX_CXX_ABI_HEADER_TARGET)
- add_dependencies(${name} ${LIBCXX_CXX_ABI_HEADER_TARGET})
- endif()
-
if (LIBCXX_ENABLE_PARALLEL_ALGORITHMS)
target_link_libraries(${name} PUBLIC pstl::ParallelSTL)
endif()
@@ -241,19 +232,18 @@ if (LIBCXX_ENABLE_SHARED)
# Link against libc++abi
if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
if (APPLE)
- target_link_libraries(cxx_shared PRIVATE "-Wl,-force_load" "${LIBCXX_CXX_STATIC_ABI_LIBRARY}")
+ target_link_libraries(cxx_shared PRIVATE "-Wl,-force_load" "$<TARGET_LINKER_FILE:libcxx-abi-static>")
else()
- target_link_libraries(cxx_shared PRIVATE "-Wl,--whole-archive,-Bstatic" "${LIBCXX_CXX_STATIC_ABI_LIBRARY}" "-Wl,-Bdynamic,--no-whole-archive")
+ target_link_libraries(cxx_shared PRIVATE "-Wl,--whole-archive,-Bstatic" "$<TARGET_LINKER_FILE:libcxx-abi-static>" "-Wl,-Bdynamic,--no-whole-archive")
endif()
else()
- target_link_libraries(cxx_shared PUBLIC "${LIBCXX_CXX_SHARED_ABI_LIBRARY}")
+ target_link_libraries(cxx_shared PUBLIC libcxx-abi-shared)
endif()
# Maybe re-export symbols from libc++abi
# In particular, we don't re-export the symbols if libc++abi is merged statically
# into libc++ because in that case there's no dylib to re-export from.
- if (APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
- LIBCXX_CXX_ABI_LIBNAME STREQUAL "default")
+ if (APPLE AND LIBCXX_CXX_ABI STREQUAL "libcxxabi"
AND NOT DEFINED LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS
AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
set(LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS ON)
@@ -292,7 +282,8 @@ if (LIBCXX_ENABLE_STATIC)
add_library(cxx_static STATIC ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
target_include_directories(cxx_static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(cxx_static PUBLIC cxx-headers
- PRIVATE ${LIBCXX_LIBRARIES})
+ PRIVATE ${LIBCXX_LIBRARIES}
+ PRIVATE libcxx-abi-static)
set_target_properties(cxx_static
PROPERTIES
COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
@@ -323,19 +314,6 @@ if (LIBCXX_ENABLE_STATIC)
list(APPEND LIBCXX_BUILD_TARGETS "cxx_static")
# Attempt to merge the libc++.a archive and the ABI library archive into one.
if (LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY)
- set(MERGE_ARCHIVES_SEARCH_PATHS "")
- if (LIBCXX_CXX_ABI_LIBRARY_PATH)
- set(MERGE_ARCHIVES_SEARCH_PATHS "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
- endif()
- if (TARGET "${LIBCXX_CXX_STATIC_ABI_LIBRARY}" OR HAVE_LIBCXXABI)
- set(MERGE_ARCHIVES_ABI_TARGET "$<TARGET_LINKER_FILE:${LIBCXX_CXX_STATIC_ABI_LIBRARY}>")
- else()
- set(MERGE_ARCHIVES_ABI_TARGET
- "${CMAKE_STATIC_LIBRARY_PREFIX}${LIBCXX_CXX_STATIC_ABI_LIBRARY}${CMAKE_STATIC_LIBRARY_SUFFIX}")
- if (LIBCXX_CXX_ABI_LIBRARY_PATH)
- set(MERGE_ARCHIVES_ABI_TARGET "${LIBCXX_CXX_ABI_LIBRARY_PATH}/${MERGE_ARCHIVES_ABI_TARGET}")
- endif ()
- endif()
if (APPLE)
set(MERGE_ARCHIVES_LIBTOOL "--use-libtool" "--libtool" "${CMAKE_LIBTOOL}")
endif()
@@ -347,8 +325,8 @@ if (LIBCXX_ENABLE_STATIC)
--ar "${CMAKE_AR}"
${MERGE_ARCHIVES_LIBTOOL}
"$<TARGET_LINKER_FILE:cxx_static>"
- "${MERGE_ARCHIVES_ABI_TARGET}"
- "${MERGE_ARCHIVES_SEARCH_PATHS}"
+ "$<TARGET_LINKER_FILE:libcxx-abi-static>"
+ ""
WORKING_DIRECTORY ${LIBCXX_BUILD_DIR}
DEPENDS ${MERGE_ARCHIVES_ABI_TARGET}
)