[PATCH] D49502: [CMake] Support statically linking dependencies only to shared or static library

Louis Dionne via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 19 06:54:39 PDT 2018


ldionne added inline comments.


================
Comment at: libcxx/lib/CMakeLists.txt:269
+        AND (TARGET cxxabi_static OR HAVE_LIBCXXABI))
+    #if ((TARGET ${LIBCXX_CXX_ABI_LIBRARY}) OR
+        #(${LIBCXX_CXX_ABI_LIBRARY} MATCHES "cxxabi(_static|_shared)?" AND HAVE_LIBCXXABI))
----------------
phosek wrote:
> ldionne wrote:
> > I don't understand why any of this needs to change -- can you please explain? Also, you probably didn't mean to leave the commented-out lines.
> The reason this change is needed the case when we're linking shared libc++abi into shared libc++ in which case `${LIBCXX_CXX_ABI_LIBRARY}` will be set to `cxxabi_shared` in `HandleLibCXXABI.cmake` but we cannot merge `libc++abi.so` into `libc++.a`, so instead we force the use of `cxxabi_static` here.
> 
> Alternatively, we could modify `HandleLibCXXABI.cmake` to set two dependencies, one for the static case and one for the shared case and use the former one here.
> 
> Removed the commented out lines.
Thanks. There's something I still don't understand. If you are linking the ABI library dynamically, why would you want to merge it (well, the static version of it) into `libc++.a`? It seems like this is somewhat defeating the purpose of dynamically linking against the ABI library, no?


================
Comment at: libcxxabi/src/CMakeLists.txt:64
   # FIXME: Is it correct to prefer the static version of libunwind?
   if (NOT LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
     list(APPEND LIBCXXABI_LIBRARIES unwind_shared)
----------------
Does this not need to change anymore? I think we'd have to set different flags for `cxxabi_shared` and `cxxabi_static`.



Repository:
  rCXX libc++

https://reviews.llvm.org/D49502





More information about the cfe-commits mailing list