Hi Marshall,

I can't build libcxxabi after this commit (using lib/buildit script).
This commit supposes that libcxx/include should be added to -I compiler flags. I have fixed 'buildit' script, so now it asks LIBCXX_INCLUDE environment variable to be set.
Please review my patch in attachment.
Thanks!

Truly yours,
Stepan Dyatkovskiy

08.05.2014, 00:31, "Marshall Clow" <[email protected]>:
Author: marshall
Date: Wed May  7 15:17:41 2014
New Revision: 208246

URL: http://llvm.org/viewvc/llvm-project?rev=208246&view=rev
Log:
Make libc++abi use the implementation of __numstr from libc++. No functionality 
change, just removal of duplicated code.

Modified:
    libcxxabi/trunk/src/stdexcept.cpp

Modified: libcxxabi/trunk/src/stdexcept.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/stdexcept.cpp?rev=208246&r1=208245&r2=208246&view=diff
==============================================================================
--- libcxxabi/trunk/src/stdexcept.cpp (original)
+++ libcxxabi/trunk/src/stdexcept.cpp Wed May  7 15:17:41 2014
@@ -7,6 +7,7 @@
 //
 
//===----------------------------------------------------------------------===//

+#include "__refstring"
 #include "stdexcept"
 #include "new"
 #include <cstdlib>
@@ -14,147 +15,25 @@
 #include <cstdint>
 #include <cstddef>

-#if __APPLE__
-#include <dlfcn.h>
-#include <mach-o/dyld.h>
-#endif
-
-// Note:  optimize for size
-
-#pragma GCC visibility push(hidden)
-
-namespace
-{
-
-class __libcpp_nmstr
-{
-private:
-    const char* str_;
-
-    typedef int count_t;
-
-    struct _Rep_base
-    {
-        std::size_t len;
-        std::size_t cap;
-        count_t     count;
-    };
-
-    static const std::ptrdiff_t offset = 
static_cast<std::ptrdiff_t>(sizeof(_Rep_base));
-
-    count_t& count() const _NOEXCEPT {return ((_Rep_base*)(str_ - 
offset))->count;}
-
-#if __APPLE__
-    static
-    const void*
-    compute_gcc_empty_string_storage() _NOEXCEPT
-    {
-        void* handle = dlopen("/usr/lib/libstdc++.6.dylib", RTLD_NOLOAD);
-        if (handle == 0)
-            return 0;
-        return (const char*)dlsym(handle, "_ZNSs4_Rep20_S_empty_rep_storageE") 
+ offset;
-    }
-
-    static
-    const void*
-    get_gcc_empty_string_storage() _NOEXCEPT
-    {
-        static const void* p = compute_gcc_empty_string_storage();
-        return p;
-    }
-#endif
-
-public:
-    explicit __libcpp_nmstr(const char* msg);
-    __libcpp_nmstr(const __libcpp_nmstr& s) _NOEXCEPT;
-    __libcpp_nmstr& operator=(const __libcpp_nmstr& s) _NOEXCEPT;
-    ~__libcpp_nmstr();
-    const char* c_str() const _NOEXCEPT {return str_;}
-};
-
-__libcpp_nmstr::__libcpp_nmstr(const char* msg)
-{
-    std::size_t len = strlen(msg);
-    str_ = static_cast<const char*>(::operator new(len + 1 + offset));
-    _Rep_base* c = (_Rep_base*)str_;
-    c->len = c->cap = len;
-    str_ += offset;
-    count() = 0;
-    std::memcpy(const_cast<char*>(c_str()), msg, len + 1);
-}
-
-inline
-__libcpp_nmstr::__libcpp_nmstr(const __libcpp_nmstr& s) _NOEXCEPT
-    : str_(s.str_)
-{
-#if __APPLE__
-    if (str_ != get_gcc_empty_string_storage())
-#endif
-        __sync_add_and_fetch(&count(), 1);
-}
-
-__libcpp_nmstr&
-__libcpp_nmstr::operator=(const __libcpp_nmstr& s) _NOEXCEPT
-{
-    const char* p = str_;
-    str_ = s.str_;
-#if __APPLE__
-    if (str_ != get_gcc_empty_string_storage())
-#endif
-        __sync_add_and_fetch(&count(), 1);
-#if __APPLE__
-    if (p != get_gcc_empty_string_storage())
-#endif
-        if (__sync_add_and_fetch((count_t*)(p-sizeof(count_t)), count_t(-1)) < 
0)
-        {
-            ::operator delete(const_cast<char*>(p-offset));
-        }
-    return *this;
-}
-
-inline
-__libcpp_nmstr::~__libcpp_nmstr()
-{
-#if __APPLE__
-    if (str_ != get_gcc_empty_string_storage())
-#endif
-        if (__sync_add_and_fetch(&count(), count_t(-1)) < 0)
-        {
-            ::operator delete(const_cast<char*>(str_ - offset));
-        }
-}
-
-}
-
-#pragma GCC visibility pop
+static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), "");

 namespace std  // purposefully not using versioning namespace
 {

-logic_error::~logic_error() _NOEXCEPT
-{
-    __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
-    s.~__libcpp_nmstr();
-}
+logic_error::~logic_error() _NOEXCEPT {}

 const char*
 logic_error::what() const _NOEXCEPT
 {
-    __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
-    return s.c_str();
+    return __imp_.c_str();
 }

-runtime_error::~runtime_error() _NOEXCEPT
-{
-    __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
-    s.~__libcpp_nmstr();
-}
+runtime_error::~runtime_error() _NOEXCEPT {}

 const char*
 runtime_error::what() const _NOEXCEPT
 {
-    __libcpp_nmstr& s = (__libcpp_nmstr&)__imp_;
-    return s.c_str();
+    return __imp_.c_str();
 }

 domain_error::~domain_error() _NOEXCEPT {}

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
diff --git a/lib/buildit b/lib/buildit
index 5a4a710..cbbce6d 100755
--- a/lib/buildit
+++ b/lib/buildit
@@ -4,6 +4,14 @@
 # running this script.  If you set $CXX, that will be used to compile
 # the library.  Otherwise we'll use clang++.
 
+if [ -z "$LIBCXX_INCLUDE" ]
+then
+	echo "LIBCXX_INCLUDE is not present in SH environment."
+	echo "Please, setup it using next command:"
+	echo "'export LIBCXX_INCLUDE=<your libcxx-location>/include'"
+	exit 1
+fi
+
 set -e
 
 if [ `basename $(pwd)` != "lib" ]
@@ -82,7 +90,7 @@ fi
 set -x
 
 for FILE in ../src/*.cpp; do
-	$CXX -c -g -O3 $RC_CFLAGS $EXTRA_FLAGS -I../include $OPTIONS $FILE
+	$CXX -c -g -O3 $RC_CFLAGS $EXTRA_FLAGS -I../include -I$LIBCXX_INCLUDE $OPTIONS $FILE
 done
 case $TRIPLE in
   *-*-mingw*)
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to