Hi All, LLVM now includes a C++ standard library, written by Howard Hinnant. You can read about it here: http://blog.llvm.org/2010/05/new-libc-c-standard-library.html Or get the code here: svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx If you have questions or comments, please direct them to one of the clang mailing lists. Thanks! -Chris
On 5/11/10 4:43 PM, Chris Lattner wrote:> Hi All, > > LLVM now includes a C++ standard library, written by Howard Hinnant. You can read about it here: > http://blog.llvm.org/2010/05/new-libc-c-standard-library.html > > Or get the code here: > svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx > > If you have questions or comments, please direct them to one of the clang mailing lists. Thanks! > > -ChrisAwesome news! The links to 'Browse SVN' and 'Browse ViewVC' seem to be pointing to compiler-rt instead of libcxx though... -- Joe Ranieri
On May 11, 2010, at 4:46 PM, Joe Ranieri wrote:> On 5/11/10 4:43 PM, Chris Lattner wrote: >> Hi All, >> >> LLVM now includes a C++ standard library, written by Howard Hinnant. You can read about it here: >> http://blog.llvm.org/2010/05/new-libc-c-standard-library.html >> >> Or get the code here: >> svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx >> >> If you have questions or comments, please direct them to one of the clang mailing lists. Thanks! >> >> -Chris > > Awesome news! The links to 'Browse SVN' and 'Browse ViewVC' seem to be > pointing to compiler-rt instead of libcxx though...Thanks Joe. Try now. -Howard
On Tuesday 11 May 2010 15:43:21 Chris Lattner wrote:> Hi All, > > LLVM now includes a C++ standard library, written by Howard Hinnant. You > can read about it here: > http://blog.llvm.org/2010/05/new-libc-c-standard-library.html > > Or get the code here: > svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx > > If you have questions or comments, please direct them to one of the clang > mailing lists. Thanks!This looks cool, but I can't help wondering about the motivation. libstdc++ has a ton of useful functionality (debug mode, profile mode, etc.). Does libc++ plan to reproduce that? What's driving libc++? -Dave
On May 11, 2010, at 7:26 PM, David Greene wrote:> On Tuesday 11 May 2010 15:43:21 Chris Lattner wrote: >> Hi All, >> >> LLVM now includes a C++ standard library, written by Howard Hinnant. You >> can read about it here: >> http://blog.llvm.org/2010/05/new-libc-c-standard-library.html >> >> Or get the code here: >> svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx >> >> If you have questions or comments, please direct them to one of the clang >> mailing lists. Thanks! > > This looks cool, but I can't help wondering about the motivation. libstdc++ > has a ton of useful functionality (debug mode, profile mode, etc.). Does > libc++ plan to reproduce that?debug mode yes. It isn't there yet. And I would like to limit it to being ABI compatible with release mode. This will entail significant debug functionality curtailment, but also eliminate numerous errors I've seen when debug mode and release mode get accidentally mixed.> What's driving libc++?The possibility of being a superior solution. ---------------- // Container overhead example #include <iostream> #include <deque> #include <map> int main() { typedef std::map<int, int> M; typedef std::deque<int> C; std::cout << "sizeof map<int, int> = " << sizeof(M)/sizeof(void*) << '\n'; std::cout << "sizeof deque<int> = " << sizeof(C)/sizeof(void*) << '\n'; } libc++: sizeof map<int, int> = 3 sizeof deque<int> = 6 libstdc++: sizeof map<int, int> = 6 sizeof deque<int> = 10 (smaller is better) ---------------- // Adding a few items to a sorted sequence and resorting // (a real world use case) #include <iostream> #include <algorithm> #include <vector> #include <ctime> int main() { typedef std::vector<int> V; V v; const int N = 100000000; for (int i = 0; i < N; ++i) v.push_back(i); for (int i = N; i > 0;) { i -= N/10; int j = v[i]; v.erase(v.begin() + i); v.push_back(j); } std::random_shuffle(v.begin() + 9 * v.size() / 10, v.end()); // How long does it take to resort a vector when // only the last 90% is unsorted? std::time_t t0 = std::time(0); std::sort(v.begin(), v.end()); std::time_t t1 = std::time(0); std::cout << difftime(t1, t0) << " seconds\n"; } libc++: 5 seconds libstdc++: 22 seconds (smaller is better) ---------------- This being said, clang will continue to be std::lib neutral. If libstdc++ meets your needs better than libc++, then you should use it. libc++ will have to earn its place. -Howard
On May 11, 2010, at 8:40 PM, Andrew Sutton wrote:> > What's driving libc++? > > The possibility of being a superior solution. > > I thought "to support Apple applications" from the previous post was sufficient motivation :) Either way, I'm excited about a new library. Plus, it looks a little easier to read (from the tiny amount of code that I've looked at). > > libc++: > > 5 seconds > > libstdc++: > > 22 seconds > > (smaller is better) > > Is this libstdc++ with or without rvalue references?This was compiled with g++-4.-2 -O3 (without rvalue references, which would have no effect on sorting ints anyway). -Howard
On Tue, May 11, 2010 at 5:40 PM, Andrew Sutton <andrew.n.sutton at gmail.com>wrote:> > What's driving libc++? >> >> The possibility of being a superior solution. >> > > I thought "to support Apple applications" from the previous post was > sufficient motivation :) Either way, I'm excited about a new library. Plus, > it looks a little easier to read (from the tiny amount of code that I've > looked at). >Just two throw 2 more motivators in... Sometimes to re-implement after learning from work done before by others is a reason to try it in itself. Also a lot of LLVM is C++ isn't it? Wouldn't it be nice if it were 100% self hosting at some point? (I think so.) Not having to depend on anyone else to make your stuff work is, well, liberating. Dave> > >> libc++: >> >> 5 seconds >> >> libstdc++: >> >> 22 seconds >> >> (smaller is better) >> > > Is this libstdc++ with or without rvalue references? >How about compile times? Having used Go a bit, I've been quite fond of how short the code, compile, test loop ends up being. Dave> > Andrew Sutton > andrew.n.sutton at gmail.com > > _______________________________________________ > cfe-dev mailing list > cfe-dev at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100511/16738ee3/attachment.html>
On May 11, 2010, at 9:32 PM, David Leimbach wrote:> > libc++: > > 5 seconds > > libstdc++: > > 22 seconds > > (smaller is better) > > Is this libstdc++ with or without rvalue references? > > How about compile times? Having used Go a bit, I've been quite fond of how short the code, compile, test loop ends up being.Tonight compile times look worse. This isn't completely unexpected as the code size of the libc++ sort is larger than the libstdc++ sort. Here is a matrix of times. Each time represents seconds and a median of 3 measurements: compile time run time ---------------- ---------------- libstdc++ libc++ libstdc++ libc++ g++-4.2 -O3 0.62 0.96 23 5 clang++ -O3 0.66 0.80 21 5 Since compile times are usually more important with non-opitimzed builds I computed the same table at -O0: compile time run time ---------------- ---------------- libstdc++ libc++ libstdc++ libc++ g++-4.2 -O0 0.48 .76 186 5 clang++ -O0 0.46 .70 261 5 -Howard
On Tuesday 11 May 2010 20:32:58 David Leimbach wrote:> Just two throw 2 more motivators in... > > Sometimes to re-implement after learning from work done before by others is > a reason to try it in itself. Also a lot of LLVM is C++ isn't it?Yes...> Wouldn't it be nice if it were 100% self hosting at some point? (I think > so.)Define self-hosting. LLVM is already self-hosting in the sense that it compiles itself.> Not having to depend on anyone else to make your stuff work is, well, > liberating.Yikes! To me that is the scariest scenario I can imagine. The best technical interview question I've ever been asked is, "what code would you never write?" Standard library functionality is at the top of my list. Why would anyone replace rigorously tested code with something not as widely tested that one has to maintain oneself? It reminds me of an interview lunch at which the developers constantly regaled me with tales of their wonderful custom data structures library. And then I asked about where they spend most of their time debugging. Guess where? Suffice to say, I didn't take that job. :) Again, I'm not dismissing libc++. I'm making a general point about reusing hardened code. If libc++ is demonstrably better than other solutions, I'll be the first on board. But I do wonder why libstdc++ could not be improved in the same way while retaining is enormous testing base. And what about libstdc++ doesn't work for Apple applications? -Dave
> > This was compiled with g++-4.-2 -O3 (without rvalue references, which would have no effect on sorting ints anyway).Errr, that is a pretty old version at this point. Also this was before significant performance improvements were target at libstdc++ *and* g++. It seems a bit strange to compare something from today to something that is now 3 release versions old.