[PATCH] D15440: [libc++abi] Use libgcc and libgcc_s to provide _Unwind symbols instead of libgcc_eh.a
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 10 20:26:12 PST 2015
EricWF created this revision.
EricWF added reviewers: danalbert, chandlerc, mclow.lists, compnerd, ismail.
EricWF added a subscriber: cfe-commits.
libgcc_eh.a cannot be used when building libc++abi as a shared library (the default configuration). See this post for some more discussion: https://gcc.gnu.org/ml/gcc/2012-03/msg00104.html
This patch reverts back to using libgcc_s when linking libc++abi.so. However gcc_s doesn't contain all of the symbols needed by libc++abi.so. The missing symbols will be resolved by libgcc.a when linking the final executable.
http://reviews.llvm.org/D15440
Files:
cmake/config-ix.cmake
src/CMakeLists.txt
Index: src/CMakeLists.txt
===================================================================
--- src/CMakeLists.txt
+++ src/CMakeLists.txt
@@ -19,6 +19,23 @@
typeinfo.cpp
)
+
+# Remove a list of flags from all CMake variables that affect compile flags.
+# This can be used to remove unwanted flags specified on the command line
+# or added in other parts of LLVM's cmake configuration.
+macro(remove_flags)
+ foreach(var ${ARGN})
+ string(REPLACE "${var}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+ string(REPLACE "${var}" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+ string(REPLACE "${var}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
+ string(REPLACE "${var}" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
+ string(REPLACE "${var}" "" CMAKE_SHARED_MODULE_FLAGS "${CMAKE_SHARED_MODULE_FLAGS}")
+ remove_definitions(${var})
+ endforeach()
+endmacro(remove_flags)
+
+remove_flags(-Wl,-z,defs)
+
if (UNIX AND NOT (APPLE OR CYGWIN))
list(APPEND LIBCXXABI_SOURCES cxa_thread_atexit.cpp)
endif()
@@ -40,17 +57,25 @@
add_definitions(-DHAVE___CXA_THREAD_ATEXIT_IMPL)
endif()
-# Generate library list.
+# Generate library list. When not using LLVM unwinder libgcc_s should be the
+# first and last library on the link line. This behavior mimics clang's
+# behavior.
set(libraries ${LIBCXXABI_CXX_ABI_LIBRARIES})
-append_if(libraries LIBCXXABI_HAS_C_LIB c)
+
+if (NOT LIBCXXABI_USE_LLVM_UNWINDER)
+ append_if(libraries LIBCXXABI_HAS_GCC_S_LIB gcc_s)
+endif()
+
if (LIBCXXABI_ENABLE_THREADS)
append_if(libraries LIBCXXABI_HAS_PTHREAD_LIB pthread)
endif()
+append_if(libraries LIBCXXABI_HAS_C_LIB c)
+
if (LIBCXXABI_USE_LLVM_UNWINDER)
list(APPEND libraries unwind)
else()
- append_if(libraries LIBCXXABI_HAS_GCC_EH_LIB gcc_eh)
+ append_if(libraries LIBCXXABI_HAS_GCC_S_LIB gcc_s)
endif()
# Setup flags.
Index: cmake/config-ix.cmake
===================================================================
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -42,6 +42,6 @@
check_library_exists(c fopen "" LIBCXXABI_HAS_C_LIB)
check_library_exists(dl dladdr "" LIBCXXABI_HAS_DL_LIB)
check_library_exists(pthread pthread_once "" LIBCXXABI_HAS_PTHREAD_LIB)
-check_library_exists(gcc_eh _Unwind_GetRegionStart "" LIBCXXABI_HAS_GCC_EH_LIB)
+check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXXABI_HAS_GCC_S_LIB)
check_library_exists(c __cxa_thread_atexit_impl ""
LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15440.42495.patch
Type: text/x-patch
Size: 2472 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151211/93362f77/attachment-0001.bin>
More information about the cfe-commits
mailing list