[libcxx-commits] [PATCH] D116689: [libunwind][libcxxabi] Use object libraries in the build

Petr Hosek via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon May 9 14:57:54 PDT 2022


phosek added a comment.

In D116689#3500263 <https://reviews.llvm.org/D116689#3500263>, @mstorsjo wrote:

> This version breaks things for me; I'm building with `LIBCXX_ENABLE_STATIC_ABI_LIBRARY` and `LIBCXXABI_USE_LLVM_UNWINDER` but not `LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY`. In this case, there's no shared libcxxabi (I build with `LIBCXXABI_ENABLE_SHARED=OFF`), so libcxx would need to retain the code to link against the libunwind cmake target, it can't be carried transitively via libcxxabi (cxxabi_shared_objects). I.e. this case gets lost:
>
>   if(LIBCXXABI_USE_LLVM_UNWINDER AND NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY)
>      target_link_libraries(cxxabi_shared PUBLIC unwind_shared)
>    endif() 

The part I don't like is referring to `LIBCXXABI_USE_LLVM_UNWINDER` from within the libcxx build.

> No - to make it work, I currently apply this diff:
>
>   diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
>   index 52d9c8046f9a..c2cce23c25b2 100644
>   --- a/libcxxabi/src/CMakeLists.txt
>   +++ b/libcxxabi/src/CMakeLists.txt
>   @@ -176,7 +176,7 @@ if (NOT TARGET pstl::ParallelSTL)
>    endif()
>    
>    # Build the shared library.
>   -if (LIBCXXABI_ENABLE_SHARED)
>   +if (LIBCXXABI_ENABLE_SHARED OR ((LIBCXX_ENABLE_SHARED OR NOT DEFINED LIBCXX_ENABLE_SHARED) AND LIBCXX_ENABLE_STATIC_ABI_LIBRARY))
>      add_library(cxxabi_shared_objects OBJECT ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS})
>      target_link_libraries(cxxabi_shared_objects PRIVATE cxx-headers ${LIBCXXABI_SHARED_LIBRARIES} ${LIBCXXABI_LIBRARIES})
>      target_link_libraries(cxxabi_shared_objects PUBLIC cxxabi-headers)
>   @@ -188,7 +188,9 @@ if (LIBCXXABI_ENABLE_SHARED)
>          COMPILE_FLAGS "${LIBCXXABI_COMPILE_FLAGS}"
>          DEFINE_SYMBOL ""
>      )
>   +endif()
>    
>   +if (LIBCXXABI_ENABLE_SHARED)
>      add_library(cxxabi_shared SHARED $<TARGET_OBJECTS:cxxabi_shared_objects>)
>      set_target_properties(cxxabi_shared 
>        PROPERTIES
>
> I.e. I need to build `cxxabi_shared_objects` (as those are needed to be merged into `cxx_shared`) but I can't build `cxxabi_shared` (because that's impossible to link when Windows shared libraries can't have undefined references).

I wonder if we could simplify things by always building `cxxabi_static_objects` and `cxxabi_shared_objects` but marking them as `EXCLUDE_FROM_ALL`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116689/new/

https://reviews.llvm.org/D116689



More information about the libcxx-commits mailing list