[libcxx-commits] [libcxx] r358614 - [CMake] Split linked libraries for shared and static libc++
Petr Hosek via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Apr 17 14:41:09 PDT 2019
Author: phosek
Date: Wed Apr 17 14:41:09 2019
New Revision: 358614
URL: http://llvm.org/viewvc/llvm-project?rev=358614&view=rev
Log:
[CMake] Split linked libraries for shared and static libc++
Some linker libraries are only needed for shared libc++, some only
for static libc++, combining these together in LIBCXX_LIBRARIES and
LIBCXX_INTERFACE_LIBRARIES can introduce unnecessary dependencies.
This changes splits those up into LIBCXX_SHARED_LIBRARIES and
LIBCXX_STATIC_LIBRARIES matching what libc++abi already does.
Differential Revision: https://reviews.llvm.org/D57872
Modified:
libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake
libcxx/trunk/lib/CMakeLists.txt
Modified: libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake?rev=358614&r1=358613&r2=358614&view=diff
==============================================================================
--- libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake Wed Apr 17 14:41:09 2019
@@ -216,14 +216,6 @@ macro(add_library_flags_if condition)
endif()
endmacro()
-# Add a list of libraries or link flags to 'LIBCXX_LIBRARIES'.
-macro(add_interface_library)
- foreach(lib ${ARGN})
- list(APPEND LIBCXX_LIBRARIES ${lib})
- list(APPEND LIBCXX_INTERFACE_LIBRARIES ${lib})
- endforeach()
-endmacro()
-
# Turn a comma separated CMake list into a space separated string.
macro(split_list listname)
string(REPLACE ";" " " ${listname} "${${listname}}")
Modified: libcxx/trunk/lib/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=358614&r1=358613&r2=358614&view=diff
==============================================================================
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Wed Apr 17 14:41:09 2019
@@ -90,17 +90,6 @@ endif()
add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
add_library_flags_if(MINGW "${MINGW_LIBRARIES}")
-# Add the unwinder library.
-if (LIBCXXABI_USE_LLVM_UNWINDER)
- if (NOT LIBCXXABI_ENABLE_STATIC_UNWINDER 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)
- else()
- add_interface_library(unwind)
- endif()
-endif()
-
# Setup flags.
add_link_flags_if_supported(-nodefaultlibs)
@@ -171,6 +160,19 @@ if (LIBCXX_ENABLE_SHARED)
)
cxx_set_common_defines(cxx_shared)
+ # Link against LLVM libunwind
+ if (LIBCXXABI_USE_LLVM_UNWINDER)
+ if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
+ target_link_libraries(cxx_shared PRIVATE unwind_shared)
+ list(APPEND LIBCXX_INTERFACE_LIBRARIES unwind_shared) # For the linker script
+ elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND))
+ # libunwind is already included in libc++abi
+ else()
+ target_link_libraries(cxx_shared PRIVATE unwind)
+ list(APPEND LIBCXX_INTERFACE_LIBRARIES unwind) # For the linker script
+ endif()
+ endif()
+
# Link against libc++abi
if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
if (APPLE)
More information about the libcxx-commits
mailing list