[libcxx-commits] [PATCH] D60005: [libc++abi] Don't set POSITION_INDEPENDENT_CODE when building static library

Sam Clegg via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 29 11:55:37 PDT 2019


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

With the current WebAssembly backend, objects build 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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60005

Files:
  libcxxabi/src/CMakeLists.txt


Index: libcxxabi/src/CMakeLists.txt
===================================================================
--- libcxxabi/src/CMakeLists.txt
+++ libcxxabi/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")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60005.192882.patch
Type: text/x-patch
Size: 1990 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190329/332d4184/attachment.bin>


More information about the libcxx-commits mailing list