Skip to content

Instantly share code, notes, and snippets.

@EricWF
Created December 19, 2014 21:26
Show Gist options
  • Select an option

  • Save EricWF/eaf71cdef95ba028e86b to your computer and use it in GitHub Desktop.

Select an option

Save EricWF/eaf71cdef95ba028e86b to your computer and use it in GitHub Desktop.
New patch
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 58abdf8..701187d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -43,6 +43,7 @@ option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
option(LIBCXX_ENABLE_CXX1Y "Enable -std=c++1y and use of c++1y language features if the compiler supports it." OFF)
option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON)
+option(LIBCXX_ENABLE_UNSTABLE_ABI "Build with the unstable ABI changes." OFF)
option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++" OFF)
option(LIBCXX_ENABLE_MONOTONIC_CLOCK
"Build libc++ with support for a monotonic clock.
@@ -206,6 +207,8 @@ endif()
if (NOT LIBCXX_ENABLE_SHARED)
list(APPEND LIBCXX_COMPILE_FLAGS -D_LIBCPP_BUILD_STATIC)
endif()
+# Unstable ABI
+append_if(LIBCXX_CXX_FLAGS LIBCXX_ENABLE_UNSTABLE_ABI -D_LIBCPP_ABI_UNSTABLE)
if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32)
if (LIBCXX_BUILD_32_BITS)
diff --git a/include/__config b/include/__config
index 8fd80bc..7dddf87 100644
--- a/include/__config
+++ b/include/__config
@@ -581,6 +581,13 @@ template <unsigned> struct __static_assert_check {};
#define __has_builtin(__x) 0
#endif
+#ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT
+#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+#endif
+#ifdef _LIBCPP_ABI_UNSTABLE
+#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
+#endif
+
#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__)
# define _LIBCPP_EXPLICIT explicit
#else
diff --git a/include/string b/include/string
index fe42bbf..f09b0f1 100644
--- a/include/string
+++ b/include/string
@@ -1185,7 +1185,7 @@ _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS __basic_string_common<true>)
#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 @@ struct __padding<_CharT, 1>
{
};
-#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 @@ public:
private:
-#ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT
+#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
struct __long
{
@@ -1294,7 +1294,7 @@ private:
value_type __data_[__min_cap];
};
-#endif // _LIBCPP_ALTERNATE_STRING_LAYOUT
+#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
union __ulx{__long __lx; __short __lxx;};
@@ -1680,7 +1680,7 @@ private:
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
@@ -1698,7 +1698,7 @@ private:
{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
@@ -1716,7 +1716,7 @@ private:
{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
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index fe82dee..58be81a 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -32,6 +32,7 @@ if(PYTHONINTERP_FOUND)
pythonize_bool(LIBCXX_ENABLE_SHARED)
pythonize_bool(LIBCXX_BUILD_32_BITS)
pythonize_bool(LIBCXX_ENABLE_THREADS)
+ pythonize_bool(LIBCXX_ENABLE_UNSTABLE_ABI)
pythonize_bool(LIBCXX_ENABLE_MONOTONIC_CLOCK)
set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
diff --git a/test/lit.cfg b/test/lit.cfg
index e7cd818..55ea9bd 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -485,7 +485,10 @@ class Configuration(object):
elif not enable_monotonic_clock:
self.lit_config.fatal('enable_monotonic_clock cannot be false when'
' enable_threads is true.')
-
+ # Configure the ABI flags.
+ enable_unstable_abi = self.get_lit_bool('enable_unstable_abi', False)
+ if enable_unstable_abi:
+ self.compile_flags += ['-D_LIBCPP_ABI_UNSTABLE']
def configure_link_flags(self):
# Configure library search paths
diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in
index f4bd8e4..2276692 100644
--- a/test/lit.site.cfg.in
+++ b/test/lit.site.cfg.in
@@ -10,6 +10,7 @@ config.enable_shared = "@LIBCXX_ENABLE_SHARED@"
config.enable_32bit = "@LIBCXX_BUILD_32_BITS@"
config.enable_threads = "@LIBCXX_ENABLE_THREADS@"
config.enable_monotonic_clock = "@LIBCXX_ENABLE_MONOTONIC_CLOCK@"
+config.enable_unstable_abi = "@LIBCXX_ENABLE_UNSTABLE_ABI@"
config.cxx_abi = "@LIBCXX_CXX_ABI_LIBNAME@"
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
config.abi_library_path = "@LIBCXX_CXX_ABI_LIBRARY_PATH@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment