[PATCH] D77370: [libunwind] Add LIBUNWIND_ENABLE_PIC

Louis Dionne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 8 09:45:11 PDT 2020


ldionne added a comment.

Ok, let's go step by step to make sure we don't talk past each other. Here's some facts (feel free to correct me if you see a mistake):

1. CMake builds **shared libraries** with `POSITION_INDEPENDENT_CODE=ON` by default.
2. CMake builds **static libraries** with `POSITION_INDEPENDENT_CODE=OFF` by default.
3. Setting `CMAKE_POSITION_INDEPENDENT_CODE=ON` on the command-line or in a cache will cause CMake to build both **shared libraries** and **static libraries** with `POSITION_INDEPENDENT_CODE=ON`.

IIUC, the problem we're trying to solve is that we want to build the **static libunwind library** with `POSITION_INDEPENDENT_CODE=ON`. Given that, why do we need a patch at all? Why isn't it sufficient to set `CMAKE_POSITION_INDEPENDENT_CODE=ON` in the Cache of whoever wants that behaviour?

While I think it would have been a better choice for the CMake designers to use `POSITION_INDEPENDENT_CODE=ON` by default for static libraries, I don't think it's wise to change that default on a per-project basis. This leads to surprises for anyone that assumes we're using CMake the way it was intended to be used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77370





More information about the llvm-commits mailing list