eugenis updated this revision to Diff 33381.
eugenis added a comment.

Remove minor version, added abi_unstable,.
Keeping __config_version until the other change lands.
Tests use headers from the build directory.


http://reviews.llvm.org/D11740

Files:
  CMakeLists.txt
  docs/Abi.rst
  docs/BuildingLibcxx.rst
  include/CMakeLists.txt
  include/__config
  include/__config_version
  include/__config_version.cmake
  include/string
  lib/CMakeLists.txt
  test/CMakeLists.txt
  test/lit.site.cfg.in

Index: test/lit.site.cfg.in
===================================================================
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -2,6 +2,7 @@
 config.cxx_under_test           = "@LIBCXX_COMPILER@"
 config.libcxx_src_root          = "@LIBCXX_SOURCE_DIR@"
 config.libcxx_obj_root          = "@LIBCXX_BINARY_DIR@"
+config.libcxx_headers           = "@LIBCXX_HEADERS@"
 config.cxx_library_root         = "@LIBCXX_LIBRARY_DIR@"
 config.enable_exceptions        = "@LIBCXX_ENABLE_EXCEPTIONS@"
 config.enable_rtti              = "@LIBCXX_ENABLE_RTTI@"
Index: test/CMakeLists.txt
===================================================================
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -34,6 +34,7 @@
 
 set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
 
+set(LIBCXX_HEADERS "${CMAKE_BINARY_DIR}/include/c++/v${LIBCXX_ABI_VERSION}")
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
Index: lib/CMakeLists.txt
===================================================================
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -129,8 +129,8 @@
     COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
     LINK_FLAGS    "${LIBCXX_LINK_FLAGS}"
     OUTPUT_NAME   "c++"
-    VERSION       "1.0"
-    SOVERSION     "1"
+    VERSION       "${LIBCXX_ABI_VERSION}.0"
+    SOVERSION     "${LIBCXX_ABI_VERSION}"
   )
 
 if (LIBCXX_INSTALL_LIBRARY)
Index: include/string
===================================================================
--- include/string
+++ include/string
@@ -1185,7 +1185,7 @@
 #pragma warning( pop )
 #endif // _LIBCPP_MSVC
 
-#ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT
+#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 
 template <class _CharT, size_t = sizeof(_CharT)>
 struct __padding
@@ -1198,7 +1198,7 @@
 {
 };
 
-#endif  // _LIBCPP_ALTERNATE_STRING_LAYOUT
+#endif  // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 
 template<class _CharT, class _Traits, class _Allocator>
 class _LIBCPP_TYPE_VIS_ONLY basic_string
@@ -1234,7 +1234,7 @@
 
 private:
 
-#ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT
+#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 
     struct __long
     {
@@ -1294,7 +1294,7 @@
         value_type __data_[__min_cap];
     };
 
-#endif  // _LIBCPP_ALTERNATE_STRING_LAYOUT
+#endif  // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 
     union __ulx{__long __lx; __short __lxx;};
 
@@ -1696,7 +1696,7 @@
     const allocator_type& __alloc() const _NOEXCEPT
         {return __r_.second();}
 
-#ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT
+#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 
     _LIBCPP_INLINE_VISIBILITY
     void __set_short_size(size_type __s) _NOEXCEPT
@@ -1714,7 +1714,7 @@
         {return __r_.first().__s.__size_;}
 #   endif
 
-#else  // _LIBCPP_ALTERNATE_STRING_LAYOUT
+#else  // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 
     _LIBCPP_INLINE_VISIBILITY
     void __set_short_size(size_type __s) _NOEXCEPT
@@ -1732,7 +1732,7 @@
         {return __r_.first().__s.__size_ >> 1;}
 #   endif
 
-#endif  // _LIBCPP_ALTERNATE_STRING_LAYOUT
+#endif  // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 
     _LIBCPP_INLINE_VISIBILITY
     void __set_long_size(size_type __s) _NOEXCEPT
Index: include/__config_version.cmake
===================================================================
--- include/__config_version.cmake
+++ include/__config_version.cmake
@@ -0,0 +1,17 @@
+// -*- C++ -*-
+//===--------------------------- __config_version -------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_CONFIG_VERSION
+#define _LIBCPP_CONFIG_VERSION
+
+#define _LIBCPP_ABI_VERSION ${LIBCXX_ABI_VERSION}
+#cmakedefine _LIBCPP_ABI_UNSTABLE
+
+#endif
Index: include/__config_version
===================================================================
--- include/__config_version
+++ include/__config_version
@@ -0,0 +1,17 @@
+// -*- C++ -*-
+//===--------------------------- __config_version -------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_CONFIG_VERSION
+#define _LIBCPP_CONFIG_VERSION
+
+#define _LIBCPP_ABI_VERSION 1
+#undef _LIBCPP_ABI_UNSTABLE
+
+#endif
Index: include/__config
===================================================================
--- include/__config
+++ include/__config
@@ -11,6 +11,8 @@
 #ifndef _LIBCPP_CONFIG
 #define _LIBCPP_CONFIG
 
