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) 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.