[libcxx-commits] [PATCH] D125393: [runtimes] Introduce object libraries

Petr Hosek via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 11 14:36:43 PDT 2022


phosek added a comment.

In D125393#3507367 <https://reviews.llvm.org/D125393#3507367>, @mstorsjo wrote:

> Thanks! Overall, this looks like it can work for me. The same two issues as I still had with D116689 <https://reviews.llvm.org/D116689> (as discussed with @phosek there) exists here too:
>
> - For mingw, I can't build cxxabi_shared, but I do need cxxabi_shared_objects for cxx_shared. @phosek suggested fixing this by always creating the `cxxabi_shared_objects` target, but adding the `EXCLUDE_FROM_ALL` property on it.
>
> - As the line `target_link_libraries(cxx_shared PUBLIC unwind_shared)` is removed from cxx, builds with `LIBCXXABI_USE_LLVM_UNWINDER`, without `LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY` fail. This can be fixed (at least for my case, didn't test other cases) by moving that dependency from `cxxabi_shared` to `cxxabi_shared_objects` - so that it propagates to either `cxxabi_shared` or `cxx_shared` later.
>
> I.e., to make it work for me, I made this change on top of it:
>
>   diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
>   index 6e22432759e6..04bee47deee7 100644
>   --- a/libcxxabi/src/CMakeLists.txt
>   +++ b/libcxxabi/src/CMakeLists.txt
>   @@ -152,10 +152,13 @@ if (NOT TARGET pstl::ParallelSTL)
>    endif()
>    
>    # Build the shared library.
>   -if (LIBCXXABI_ENABLE_SHARED)
>      add_library(cxxabi_shared_objects OBJECT ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS})
>   -  if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY)
>   -    target_sources(cxxabi_shared_objects PUBLIC $<TARGET_OBJECTS:unwind_shared_objects>)
>   +  if (LIBCXXABI_USE_LLVM_UNWINDER)
>   +    if (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY)
>   +      target_sources(cxxabi_shared_objects PUBLIC $<TARGET_OBJECTS:unwind_shared_objects>)
>   +    else()
>   +      target_link_libraries(cxxabi_shared_objects PUBLIC unwind_shared)
>   +    endif()
>      endif()
>      target_link_libraries(cxxabi_shared_objects PRIVATE cxx-headers ${LIBCXXABI_BUILTINS_LIBRARY} ${LIBCXXABI_SHARED_LIBRARIES} ${LIBCXXABI_LIBRARIES})
>      target_link_libraries(cxxabi_shared_objects PUBLIC cxxabi-headers)
>   @@ -166,12 +169,11 @@ if (LIBCXXABI_ENABLE_SHARED)
>          CXX_STANDARD_REQUIRED OFF
>          COMPILE_FLAGS "${LIBCXXABI_COMPILE_FLAGS}"
>          DEFINE_SYMBOL ""
>   +      EXCLUDE_FROM_ALL ON
>      )
>    
>   +if (LIBCXXABI_ENABLE_SHARED)
>      add_library(cxxabi_shared SHARED $<TARGET_OBJECTS:cxxabi_shared_objects>)
>   -  if(LIBCXXABI_USE_LLVM_UNWINDER AND NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY)
>   -    target_link_libraries(cxxabi_shared PUBLIC unwind_shared)
>   -  endif()
>      set_target_properties(cxxabi_shared
>        PROPERTIES
>          LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}"
>
> (I guess the same change for always creating the `cxxabi_static_objects`, but with `EXCLUDE_FROM_ALL`, should be made too, but I just tested with the bare minimums for making this work for me.)

As mentioned in D116689 <https://reviews.llvm.org/D116689>, the `EXCLUDE_FROM_ALL` is going to require more cleanup throughout LLVM so I'd suggest making that change as a follow up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125393



More information about the libcxx-commits mailing list