[libcxx-commits] [PATCH] D57872: [CMake] Split linked libraries for shared and static libc++
Petr Hosek via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Apr 2 19:21:00 PDT 2019
phosek updated this revision to Diff 193416.
Repository:
rCXX libc++
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57872/new/
https://reviews.llvm.org/D57872
Files:
libcxx/cmake/Modules/HandleLibcxxFlags.cmake
libcxx/lib/CMakeLists.txt
Index: libcxx/lib/CMakeLists.txt
===================================================================
--- libcxx/lib/CMakeLists.txt
+++ libcxx/lib/CMakeLists.txt
@@ -59,14 +59,14 @@
if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
if (APPLE)
- add_library_flags("-Wl,-force_load" "${LIBCXX_CXX_STATIC_ABI_LIBRARY}")
+ list(APPEND LIBCXX_SHARED_LIBRARIES "-Wl,-force_load" "${LIBCXX_CXX_STATIC_ABI_LIBRARY}")
else()
- add_library_flags("-Wl,--whole-archive" "-Wl,-Bstatic")
- add_library_flags("${LIBCXX_CXX_STATIC_ABI_LIBRARY}")
- add_library_flags("-Wl,-Bdynamic" "-Wl,--no-whole-archive")
+ list(APPEND LIBCXX_SHARED_LIBRARIES "-Wl,--whole-archive" "-Wl,-Bstatic")
+ list(APPEND LIBCXX_SHARED_LIBRARIES "${LIBCXX_CXX_STATIC_ABI_LIBRARY}")
+ list(APPEND LIBCXX_SHARED_LIBRARIES "-Wl,-Bdynamic" "-Wl,--no-whole-archive")
endif()
elseif (LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS)
- add_library_flags("${LIBCXX_CXX_SHARED_ABI_LIBRARY}")
+ list(APPEND LIBCXX_SHARED_LIBRARIES "${LIBCXX_CXX_SHARED_ABI_LIBRARY}")
else ()
add_interface_library("${LIBCXX_CXX_SHARED_ABI_LIBRARY}")
endif()
@@ -112,13 +112,20 @@
# Add the unwinder library.
if (LIBCXXABI_USE_LLVM_UNWINDER)
- if (NOT LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
+ if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
add_interface_library(unwind_shared)
- elseif (LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_static OR HAVE_LIBUNWIND))
- add_interface_library(unwind_static)
+ elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND))
+ # libunwind is already included in libc++abi
else()
add_interface_library(unwind)
endif()
+ if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
+ list(APPEND LIBCXX_STATIC_LIBRARIES unwind_shared)
+ elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND))
+ # libunwind is already included in libc++abi
+ else()
+ list(APPEND LIBCXXABI_STATIC_LIBRARIES unwind)
+ endif()
endif()
# Setup flags.
@@ -198,7 +205,7 @@
if(COMMAND llvm_setup_rpath)
llvm_setup_rpath(cxx_shared)
endif()
- target_link_libraries(cxx_shared PRIVATE ${LIBCXX_LIBRARIES})
+ target_link_libraries(cxx_shared PRIVATE ${LIBCXX_SHARED_LIBRARIES} ${LIBCXX_LIBRARIES})
set_target_properties(cxx_shared
PROPERTIES
COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
@@ -226,7 +233,7 @@
# Build the static library.
if (LIBCXX_ENABLE_STATIC)
add_library(cxx_static STATIC ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
- target_link_libraries(cxx_static PRIVATE ${LIBCXX_LIBRARIES})
+ target_link_libraries(cxx_static PRIVATE ${LIBCXX_STATIC_LIBRARIES} ${LIBCXX_LIBRARIES})
set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
set_target_properties(cxx_static
PROPERTIES
Index: libcxx/cmake/Modules/HandleLibcxxFlags.cmake
===================================================================
--- libcxx/cmake/Modules/HandleLibcxxFlags.cmake
+++ libcxx/cmake/Modules/HandleLibcxxFlags.cmake
@@ -216,10 +216,10 @@
endif()
endmacro()
-# Add a list of libraries or link flags to 'LIBCXX_LIBRARIES'.
+# Add a list of libraries or link flags to 'LIBCXX_SHARED_LIBRARIES'.
macro(add_interface_library)
foreach(lib ${ARGN})
- list(APPEND LIBCXX_LIBRARIES ${lib})
+ list(APPEND LIBCXX_SHARED_LIBRARIES ${lib})
list(APPEND LIBCXX_INTERFACE_LIBRARIES ${lib})
endforeach()
endmacro()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57872.193416.patch
Type: text/x-patch
Size: 3622 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190403/837268eb/attachment.bin>
More information about the libcxx-commits
mailing list