[libcxx-commits] [PATCH] D60173: [libc++abi] Do not share an object library to create the static/shared libraries

Sam Clegg via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Apr 3 11:33:57 PDT 2019


sbc100 added inline comments.


================
Comment at: libcxxabi/src/CMakeLists.txt:193
+  if(LIBCXXABI_ENABLE_PIC)
+    set_target_properties(cxxabi_static PROPERTIES POSITION_INDEPENDENT_CODE ON)
+  endif()
----------------
phosek wrote:
> Related to discussion on D60049, should this be set for shared as well or only static? It's unclear to me whether that option should control both or just static? @sbc100 what was your intention?
> 
> Personally, I'd prefer to introduce:
> 
> ```
> cmake_dependent_option(LIBCXXABI_ENABLE_PIC_SHARED_LIBRARY "LIBCXXABI_ENABLE_SHARED;LIBCXXABI_ENABLE_PIC" ON)
> cmake_dependent_option(LIBCXXABI_ENABLE_PIC_STATIC_LIBRARY "LIBCXXABI_ENABLE_STATIC;LIBCXXABI_ENABLE_PIC" ON)
> ```
> 
> Then use those dependent options to control PIC independently for shared and static libraries. WDYT?
>From a WebAssembly perspective we only needed a way to prevent the static library being built as PIC.  Which we now have in the form of the  `LIBCXXABI_ENABLE_PIC=OFF` option.

During review somebody pointed out that there are times when one might also want to disable PIC in shared libraries too so we had this option effect both which is probably fine with us too.

I'm hoping to fix the issue that is currently present in WebAssembly where PIC code can't linked into static binaries.    If I'm not able to do that I'll most likely end up building everything twice creating a complete fork of the lib directory. e.g:

-  `lib/wasm32-unknown-unknown/pic`   (includes .so files and .a files built with PIC)
-  `lib/wasm32-unknown-unknown/nopic`   (includes only .a files *all* built without PIC)

Then the linker would then choose the lib directory to use based weather its building relocatable output or not.

If we end up doing that we don't need that much flexibility within a given build because we will be running cmake twice, once for pic and once for non-pic.

So basically, no I need that fine grained control for what I'm doing (yet).



Repository:
  rCXXA libc++abi

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

https://reviews.llvm.org/D60173





More information about the libcxx-commits mailing list