+#include <__config_version>
+
 #if !defined(_MSC_VER) || defined(__clang__)
 #pragma GCC system_header
 #endif
@@ -23,7 +25,9 @@
 
 #define _LIBCPP_VERSION 3800
 
-#define _LIBCPP_ABI_VERSION 1
+#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
+#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+#endif
 
 #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y
 #define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y)
@@ -230,9 +234,10 @@
 
 #if defined(__clang__)
 
-#if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) &&        \
-    !defined(__arm__)
-#define _LIBCPP_ALTERNATE_STRING_LAYOUT
+#if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) &&       \
+     !defined(__arm__)) ||                                                     \
+    defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
+#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
 #endif
 
 #if __has_feature(cxx_alignas)
Index: include/CMakeLists.txt
===================================================================
--- include/CMakeLists.txt
+++ include/CMakeLists.txt
@@ -3,20 +3,28 @@
 endif()
 set(LIBCXX_HEADER_PATTERN
   PATTERN "*"
+  PATTERN "__config_version" EXCLUDE
+  PATTERN "__config_version.cmake" EXCLUDE
   PATTERN "CMakeLists.txt" EXCLUDE
   PATTERN ".svn" EXCLUDE
   ${LIBCXX_SUPPORT_HEADER_PATTERN}
   )
 
 file(COPY .
-  DESTINATION "${CMAKE_BINARY_DIR}/include/c++/v1"
+  DESTINATION "${CMAKE_BINARY_DIR}/include/c++/v${LIBCXX_ABI_VERSION}"
   FILES_MATCHING
   ${LIBCXX_HEADER_PATTERN}
   )
 
+set(_LIBCPP_ABI_UNSTABLE ${LIBCXX_ABI_UNSTABLE})
+configure_file(
+  __config_version.cmake
+  "${CMAKE_BINARY_DIR}/include/c++/v${LIBCXX_ABI_VERSION}/__config_version")
+set(_LIBCPP_ABI_UNSTABLE)
+
 if (LIBCXX_INSTALL_HEADERS)
-  install(DIRECTORY .
-    DESTINATION include/c++/v1
+  install(DIRECTORY ${CMAKE_BINARY_DIR}/include/c++/v${LIBCXX_ABI_VERSION}
+    DESTINATION include/c++
     COMPONENT libcxx
     FILES_MATCHING
     ${LIBCXX_HEADER_PATTERN}
Index: docs/BuildingLibcxx.rst
===================================================================
--- docs/BuildingLibcxx.rst
+++ docs/BuildingLibcxx.rst
@@ -193,6 +193,25 @@
 
   Build libc++ with run time type information.
 
+
+libc++ Feature options
+----------------------
+
+The following options allow building libc++ for a different ABI version.
+
+.. option:: LIBCXX_ABI_VERSION:STRING
+
+  **Default**: ``1``
+
+  Defines the target ABI version of libc++.
+
+.. option:: LIBCXX_ABI_UNSTABLE:BOOL
+
+  **Default**: ``OFF``
+
+  Build the "unstable" ABI version of libc++. Includes all ABI changing features
+  on top of the current stable version.
+
 .. _LLVM-specific variables:
 
 LLVM-specific options
Index: docs/Abi.rst
===================================================================
--- docs/Abi.rst
+++ docs/Abi.rst
@@ -0,0 +1,17 @@
+
+====================
+Libc++ ABI stability
+====================
+
+Libc++ aims to preserve stable ABI to avoid subtle bugs when code built to the old ABI
+is linked with the code build to the new ABI. At the same time, libc++ allows ABI-breaking
+improvements and bugfixes for the scenarios when ABI change is not a issue.
+
+To support both cases, libc++ allows specifying the ABI version at the
+build time.  The version is defined with a cmake option
+LIBCXX_ABI_VERSION. Another option LIBCXX_ABI_UNSTABLE can be used to
+include all present ABI breaking features. These options translate
+into C++ macro definitions _LIBCPP_ABI_VERSION, _LIBCPP_ABI_UNSTABLE.
+
+Any ABI-changing feature is placed under it's own macro, _LIBCPP_ABI_XXX, which is enabled
+based on the value of _LIBCPP_ABI_VERSION. _LIBCPP_ABI_UNSTABLE, if set, enables all features at once.
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -58,6 +58,8 @@
 option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
 option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON)
 option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
+set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
+option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
 
 # ABI Library options ---------------------------------------------------------
 set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING
@@ -304,7 +306,7 @@
 #===============================================================================
 # Setup Source Code And Tests
 #===============================================================================
-include_directories(include)
+include_directories("${CMAKE_BINARY_DIR}/include/c++/v${LIBCXX_ABI_VERSION}")
 add_subdirectory(include)
 add_subdirectory(lib)
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to