[PATCH] D110261: [libc++][release] Do not force building the runtimes with -fPIC
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 22 10:25:43 PDT 2021
MaskRay accepted this revision.
MaskRay added a comment.
(On ELF, shared objects (-shared) needs -fPIC code; PIE executable needs -fPIE or -fPIC code; position-dependent executable accepts any of -fno-PIC/-fPIE/-fPIC.)
`LLVM_ENABLE_PIC` (default) adds `-fPIC`. `-DCMAKE_POSITION_INDEPENDENT_CODE=ON` adds a duplicated `-fPIC`.
> Someone complained that libc++.a couldn't be used in shared libraries built without -fPIC (http://llvm.org/PR43604) since the LLVM 9 release.
I believe this was due to they doing a standalone libc++ build (`cmake -Hlibcxx -Bout` instead of `cmake -Hllvm -Bout`), so they did not receive `-fPIC` from `LLVM_ENABLE_PIC`.
> As-is, this patch will have 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.
I think there is no difference in the build output, just one `-fPIC` now becoming two `-fPIC` in the compiler options :)
---
Setting `-DCMAKE_POSITION_INDEPENDENT_CODE=ON` looks good to me.
We may be able to drop `LLVM_ENABLE_PIC` in favor of the standard CMake variable.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110261/new/
https://reviews.llvm.org/D110261
More information about the llvm-commits
mailing list