[libcxxabi] r212824 - Add support for building and testing the unwinder.

Dan Albert danalbert at google.com
Fri Jul 11 08:36:02 PDT 2014


Author: danalbert
Date: Fri Jul 11 10:36:02 2014
New Revision: 212824

URL: http://llvm.org/viewvc/llvm-project?rev=212824&view=rev
Log:
Add support for building and testing the unwinder.

Note: The unwinder currently only works on Darwin and on ARM Linux.
Non-ARM Linux support is not yet implemented, and will fail to build.

Added:
    libcxxabi/trunk/src/Unwind/CMakeLists.txt
Modified:
    libcxxabi/trunk/CMakeLists.txt
    libcxxabi/trunk/src/CMakeLists.txt
    libcxxabi/trunk/test/CMakeLists.txt
    libcxxabi/trunk/test/lit.cfg
    libcxxabi/trunk/test/lit.site.cfg.in

Modified: libcxxabi/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=212824&r1=212823&r2=212824&view=diff
==============================================================================
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Fri Jul 11 10:36:02 2014
@@ -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

Modified: libcxxabi/trunk/src/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/CMakeLists.txt?rev=212824&r1=212823&r2=212824&view=diff
==============================================================================
--- libcxxabi/trunk/src/CMakeLists.txt (original)
+++ libcxxabi/trunk/src/CMakeLists.txt Fri Jul 11 10:36:02 2014
@@ -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)

Added: libcxxabi/trunk/src/Unwind/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/Unwind/CMakeLists.txt?rev=212824&view=auto
==============================================================================
--- libcxxabi/trunk/src/Unwind/CMakeLists.txt (added)
+++ libcxxabi/trunk/src/Unwind/CMakeLists.txt Fri Jul 11 10:36:02 2014
@@ -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
+  )

Modified: libcxxabi/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/CMakeLists.txt?rev=212824&r1=212823&r2=212824&view=diff
==============================================================================
--- libcxxabi/trunk/test/CMakeLists.txt (original)
+++ libcxxabi/trunk/test/CMakeLists.txt Fri Jul 11 10:36:02 2014
@@ -10,6 +10,7 @@ set(LIBCXXABI_COMPILER ${CMAKE_CXX_COMPI
 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}

Modified: libcxxabi/trunk/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/lit.cfg?rev=212824&r1=212823&r2=212824&view=diff
==============================================================================
--- libcxxabi/trunk/test/lit.cfg (original)
+++ libcxxabi/trunk/test/lit.cfg Fri Jul 11 10:36:02 2014
@@ -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")
 

Modified: libcxxabi/trunk/test/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/lit.site.cfg.in?rev=212824&r1=212823&r2=212824&view=diff
==============================================================================
--- libcxxabi/trunk/test/lit.site.cfg.in (original)
+++ libcxxabi/trunk/test/lit.site.cfg.in Fri Jul 11 10:36:02 2014
@@ -5,6 +5,7 @@ config.libcxxabi_obj_root    = "@LIBCXXA
 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")





More information about the cfe-commits mailing list