[libcxx-commits] [PATCH] D104328: [libc++] Always build libc++ and libc++abi with -fPIC

Fangrui Song via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jul 30 12:52:13 PDT 2021


MaskRay added a comment.

I think there is some configuration confusion here. I think:

- Normally libc++.a should have -fPIC object files. This allows shared object links.
- LLVM_ENABLE_PIC=on (default) adds -fPIC to all object file compilation, including libc++ object files.
- `POSITION_INDEPENDENT_CODE` to libc++/libc++/libunwind targets just duplicate LLVM_ENABLE_PIC=on's -fPIC (I have checked build.ninja)
- When LLVM_ENABLE_PIC=off, shared object targets (e.g. `cxx_shared`, libLLVM-13git.so) do not make sense.

I think the original report of https://bugs.llvm.org/show_bug.cgi?id=43604 is due to they setting LLVM_ENABLE_PIC to off.
So I ask when LLVM_ENABLE_PIC=off, do we expect that libc++.a can be used to build shared objects.
I think no. The distribution problems should be fixed by deleting LLVM_ENABLE_PIC=off.
We don't need any addition `POSITION_INDEPENDENT_CODE`.

On https://bugs.llvm.org/show_bug.cgi?id=43604 , I left a comment that LLVM_ENABLE_PIC and CMAKE_POSITION_INDEPENDENT_CODE both control the same property.
We could consider simplifying CMake by preferring CMAKE_POSITION_INDEPENDENT_CODE and letting LLVM_ENABLE_PIC provide a default value for CMAKE_POSITION_INDEPENDENT_CODE.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104328



More information about the libcxx-commits mailing list