Author: Haowei Wu Date: 2022-10-12T12:54:48-07:00 New Revision: a3539090884c9159893c0b2b4c1dc34f23510707
URL: https://github.com/llvm/llvm-project/commit/a3539090884c9159893c0b2b4c1dc34f23510707 DIFF: https://github.com/llvm/llvm-project/commit/a3539090884c9159893c0b2b4c1dc34f23510707.diff LOG: Revert "[runtimes] Always define cxx_shared, cxx_static & other targets" This reverts commit 79ee0342dbf025bc70f237bdfe9ccb4e10a592ce which breaks the LLVM TSan bots. Added: Modified: libcxx/cmake/caches/AIX.cmake libcxx/src/CMakeLists.txt libcxxabi/src/CMakeLists.txt libunwind/src/CMakeLists.txt Removed: ################################################################################ diff --git a/libcxx/cmake/caches/AIX.cmake b/libcxx/cmake/caches/AIX.cmake index d4eb9ac42743a..76cf177913011 100644 --- a/libcxx/cmake/caches/AIX.cmake +++ b/libcxx/cmake/caches/AIX.cmake @@ -17,10 +17,3 @@ set(LIBCXX_CXX_ABI libcxxabi CACHE STRING "") set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") set(LIBUNWIND_ENABLE_SHARED ON CACHE BOOL "") set(LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "") - -# On AIX, both shared and static libraries are archived. As a result, both the static and the shared targets end -# up with a `.a` suffix, which conflict. To workaround that, we set a diff erent output name for the static -# libraries, which we never actually build anyway. For more information, see https://gitlab.kitware.com/cmake/cmake/-/issues/19494. -set(LIBCXX_STATIC_OUTPUT_NAME "c++-static" CACHE STRING "") -set(LIBCXXABI_STATIC_OUTPUT_NAME "c++abi-static" CACHE STRING "") -set(LIBUNWIND_STATIC_OUTPUT_NAME "unwind-static" CACHE STRING "") diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt index f2ae81e88cf76..9ff2a62e93946 100644 --- a/libcxx/src/CMakeLists.txt +++ b/libcxx/src/CMakeLists.txt @@ -147,6 +147,10 @@ if (LIBCXX_CONFIGURE_IDE) endif() endif() +if(NOT LIBCXX_INSTALL_LIBRARY) + set(exclude_from_all EXCLUDE_FROM_ALL) +endif() + if (LIBCXX_GENERATE_COVERAGE AND NOT LIBCXX_COVERAGE_LIBRARY) find_compiler_rt_library(profile LIBCXX_COVERAGE_LIBRARY) endif() @@ -191,146 +195,139 @@ endfunction() split_list(LIBCXX_COMPILE_FLAGS) split_list(LIBCXX_LINK_FLAGS) -# # Build the shared library. -# -add_library(cxx_shared SHARED $<$<NOT:$<BOOL:LIBCXX_ENABLE_SHARED>>:EXCLUDE_FROM_ALL> ${LIBCXX_SOURCES} ${LIBCXX_HEADERS}) -target_include_directories(cxx_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(cxx_shared PUBLIC cxx-headers - PRIVATE ${LIBCXX_LIBRARIES}) -set_target_properties(cxx_shared - PROPERTIES - COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}" - LINK_FLAGS "${LIBCXX_LINK_FLAGS}" - OUTPUT_NAME "${LIBCXX_SHARED_OUTPUT_NAME}" - VERSION "${LIBCXX_LIBRARY_VERSION}" - SOVERSION "${LIBCXX_ABI_VERSION}" - DEFINE_SYMBOL "" -) -cxx_add_common_build_flags(cxx_shared) -cxx_set_common_defines(cxx_shared) - -if(ZOS) - add_custom_command(TARGET cxx_shared POST_BUILD - COMMAND - ${LIBCXX_SOURCE_DIR}/utils/zos_rename_dll_side_deck.sh - $<TARGET_LINKER_FILE_NAME:cxx_shared> $<TARGET_FILE_NAME:cxx_shared> "${LIBCXX_DLL_NAME}" - COMMENT "Rename dll name inside the side deck file" - WORKING_DIRECTORY $<TARGET_FILE_DIR:cxx_shared> +if (LIBCXX_ENABLE_SHARED) + add_library(cxx_shared SHARED ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS}) + target_include_directories(cxx_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + target_link_libraries(cxx_shared PUBLIC cxx-headers + PRIVATE ${LIBCXX_LIBRARIES}) + set_target_properties(cxx_shared + PROPERTIES + COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}" + LINK_FLAGS "${LIBCXX_LINK_FLAGS}" + OUTPUT_NAME "${LIBCXX_SHARED_OUTPUT_NAME}" + VERSION "${LIBCXX_LIBRARY_VERSION}" + SOVERSION "${LIBCXX_ABI_VERSION}" + DEFINE_SYMBOL "" ) -endif() + cxx_add_common_build_flags(cxx_shared) + cxx_set_common_defines(cxx_shared) + + if(ZOS) + add_custom_command(TARGET cxx_shared POST_BUILD + COMMAND + ${LIBCXX_SOURCE_DIR}/utils/zos_rename_dll_side_deck.sh + $<TARGET_LINKER_FILE_NAME:cxx_shared> $<TARGET_FILE_NAME:cxx_shared> "${LIBCXX_DLL_NAME}" + COMMENT "Rename dll name inside the side deck file" + WORKING_DIRECTORY $<TARGET_FILE_DIR:cxx_shared> + ) + endif() -# Link against libc++abi -if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY) - target_link_libraries(cxx_shared PRIVATE libcxx-abi-shared-objects) -else() - target_link_libraries(cxx_shared PUBLIC libcxx-abi-shared) -endif() + # Link against libc++abi + if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY) + target_link_libraries(cxx_shared PRIVATE libcxx-abi-shared-objects) + else() + 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 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) -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 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) + endif() -if (LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS) - target_link_libraries(cxx_shared PRIVATE - "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/libc++unexp.exp" - "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/libc++abi.exp" - "-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/notweak.exp" - "-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/weak.exp") + if (LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS) + target_link_libraries(cxx_shared PRIVATE + "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/libc++unexp.exp" + "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/libc++abi.exp" + "-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/notweak.exp" + "-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/weak.exp") - target_link_libraries(cxx_shared PRIVATE $<TARGET_NAME_IF_EXISTS:cxxabi-reexports>) -endif() + target_link_libraries(cxx_shared PRIVATE $<TARGET_NAME_IF_EXISTS:cxxabi-reexports>) + endif() -# Generate a linker script in place of a libc++.so symlink. -if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT) - set(link_libraries) - - set(imported_libname "$<TARGET_PROPERTY:libcxx-abi-shared,IMPORTED_LIBNAME>") - set(output_name "$<TARGET_PROPERTY:libcxx-abi-shared,OUTPUT_NAME>") - string(APPEND link_libraries "${CMAKE_LINK_LIBRARY_FLAG}$<IF:$<BOOL:${imported_libname}>,${imported_libname},${output_name}>") - - # TODO: Move to the same approach as above for the unwind library - if (LIBCXXABI_USE_LLVM_UNWINDER) - if (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY) - # libunwind is already included in libc++abi - elseif (TARGET unwind_shared OR HAVE_LIBUNWIND) - string(APPEND link_libraries " ${CMAKE_LINK_LIBRARY_FLAG}$<TARGET_PROPERTY:unwind_shared,OUTPUT_NAME>") - else() - string(APPEND link_libraries " ${CMAKE_LINK_LIBRARY_FLAG}unwind") + # Generate a linker script in place of a libc++.so symlink. + if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT) + set(link_libraries) + + set(imported_libname "$<TARGET_PROPERTY:libcxx-abi-shared,IMPORTED_LIBNAME>") + set(output_name "$<TARGET_PROPERTY:libcxx-abi-shared,OUTPUT_NAME>") + string(APPEND link_libraries "${CMAKE_LINK_LIBRARY_FLAG}$<IF:$<BOOL:${imported_libname}>,${imported_libname},${output_name}>") + + # TODO: Move to the same approach as above for the unwind library + if (LIBCXXABI_USE_LLVM_UNWINDER) + if (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY) + # libunwind is already included in libc++abi + elseif (TARGET unwind_shared OR HAVE_LIBUNWIND) + string(APPEND link_libraries " ${CMAKE_LINK_LIBRARY_FLAG}$<TARGET_PROPERTY:unwind_shared,OUTPUT_NAME>") + else() + string(APPEND link_libraries " ${CMAKE_LINK_LIBRARY_FLAG}unwind") + endif() endif() - endif() - set(linker_script "INPUT($<TARGET_SONAME_FILE_NAME:cxx_shared> ${link_libraries})") - add_custom_command(TARGET cxx_shared POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E remove "$<TARGET_LINKER_FILE:cxx_shared>" - COMMAND "${CMAKE_COMMAND}" -E echo "${linker_script}" > "$<TARGET_LINKER_FILE:cxx_shared>" - COMMENT "Generating linker script: '${linker_script}' as file $<TARGET_LINKER_FILE:cxx_shared>" - VERBATIM - ) -endif() + set(linker_script "INPUT($<TARGET_SONAME_FILE_NAME:cxx_shared> ${link_libraries})") + add_custom_command(TARGET cxx_shared POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E remove "$<TARGET_LINKER_FILE:cxx_shared>" + COMMAND "${CMAKE_COMMAND}" -E echo "${linker_script}" > "$<TARGET_LINKER_FILE:cxx_shared>" + COMMENT "Generating linker script: '${linker_script}' as file $<TARGET_LINKER_FILE:cxx_shared>" + VERBATIM + ) + endif() -if (LIBCXX_ENABLE_SHARED) list(APPEND LIBCXX_BUILD_TARGETS "cxx_shared") -endif() -if(WIN32 AND NOT MINGW AND NOT "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") - # Since we most likely do not have a mt.exe replacement, disable the - # manifest bundling. This allows a normal cmake invocation to pass which - # will attempt to use the manifest tool to generate the bundled manifest - set_target_properties(cxx_shared PROPERTIES - APPEND_STRING PROPERTY LINK_FLAGS " /MANIFEST:NO") + if(WIN32 AND NOT MINGW AND NOT "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") + # Since we most likely do not have a mt.exe replacement, disable the + # manifest bundling. This allows a normal cmake invocation to pass which + # will attempt to use the manifest tool to generate the bundled manifest + set_target_properties(cxx_shared PROPERTIES + APPEND_STRING PROPERTY LINK_FLAGS " /MANIFEST:NO") + endif() endif() set(CMAKE_STATIC_LIBRARY_PREFIX "lib") -# # Build the static library. -# -add_library(cxx_static STATIC $<$<NOT:$<BOOL:LIBCXX_ENABLE_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-abi-static) -set_target_properties(cxx_static - PROPERTIES - COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}" - LINK_FLAGS "${LIBCXX_LINK_FLAGS}" - OUTPUT_NAME "${LIBCXX_STATIC_OUTPUT_NAME}" -) -cxx_add_common_build_flags(cxx_static) -cxx_set_common_defines(cxx_static) - -if (LIBCXX_HERMETIC_STATIC_LIBRARY) - # If the hermetic library doesn't define the operator new/delete functions - # then its code shouldn't declare them with hidden visibility. They might - # actually be provided by a shared library at link time. - if (LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS) - append_flags_if_supported(CXX_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete-hidden) +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-abi-static) + set_target_properties(cxx_static + PROPERTIES + COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}" + LINK_FLAGS "${LIBCXX_LINK_FLAGS}" + OUTPUT_NAME "${LIBCXX_STATIC_OUTPUT_NAME}" + ) + cxx_add_common_build_flags(cxx_static) + cxx_set_common_defines(cxx_static) + + if (LIBCXX_HERMETIC_STATIC_LIBRARY) + # If the hermetic library doesn't define the operator new/delete functions + # then its code shouldn't declare them with hidden visibility. They might + # actually be provided by a shared library at link time. + if (LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS) + append_flags_if_supported(CXX_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete-hidden) + endif() + target_compile_options(cxx_static PRIVATE ${CXX_STATIC_LIBRARY_FLAGS}) + # _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS can be defined in __config_site + # too. Define it in the same way here, to avoid redefinition conflicts. + target_compile_definitions(cxx_static PRIVATE _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=) endif() - target_compile_options(cxx_static PRIVATE ${CXX_STATIC_LIBRARY_FLAGS}) - # _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS can be defined in __config_site - # too. Define it in the same way here, to avoid redefinition conflicts. - target_compile_definitions(cxx_static PRIVATE _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=) -endif() -if (LIBCXX_ENABLE_STATIC) list(APPEND LIBCXX_BUILD_TARGETS "cxx_static") -endif() -# Attempt to merge the libc++.a archive and the ABI library archive into one. -if (LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY) - target_link_libraries(cxx_static PRIVATE libcxx-abi-static-objects) + # Attempt to merge the libc++.a archive and the ABI library archive into one. + if (LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY) + target_link_libraries(cxx_static PRIVATE libcxx-abi-static-objects) + endif() endif() # Add a meta-target for both libraries. add_custom_target(cxx DEPENDS ${LIBCXX_BUILD_TARGETS}) -# -# Build the experimental static library -# set(LIBCXX_EXPERIMENTAL_SOURCES experimental/memory_resource.cpp format.cpp diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt index e4e85733153d2..58df59a5725a3 100644 --- a/libcxxabi/src/CMakeLists.txt +++ b/libcxxabi/src/CMakeLists.txt @@ -182,63 +182,64 @@ if (CMAKE_POSITION_INDEPENDENT_CODE OR NOT DEFINED CMAKE_POSITION_INDEPENDENT_CO set_target_properties(cxxabi_shared_objects PROPERTIES POSITION_INDEPENDENT_CODE ON) # must set manually because it's an object library endif() -add_library(cxxabi_shared SHARED $<$<NOT:$<BOOL:LIBCXXABI_ENABLE_SHARED>>:EXCLUDE_FROM_ALL>) -set_target_properties(cxxabi_shared - PROPERTIES - LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}" - OUTPUT_NAME "${LIBCXXABI_SHARED_OUTPUT_NAME}" - SOVERSION "1" - VERSION "${LIBCXXABI_LIBRARY_VERSION}" -) - -if (ZOS) - add_custom_command(TARGET cxxabi_shared POST_BUILD - COMMAND - ${LIBCXXABI_LIBCXX_PATH}/utils/zos_rename_dll_side_deck.sh - $<TARGET_LINKER_FILE_NAME:cxxabi_shared> $<TARGET_FILE_NAME:cxxabi_shared> "${LIBCXXABI_DLL_NAME}" - COMMENT "Rename dll name inside the side deck file" - WORKING_DIRECTORY $<TARGET_FILE_DIR:cxxabi_shared> +if (LIBCXXABI_ENABLE_SHARED) + add_library(cxxabi_shared SHARED) + set_target_properties(cxxabi_shared + PROPERTIES + LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}" + OUTPUT_NAME "${LIBCXXABI_SHARED_OUTPUT_NAME}" + SOVERSION "1" + VERSION "${LIBCXXABI_LIBRARY_VERSION}" ) -endif () -target_link_libraries(cxxabi_shared - PUBLIC cxxabi_shared_objects - PRIVATE ${LIBCXXABI_SHARED_LIBRARIES} ${LIBCXXABI_LIBRARIES}) -if (TARGET pstl::ParallelSTL) - target_link_libraries(cxxabi_shared PUBLIC pstl::ParallelSTL) -endif() + if (ZOS) + add_custom_command(TARGET cxxabi_shared POST_BUILD + COMMAND + ${LIBCXXABI_LIBCXX_PATH}/utils/zos_rename_dll_side_deck.sh + $<TARGET_LINKER_FILE_NAME:cxxabi_shared> $<TARGET_FILE_NAME:cxxabi_shared> "${LIBCXXABI_DLL_NAME}" + COMMENT "Rename dll name inside the side deck file" + WORKING_DIRECTORY $<TARGET_FILE_DIR:cxxabi_shared> + ) + endif () + + target_link_libraries(cxxabi_shared + PUBLIC cxxabi_shared_objects + PRIVATE ${LIBCXXABI_SHARED_LIBRARIES} ${LIBCXXABI_LIBRARIES}) + if (TARGET pstl::ParallelSTL) + target_link_libraries(cxxabi_shared PUBLIC pstl::ParallelSTL) + endif() -if (LIBCXXABI_ENABLE_SHARED) list(APPEND LIBCXXABI_BUILD_TARGETS "cxxabi_shared") -endif() -if (LIBCXXABI_INSTALL_SHARED_LIBRARY) - list(APPEND LIBCXXABI_INSTALL_TARGETS "cxxabi_shared") -endif() + if (LIBCXXABI_INSTALL_SHARED_LIBRARY) + list(APPEND LIBCXXABI_INSTALL_TARGETS "cxxabi_shared") + endif() -add_library(cxxabi-reexports INTERFACE) -# -exported_symbols_list is only available on Apple platforms -if (APPLE) - function(export_symbols file) - target_link_libraries(cxxabi_shared PRIVATE "-Wl,-exported_symbols_list,${file}") - endfunction() - function(reexport_symbols file) - export_symbols("${file}") - target_link_libraries(cxxabi-reexports INTERFACE "-Wl,-reexported_symbols_list,${file}") - endfunction() + add_library(cxxabi-reexports INTERFACE) - export_symbols("${CMAKE_CURRENT_SOURCE_DIR}/../lib/itanium-base.exp") + # -exported_symbols_list is only available on Apple platforms + if (APPLE) + function(export_symbols file) + target_link_libraries(cxxabi_shared PRIVATE "-Wl,-exported_symbols_list,${file}") + endfunction() + function(reexport_symbols file) + export_symbols("${file}") + target_link_libraries(cxxabi-reexports INTERFACE "-Wl,-reexported_symbols_list,${file}") + endfunction() - if (LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS) - reexport_symbols("${CMAKE_CURRENT_SOURCE_DIR}/../lib/new-delete.exp") - endif() + export_symbols("${CMAKE_CURRENT_SOURCE_DIR}/../lib/itanium-base.exp") - if (LIBCXXABI_ENABLE_EXCEPTIONS) - reexport_symbols("${CMAKE_CURRENT_SOURCE_DIR}/../lib/exceptions.exp") + if (LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS) + reexport_symbols("${CMAKE_CURRENT_SOURCE_DIR}/../lib/new-delete.exp") + endif() - if ("${CMAKE_OSX_ARCHITECTURES}" MATCHES "^(armv6|armv7|armv7s)$") - reexport_symbols("${CMAKE_CURRENT_SOURCE_DIR}/../lib/personality-sjlj.exp") - else() - reexport_symbols("${CMAKE_CURRENT_SOURCE_DIR}/../lib/personality-v0.exp") + if (LIBCXXABI_ENABLE_EXCEPTIONS) + reexport_symbols("${CMAKE_CURRENT_SOURCE_DIR}/../lib/exceptions.exp") + + if ("${CMAKE_OSX_ARCHITECTURES}" MATCHES "^(armv6|armv7|armv7s)$") + reexport_symbols("${CMAKE_CURRENT_SOURCE_DIR}/../lib/personality-sjlj.exp") + else() + reexport_symbols("${CMAKE_CURRENT_SOURCE_DIR}/../lib/personality-v0.exp") + endif() endif() endif() endif() @@ -276,27 +277,27 @@ if(LIBCXXABI_HERMETIC_STATIC_LIBRARY) _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=) endif() -add_library(cxxabi_static STATIC $<$<NOT:$<BOOL:LIBCXXABI_ENABLE_STATIC>>:EXCLUDE_FROM_ALL>) -if (LIBCXXABI_USE_LLVM_UNWINDER AND NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY) - target_link_libraries(cxxabi_static PUBLIC unwind_static) -endif() -set_target_properties(cxxabi_static - PROPERTIES - LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}" - OUTPUT_NAME "${LIBCXXABI_STATIC_OUTPUT_NAME}" - ) -target_link_libraries(cxxabi_static - PUBLIC cxxabi_static_objects - PRIVATE ${LIBCXXABI_STATIC_LIBRARIES} ${LIBCXXABI_LIBRARIES}) -if (TARGET pstl::ParallelSTL) - target_link_libraries(cxxabi_static PUBLIC pstl::ParallelSTL) -endif() - if (LIBCXXABI_ENABLE_STATIC) + add_library(cxxabi_static STATIC) + if (LIBCXXABI_USE_LLVM_UNWINDER AND NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY) + target_link_libraries(cxxabi_static PUBLIC unwind_static) + endif() + set_target_properties(cxxabi_static + PROPERTIES + LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}" + OUTPUT_NAME "${LIBCXXABI_STATIC_OUTPUT_NAME}" + ) + target_link_libraries(cxxabi_static + PUBLIC cxxabi_static_objects + PRIVATE ${LIBCXXABI_STATIC_LIBRARIES} ${LIBCXXABI_LIBRARIES}) + if (TARGET pstl::ParallelSTL) + target_link_libraries(cxxabi_static PUBLIC pstl::ParallelSTL) + endif() + list(APPEND LIBCXXABI_BUILD_TARGETS "cxxabi_static") -endif() -if (LIBCXXABI_INSTALL_STATIC_LIBRARY) - list(APPEND LIBCXXABI_INSTALL_TARGETS "cxxabi_static") + if (LIBCXXABI_INSTALL_STATIC_LIBRARY) + list(APPEND LIBCXXABI_INSTALL_TARGETS "cxxabi_static") + endif() endif() # Add a meta-target for both libraries. diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt index c33180360d41d..df32e53d69e6e 100644 --- a/libunwind/src/CMakeLists.txt +++ b/libunwind/src/CMakeLists.txt @@ -135,9 +135,7 @@ set_property(SOURCE ${LIBUNWIND_C_SOURCES} # ease, but does not rely on C++ at runtime. set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "") -# # Build the shared library. -# add_library(unwind_shared_objects OBJECT EXCLUDE_FROM_ALL ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS}) if(CMAKE_C_COMPILER_ID STREQUAL MSVC) target_compile_options(unwind_shared_objects PRIVATE /GR-) @@ -156,27 +154,25 @@ if (CMAKE_POSITION_INDEPENDENT_CODE OR NOT DEFINED CMAKE_POSITION_INDEPENDENT_CO set_target_properties(unwind_shared_objects PROPERTIES POSITION_INDEPENDENT_CODE ON) # must set manually because it's an object library endif() -add_library(unwind_shared SHARED $<$<NOT:$<BOOL:LIBUNWIND_ENABLE_SHARED>>:EXCLUDE_FROM_ALL>) -target_link_libraries(unwind_shared PUBLIC unwind_shared_objects) -set_target_properties(unwind_shared - PROPERTIES - LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}" - LINKER_LANGUAGE C - OUTPUT_NAME "${LIBUNWIND_SHARED_OUTPUT_NAME}" - VERSION "1.0" - SOVERSION "1" -) - if (LIBUNWIND_ENABLE_SHARED) + add_library(unwind_shared SHARED) + target_link_libraries(unwind_shared PUBLIC unwind_shared_objects) + set_target_properties(unwind_shared + PROPERTIES + LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}" + LINKER_LANGUAGE C + OUTPUT_NAME "${LIBUNWIND_SHARED_OUTPUT_NAME}" + VERSION "1.0" + SOVERSION "1" + ) + list(APPEND LIBUNWIND_BUILD_TARGETS "unwind_shared") -endif() -if (LIBUNWIND_INSTALL_SHARED_LIBRARY) - list(APPEND LIBUNWIND_INSTALL_TARGETS "unwind_shared") + if (LIBUNWIND_INSTALL_SHARED_LIBRARY) + list(APPEND LIBUNWIND_INSTALL_TARGETS "unwind_shared") + endif() endif() -# # Build the static library. -# add_library(unwind_static_objects OBJECT EXCLUDE_FROM_ALL ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS}) if(CMAKE_C_COMPILER_ID STREQUAL MSVC) target_compile_options(unwind_static_objects PRIVATE /GR-) @@ -198,20 +194,20 @@ if(LIBUNWIND_HIDE_SYMBOLS) target_compile_definitions(unwind_static_objects PRIVATE _LIBUNWIND_HIDE_SYMBOLS) endif() -add_library(unwind_static STATIC $<$<NOT:$<BOOL:LIBUNWIND_ENABLE_STATIC>>:EXCLUDE_FROM_ALL>) -target_link_libraries(unwind_static PUBLIC unwind_static_objects) -set_target_properties(unwind_static - PROPERTIES - LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}" - LINKER_LANGUAGE C - OUTPUT_NAME "${LIBUNWIND_STATIC_OUTPUT_NAME}" -) - if (LIBUNWIND_ENABLE_STATIC) + add_library(unwind_static STATIC) + target_link_libraries(unwind_static PUBLIC unwind_static_objects) + set_target_properties(unwind_static + PROPERTIES + LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}" + LINKER_LANGUAGE C + OUTPUT_NAME "${LIBUNWIND_STATIC_OUTPUT_NAME}" + ) + list(APPEND LIBUNWIND_BUILD_TARGETS "unwind_static") -endif() -if (LIBUNWIND_INSTALL_STATIC_LIBRARY) - list(APPEND LIBUNWIND_INSTALL_TARGETS "unwind_static") + if (LIBUNWIND_INSTALL_STATIC_LIBRARY) + list(APPEND LIBUNWIND_INSTALL_TARGETS "unwind_static") + endif() endif() # Add a meta-target for both libraries. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits