[libcxx-commits] [PATCH] D60049: Add LIBCXXABI_ENABLE_PIC cmake option

Sam Clegg via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Mar 31 12:32:14 PDT 2019


sbc100 created this revision.
Herald added subscribers: libcxx-commits, jdoerfert, christof, sunfish, aheejin, mgorny, dschuff.
Herald added a project: libc++.

This is on by default, since on many platforms and configurations
libc++abi.a gets statically linked into shared libraries and/or
PIE executables.

This change is a followup to https://reviews.llvm.org/D60005 which
allows us to default to PIC code, but disable this if needed (for
example on WebAssembly where PIC code its currently compatible with
static linking).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60049

Files:
  libcxxabi/CMakeLists.txt
  libcxxabi/src/CMakeLists.txt


Index: libcxxabi/src/CMakeLists.txt
===================================================================
--- libcxxabi/src/CMakeLists.txt
+++ libcxxabi/src/CMakeLists.txt
@@ -176,6 +176,10 @@
   cxxabi_object_library(cxxabi_static_objects)
 endif()
 
+if(LIBCXXABI_ENABLE_PIC)
+  set_target_properties(cxxabi_static_objects PROPERTIES POSITION_INDEPENDENT_CODE ON)
+endif()
+
 cxxabi_object_library(cxxabi_shared_objects POSITION_INDEPENDENT_CODE ON)
 set(cxxabi_static_sources $<TARGET_OBJECTS:cxxabi_static_objects>)
 set(cxxabi_shared_sources $<TARGET_OBJECTS:cxxabi_shared_objects>)
Index: libcxxabi/CMakeLists.txt
===================================================================
--- libcxxabi/CMakeLists.txt
+++ libcxxabi/CMakeLists.txt
@@ -46,6 +46,7 @@
 option(LIBCXXABI_ENABLE_EXCEPTIONS "Use exceptions." ON)
 option(LIBCXXABI_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)
 option(LIBCXXABI_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
+option(LIBCXXABI_ENABLE_PIC "Build Position-Independent Code, even in static library" ON)
 option(LIBCXXABI_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
 option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF)
 option(LIBCXXABI_ENABLE_STATIC_UNWINDER "Statically link the LLVM unwinder." OFF)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60049.193022.patch
Type: text/x-patch
Size: 1308 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190331/3e2eb005/attachment.bin>


More information about the libcxx-commits mailing list