[libc++][release] Do not force building the runtimes with -fPIC
authorLouis Dionne <ldionne.2@gmail.com>
Wed, 22 Sep 2021 16:09:07 +0000 (12:09 -0400)
committerLouis Dionne <ldionne.2@gmail.com>
Wed, 8 Dec 2021 16:34:35 +0000 (11:34 -0500)
commita6e5563dfaff0cb7147058b9c49e38b611a28fb1
tree487074c5f5a2893de5da8d3e46a18da778ac8c64
parentde467afe182ed9ea4ca5454f79dc6ef29ca155cc
[libc++][release] Do not force building the runtimes with -fPIC

There's a lot of history behind this, so here's a summary:

1. I stopped forcing -fPIC when building the runtimes in 30f305efe279,
   before the LLVM 9 release back in 2019.

2. Someone complained that libc++.a couldn't be used in shared libraries
   built without -fPIC (http://llvm.org/PR43604) since the LLVM 9 release.
   This had been caused by my removal of -fPIC when building libc++.a in (1).

3. I suggested two ways of fixing the issue, the first being to force
   -fPIC back unconditionally (http://llvm.org/D104328), and the second
   being to specify that option explicitly when building the LLVM release
   (http://llvm.org/D104327). We converged on the first solution.

4. I landed D104328, which forced building the runtimes with -fPIC.
   This was included in the LLVM 13.0 release.

5. People complained about that and requested that we be able to
   customize this setting (basically we should have done the second
   solution).

This patch makes it such that the LLVM release script will specifically
ask for building with -fPIC using CMAKE_POSITION_INDEPENDENT_CODE,
however by default the runtimes will not force that option onto users.

This patch has the unintended effect that Clang and the LLVM libraries
(not only the runtime ones like libc++) will also be built with -fPIC
in the release. It would be better if we could specify that -fPIC is to
be used only when building the runtimes, however this is left as a
future improvement. The release should probably be using a bootstrapping
build and passing those options to the stage that builds the runtimes
only, see https://reviews.llvm.org/D112748 for that change.

Differential Revision: https://reviews.llvm.org/D110261
libcxx/docs/ReleaseNotes.rst
libcxx/src/CMakeLists.txt
libcxx/test/libcxx/debug/extern-templates.sh.cpp
libcxx/utils/libcxx/test/dsl.py
libcxx/utils/libcxx/test/features.py
libcxxabi/src/CMakeLists.txt
libunwind/src/CMakeLists.txt
llvm/utils/release/test-release.sh