[libc++abi] Don't set POSITION_INDEPENDENT_CODE when building static library
With the current WebAssembly backend, objects built with -fPIC are not
compatible with static linking. libc++abi was (mistakenly?) adding
-fPIC to the objects it was including in a static library.
IIUC this change should also mean the static build can be more efficient
on all platforms.
Differential Revision: https://reviews.llvm.org/D60005
git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@357322 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b05178a..7123718 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -153,9 +153,7 @@
CXX_STANDARD_REQUIRED
ON
COMPILE_FLAGS
- "${LIBCXXABI_COMPILE_FLAGS}"
- POSITION_INDEPENDENT_CODE
- ON)
+ "${LIBCXXABI_COMPILE_FLAGS}")
if(ARGS_DEFINES)
target_compile_definitions(${name} PRIVATE ${ARGS_DEFINES})
@@ -174,15 +172,14 @@
_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS
_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
FLAGS ${CXXABI_STATIC_OBJECTS_FLAGS})
- cxxabi_object_library(cxxabi_shared_objects)
- set(cxxabi_static_sources $<TARGET_OBJECTS:cxxabi_static_objects>)
- set(cxxabi_shared_sources $<TARGET_OBJECTS:cxxabi_shared_objects>)
else()
- cxxabi_object_library(cxxabi_objects)
- set(cxxabi_static_sources $<TARGET_OBJECTS:cxxabi_objects>)
- set(cxxabi_shared_sources $<TARGET_OBJECTS:cxxabi_objects>)
+ cxxabi_object_library(cxxabi_static_objects)
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>)
+
# Build the shared library.
if (LIBCXXABI_ENABLE_SHARED)
add_library(cxxabi_shared SHARED ${cxxabi_shared_sources})
@@ -238,9 +235,7 @@
LINK_FLAGS
"${LIBCXXABI_LINK_FLAGS}"
OUTPUT_NAME
- "c++abi"
- POSITION_INDEPENDENT_CODE
- ON)
+ "c++abi")
list(APPEND LIBCXXABI_BUILD_TARGETS "cxxabi_static")
if (LIBCXXABI_INSTALL_STATIC_LIBRARY)
list(APPEND LIBCXXABI_INSTALL_TARGETS "cxxabi_static")