diff options
| -rw-r--r-- | libcxxabi/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | libcxxabi/src/CMakeLists.txt | 8 | ||||
| -rw-r--r-- | libcxxabi/src/Unwind/CMakeLists.txt | 101 | ||||
| -rw-r--r-- | libcxxabi/test/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | libcxxabi/test/lit.cfg | 12 | ||||
| -rw-r--r-- | libcxxabi/test/lit.site.cfg.in | 1 | 
6 files changed, 124 insertions, 8 deletions
| diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index e6bef800014..bbb48b36963 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -104,6 +104,7 @@ endif()  option(LIBCXXABI_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)  option(LIBCXXABI_ENABLE_PEDANTIC "Compile with pedantic enabled." 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)  # Default to building a shared library so that the default options still test  # the libc++abi that is being built. There are two problems with testing a @@ -243,6 +244,10 @@ include_directories(include)  # soname, etc...  add_subdirectory(src) +if (LIBCXXABI_USE_LLVM_UNWINDER) +  add_subdirectory(src/Unwind) +endif() +  if(NOT LIBCXXABI_ENABLE_SHARED)    # TODO: Fix the libc++ cmake files so that libc++abi can be statically linked.    # As it is now, libc++ will prefer linking against a dynamic libc++abi in the diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt index 4bf860a91df..ae0befbf007 100644 --- a/libcxxabi/src/CMakeLists.txt +++ b/libcxxabi/src/CMakeLists.txt @@ -19,13 +19,7 @@ set(LIBCXXABI_SOURCES    typeinfo.cpp  ) -set(LIBCXXABI_HEADERS -  ../include/cxxabi.h -  ../include/libunwind.h -  ../include/unwind.h -) - -append_if(LIBCXXABI_HEADERS APPLE ../include/mach-o/compact_unwind_encoding.h) +set(LIBCXXABI_HEADERS ../include/cxxabi.h)  # Add all the headers to the project for IDEs.  if (MSVC_IDE OR XCODE) diff --git a/libcxxabi/src/Unwind/CMakeLists.txt b/libcxxabi/src/Unwind/CMakeLists.txt new file mode 100644 index 00000000000..ee2450487d3 --- /dev/null +++ b/libcxxabi/src/Unwind/CMakeLists.txt @@ -0,0 +1,101 @@ +# Get sources +set(LIBUNWIND_SOURCES +  libunwind.cpp +  Unwind-EHABI.cpp +  UnwindLevel1.c +  UnwindLevel1-gcc-ext.c +  Unwind-sjlj.c +) + +append_if(LIBUNWIND_SOURCES APPLE Unwind_AppleExtras.cpp) + +set(LIBUNWIND_ASM_SOURCES +  UnwindRegistersRestore.S +  UnwindRegistersSave.S +) + +set_source_files_properties(${LIBUNWIND_ASM_SOURCES} PROPERTIES LANGUAGE C) + +set(LIBUNWIND_HEADERS +  AddressSpace.hpp +  assembly.h +  CompactUnwinder.hpp +  config.h +  dwarf2.h +  DwarfInstructions.hpp +  DwarfParser.hpp +  libunwind_ext.h +  Registers.hpp +  UnwindCursor.hpp +  unwind_ext.h +  ../../include/libunwind.h +  ../../include/unwind.h +) + +append_if(LIBCXXABI_HEADERS APPLE ../../include/mach-o/compact_unwind_encoding.h) + +if (MSVC_IDE) +  # Force them all into the headers dir on MSVC, otherwise they end up at +  # project scope because they don't have extensions. +  source_group("Header Files" FILES ${LIBUNWIND_HEADERS}) +endif() + +if (LIBUNWIND_ENABLE_SHARED) +  add_library(unwind SHARED +    ${LIBUNWIND_SOURCES} +    ${LIBUNWIND_ASM_SOURCES} +    ${LIBUNWIND_HEADERS} +    ) +else() +  add_library(unwind STATIC +    ${LIBUNWIND_SOURCES} +    ${LIBUNWIND_ASM_SOURCES} +    ${LIBUNWIND_HEADERS} +    ) +endif() + +include_directories("${LIBCXXABI_LIBCXX_INCLUDES}") + +# Generate library list. +set(libraries ${LIBCXXABI_CXX_ABI_LIBRARIES}) +append_if(libraries LIBCXXABI_HAS_C_LIB c) + +target_link_libraries(unwind ${libraries}) + +# Setup flags. +append_if(compile_flags LIBCXXABI_HAS_FPIC_FLAG -fPIC) +append_if(link_flags LIBCXXABI_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs) + +set(LIBCXXABI_UNWINDER_NAME "unwind") + +if ( APPLE ) +  if ( CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.6" ) +    list(APPEND compile_flags "-U__STRICT_ANSI__") +    list(APPEND link_flags +      "-compatibility_version 1" +      "-current_version ${LIBCXXABI_VERSION}" +      "-install_name /usr/lib/lib${LIBCXXABI_UNWINDER_NAME}.1.dylib" +      "/usr/lib/libSystem.B.dylib") +  else() +    list(APPEND link_flags +      "-compatibility_version 1" +      "-install_name /usr/lib/lib${LIBCXXABI_UNWINDER_NAME}.1.dylib") +  endif() +endif() + +string(REPLACE ";" " " compile_flags "${compile_flags}") +string(REPLACE ";" " " link_flags "${link_flags}") + +set_target_properties(unwind +  PROPERTIES +    COMPILE_FLAGS "${compile_flags}" +    LINK_FLAGS    "${link_flags}" +    OUTPUT_NAME   "${LIBCXXABI_UNWINDER_NAME}" +    VERSION       "1.0" +    SOVERSION     "1" +  ) + +install(TARGETS unwind +  LIBRARY DESTINATION lib +  ARCHIVE DESTINATION lib +  ) diff --git a/libcxxabi/test/CMakeLists.txt b/libcxxabi/test/CMakeLists.txt index a8fca75f543..1383cd71133 100644 --- a/libcxxabi/test/CMakeLists.txt +++ b/libcxxabi/test/CMakeLists.txt @@ -10,6 +10,7 @@ set(LIBCXXABI_COMPILER ${CMAKE_CXX_COMPILER})  set(LIBCXXABI_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)  set(LIBCXXABI_BINARY_DIR ${CMAKE_BINARY_DIR})  pythonize_bool(LIBCXXABI_ENABLE_SHARED) +pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)  set(AUTO_GEN_COMMENT "## Autogenerated by libcxxabi configuration.\n# Do not edit!")  configure_file( @@ -22,6 +23,10 @@ if (NOT LIBCXXABI_BUILT_STANDALONE)    list(APPEND LIBCXXABI_TEST_DEPS cxx)  endif() +if (LIBCXXABI_USE_LLVM_UNWINDER) +  list(APPEND LIBCXXABI_TEST_DEPS unwind) +endif() +  add_lit_testsuite(check-libcxxabi "Running libcxxabi tests"    ${CMAKE_CURRENT_BINARY_DIR}    DEPENDS ${LIBCXXABI_TEST_DEPS} diff --git a/libcxxabi/test/lit.cfg b/libcxxabi/test/lit.cfg index 3f878a79a01..72d038dedcc 100644 --- a/libcxxabi/test/lit.cfg +++ b/libcxxabi/test/lit.cfg @@ -188,6 +188,10 @@ if enable_shared is None:      if enable_shared is None:          lit_config.fatal("enable_shared must be defined") +llvm_unwinder = getattr(config, 'llvm_unwinder', None) +if llvm_unwinder is None: +    lit_config.fatal("llvm_unwinder must be defined") +  link_flags = []  link_flags_str = lit_config.params.get('link_flags', None)  if link_flags_str is None: @@ -198,7 +202,13 @@ if link_flags_str is None:          if sys.platform == 'darwin':              link_flags += ['-lSystem']          elif sys.platform == 'linux2': -            link_flags += ['-lgcc_eh', '-lc', '-lm', '-lpthread', '-lgcc_s'] +            if not llvm_unwinder: +                link_flags += ['-lgcc_eh'] +            link_flags += ['-lc', '-lm', '-lpthread'] +            if llvm_unwinder: +                link_flags += ['-lunwind', '-ldl'] +            else: +                link_flags += ['-lgcc_s']          else:              lit_config.fatal("unrecognized system") diff --git a/libcxxabi/test/lit.site.cfg.in b/libcxxabi/test/lit.site.cfg.in index 4b05ed34531..94c61a0e4a7 100644 --- a/libcxxabi/test/lit.site.cfg.in +++ b/libcxxabi/test/lit.site.cfg.in @@ -5,6 +5,7 @@ config.libcxxabi_obj_root    = "@LIBCXXABI_BINARY_DIR@"  config.python_executable     = "@PYTHON_EXECUTABLE@"  config.enable_shared         = @LIBCXXABI_ENABLE_SHARED@  config.libcxx_includes       = "@LIBCXXABI_LIBCXX_INCLUDES@" +config.llvm_unwinder         = @LIBCXXABI_USE_LLVM_UNWINDER@  # Let the main config do the real work.  lit_config.load_config(config, "@LIBCXXABI_SOURCE_DIR@/test/lit.cfg") | 

