<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Hi All,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>libcxx is fairly well designed to work in a no-exceptions environment, with<o:p></o:p></p><p class=MsoNormal>most of the sources diligently using the _LIBCPP_NO_EXCEPTIONS macro. However,<o:p></o:p></p><p class=MsoNormal>it seems to have bit-rotted a bit and could use some TLC right now. A<o:p></o:p></p><p class=MsoNormal>no-exceptions variety of libcxx would be quite useful when you want to use all<o:p></o:p></p><p class=MsoNormal>of libcxx goodness without the overhead of exceptions (especially in embedded<o:p></o:p></p><p class=MsoNormal>environments). I'm willing to do the necessary source / test updates and<o:p></o:p></p><p class=MsoNormal>following is my plan/proposal:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>[Phase-1: Fix the build, setup build-only build bots]<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Currently I cannot build libcxx with -DLIBCXX_ENABLE_EXCEPTIONS=0 due to a small<o:p></o:p></p><p class=MsoNormal>omission in one of the sources. The following patch fixes this:<o:p></o:p></p><p class=MsoNormal> http://reviews.llvm.org/D14172<o:p></o:p></p><p class=MsoNormal>Once we get the reviewed+committed, the next step would be to have some build-<o:p></o:p></p><p class=MsoNormal>bots setup so that we don't regress the build. I've already spoken to Renato<o:p></o:p></p><p class=MsoNormal>(copied) and he has kindly agreed to setup an ARM build-bot for this.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>@Eric, Dimitri: Would it be possible for you to extend your x86 libcxx<o:p></o:p></p><p class=MsoNormal>build-bots to include a no-exception build as well?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Initially, these bots will be build-only. Once I get the tests updated (below),<o:p></o:p></p><p class=MsoNormal>we can enable the test runs too.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>[Phase-2: Fix the tests, update build-bots to run them]<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Currently quite a few tests fail on the no-exceptions libcxx variant build as<o:p></o:p></p><p class=MsoNormal>above. It appears that most of the tests assume that libcxx is built with<o:p></o:p></p><p class=MsoNormal>exceptions enabled. We'll have to update the tests so that they are aware of<o:p></o:p></p><p class=MsoNormal>the no-exceptions build as well. I have a work-in-progress patch for this, I<o:p></o:p></p><p class=MsoNormal>will put it up for review separately once I'm done with it.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Note that it's not just the tests that need to be updated. For example, take<o:p></o:p></p><p class=MsoNormal>unordered_map::at(key) definition:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc><o:p></o:p></p><p class=MsoNormal>_Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k)<o:p></o:p></p><p class=MsoNormal>{<o:p></o:p></p><p class=MsoNormal> iterator __i = find(__k);<o:p></o:p></p><p class=MsoNormal>#ifndef _LIBCPP_NO_EXCEPTIONS<o:p></o:p></p><p class=MsoNormal> if (__i == end())<o:p></o:p></p><p class=MsoNormal> throw out_of_range("unordered_map::at: key not found");<o:p></o:p></p><p class=MsoNormal>#endif<o:p></o:p></p><p class=MsoNormal> return __i->second;<o:p></o:p></p><p class=MsoNormal>}<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Here the behavior is not correct w.r.t no-exceptions use case, __i == end()<o:p></o:p></p><p class=MsoNormal>should instead call abort(). My local patch includes updates to tests as well<o:p></o:p></p><p class=MsoNormal>as fixes for omissions like this one.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Once this (quite large) patch gets reviewed+committed, we can enable the testing<o:p></o:p></p><p class=MsoNormal>stages of the bots, so that we don't regress the no-exceptions behavior.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>[Phase-3: Add more tests]<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>There are quite a few other places in the source which follow the pattern:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>#ifndef _LIBCPP_NO_EXCEPTIONS<o:p></o:p></p><p class=MsoNormal> if (check_some_bad_stat())<o:p></o:p></p><p class=MsoNormal> throw some_exception()<o:p></o:p></p><p class=MsoNormal>#endif<o:p></o:p></p><p class=MsoNormal> // continues like nothing happened<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I don't think all of those cases are exposed in the current tests, we need to<o:p></o:p></p><p class=MsoNormal>weed-out these cases and add more tests.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Does that sound like an OK plan? What do others think about supporting the<o:p></o:p></p><p class=MsoNormal>no-exceptions libcxx variety long-term? Please let me know.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Many thanks.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>- Asiri<o:p></o:p></p></div></body></html>