summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2019-04-03 00:34:12 +0000
committerSam Clegg <sbc@chromium.org>2019-04-03 00:34:12 +0000
commit31d7394dc7c759b501efd5ca2a70f2e1e286f127 (patch)
tree0e78d34d4b5a97e7d84c0b88f0366ed94e4c248d
parent1e6c93184406d35c06bdc4db8319b8c9c5f2dbba (diff)
downloadbcm5719-llvm-31d7394dc7c759b501efd5ca2a70f2e1e286f127.tar.gz
bcm5719-llvm-31d7394dc7c759b501efd5ca2a70f2e1e286f127.zip
[libc++abi] Add LIBCXXABI_ENABLE_PIC cmake option
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). Differential Revision: https://reviews.llvm.org/D60049 llvm-svn: 357551
-rw-r--r--libcxxabi/CMakeLists.txt1
-rw-r--r--libcxxabi/src/CMakeLists.txt5
2 files changed, 5 insertions, 1 deletions
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index b77422847ab..4138acf8615 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -46,6 +46,7 @@ include(HandleCompilerRT)
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)
diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index f8b31c10757..9911c9805c7 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -155,6 +155,10 @@ macro(cxxabi_object_library name)
COMPILE_FLAGS
"${LIBCXXABI_COMPILE_FLAGS}")
+ if(LIBCXXABI_ENABLE_PIC)
+ set_target_properties(${name} PROPERTIES POSITION_INDEPENDENT_CODE ON)
+ endif()
+
if(ARGS_DEFINES)
target_compile_definitions(${name} PRIVATE ${ARGS_DEFINES})
endif()
@@ -177,7 +181,6 @@ else()
endif()
cxxabi_object_library(cxxabi_shared_objects)
-set_target_properties(cxxabi_shared_objects PROPERTIES POSITION_INDEPENDENT_CODE ON)
set(cxxabi_static_sources $<TARGET_OBJECTS:cxxabi_static_objects>)
set(cxxabi_shared_sources $<TARGET_OBJECTS:cxxabi_shared_objects>)
OpenPOWER on IntegriCloud