That last patch was messed up. Here's a new one.

Hi chandlerc,

http://llvm-reviews.chandlerc.com/D82

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D82?vs=373&id=375#toc

Files:
  CMakeLists.txt
  lib/CMakeLists.txt
  src/exception.cpp
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -39,10 +39,15 @@
 option(LIBCXX_ENABLE_CXX0X "Enable -std=c++0x and use of c++0x language features if the compiler supports it." ON)
 option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)

+set(CXXABIS none libcxxabi libcxxrt libsupc++)
+set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING
+    "Specify C++ ABI library to use." FORCE)
+set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS "";${CXXABIS})
+
 #===============================================================================
 # Configure System
 #===============================================================================

 # Get triples.
 include(GetTriple)
 get_host_triple(LIBCXX_HOST_TRIPLE
@@ -58,13 +63,61 @@
   )
 set(LIBCXX_TARGET_TRIPLE ${LIBCXX_TARGET_TRIPLE} CACHE STRING "Target triple.")

+if (${LIBCXX_CXX_ABI} STREQUAL "libsupc++")
+  set(LIBCXX_LIBSUPCXX_INCLUDE_PATHS "" CACHE STRINGS
+      "Paths to libsupc++ include directories. Separate by system separator")
+  set(LIBCXX_CXX_ABI_LIBRARIES stdc++)
+  set(LIBCXX_LIBSUPCXX_FILES
+      cxxabi.h
+      bits/c++config.h
+      bits/os_defines.h
+      bits/cpu_defines.h
+      bits/cxxabi_tweaks.h
+      bits/cxxabi_forced.h
+      )
+  set(LIBCXX_LIBSUPCXX_FILE_PATHS)
+  foreach(path ${LIBCXX_LIBSUPCXX_FILES})
+    set(found FALSE)
+    foreach(incpath ${LIBCXX_LIBSUPCXX_INCLUDE_PATHS})
+      if (EXISTS "${incpath}/${path}")
+        set(found TRUE)
+        get_filename_component(dstdir ${path} PATH)
+        get_filename_component(file ${path} NAME)
+        add_custom_command(
+          OUTPUT "${CMAKE_BINARY_DIR}/include/${dstdir}/${file}"
+          COMMAND ${CMAKE_COMMAND} -E copy_if_different
+                    "${incpath}/${path}"
+                    "${CMAKE_BINARY_DIR}/include/${dstdir}"
+          MAIN_DEPENDENCY "${incpath}/${path}"
+          )
+        list(APPEND LIBCXX_CXX_ABI_DEPS
+                    "${CMAKE_BINARY_DIR}/include/${dstdir}/${file}")
+      endif()
+    endforeach()
+    if (NOT found)
+      message(FATAL_ERROR "Failed to find ${path}")
+    endif()
+  endforeach()
+  add_custom_target(supcxx_headers DEPENDS ${LIBCXX_CXX_ABI_DEPS})
+  set(LIBCXX_CXX_ABI_DEPS supcxx_headers)
+  include_directories("${CMAKE_BINARY_DIR}/include")
+  install(DIRECTORY "${CMAKE_BINARY_DIR}/include/"
+    DESTINATION include/c++/v1
+    FILES_MATCHING
+    PATTERN "*"
+    )
+elseif (${LIBCXX_CXX_ABI} NOT STREQUAL "none")
+  message(FATAL_ERROR
+          "Currently only none and libsupc++ are supported for c++ abi.")
+endif ()
+
 # Configure compiler.
 include(config-ix)

 #===============================================================================
 # Setup Compiler Flags
 #===============================================================================

 # Get required flags.
 # On all systems the system c++ standard library headers need to be excluded.
 if (MSVC)
Index: lib/CMakeLists.txt
===================================================================
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -31,33 +31,36 @@
     )
 endif()

+add_dependencies(cxx ${LIBCXX_CXX_ABI_DEPS})
+
 # Generate library list.
+set(libraries ${LIBCXX_CXX_ABI_LIBRARIES})
 append_if(libraries LIBCXX_HAS_PTHREAD_LIB pthread)
 append_if(libraries LIBCXX_HAS_C_LIB c)
 append_if(libraries LIBCXX_HAS_M_LIB m)
 append_if(libraries LIBCXX_HAS_RT_LIB rt)
 append_if(libraries LIBCXX_HAS_GCC_S_LIB gcc_s)

 target_link_libraries(cxx ${libraries})

 # Setup flags.
 append_if(compile_flags LIBCXX_HAS_FPIC_FLAG -fPIC)
 append_if(link_flags LIBCXX_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs)

 set_target_properties(cxx
   PROPERTIES
     COMPILE_FLAGS "${compile_flags}"
     LINK_FLAGS    "${link_flags}"
     OUTPUT_NAME   "c++"
     VERSION       "1.0"
     SOVERSION     "1"
   )

 install(TARGETS cxx
   LIBRARY DESTINATION lib
   ARCHIVE DESTINATION lib
   )

 install(DIRECTORY ../include/
   DESTINATION include/c++/v1
   FILES_MATCHING
Index: src/exception.cpp
===================================================================
--- src/exception.cpp
+++ src/exception.cpp
@@ -41,42 +41,42 @@
 namespace std
 {

-#if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
+#if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__)

 // libcxxrt provides implementations of these functions itself.
 unexpected_handler
 set_unexpected(unexpected_handler func) _NOEXCEPT
 {
     return __sync_lock_test_and_set(&__unexpected_handler, func);
 }

 unexpected_handler
 get_unexpected() _NOEXCEPT
 {
     return __sync_fetch_and_add(&__unexpected_handler, (unexpected_handler)0);
 }

 _LIBCPP_NORETURN
 void
 unexpected()
 {
     (*get_unexpected())();
     // unexpected handler should not return
     terminate();
 }

 terminate_handler
 set_terminate(terminate_handler func) _NOEXCEPT
 {
     return __sync_lock_test_and_set(&__terminate_handler, func);
 }

 terminate_handler
 get_terminate() _NOEXCEPT
 {
     return __sync_fetch_and_add(&__terminate_handler, (terminate_handler)0);
 }

 _LIBCPP_NORETURN
 void
 terminate() _NOEXCEPT
@@ -99,7 +99,7 @@
 }
 #endif // !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)

-#ifndef LIBCXXRT
+#if !defined(LIBCXXRT) && !defined(__GLIBCXX__)
 bool uncaught_exception() _NOEXCEPT
 {
 #if __APPLE__ || defined(_LIBCPPABI_VERSION)
@@ -124,20 +124,20 @@

 #endif  // _LIBCPPABI_VERSION
 #endif //LIBCXXRT
-#ifndef _LIBCPPABI_VERSION
+#if !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__)

 bad_exception::~bad_exception() _NOEXCEPT
 {
 }

 const char* bad_exception::what() const _NOEXCEPT
 {
   return "std::bad_exception";
 }

 #endif


 exception_ptr::~exception_ptr() _NOEXCEPT
 {
 #if HAVE_DEPENDENT_EH_ABI
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to