{"id":75,"date":"2016-08-28T23:03:04","date_gmt":"2016-08-28T15:03:04","guid":{"rendered":"http:\/\/blogs.gentoo.org\/gsoc2016-native-clang\/?p=75"},"modified":"2017-03-08T03:32:21","modified_gmt":"2017-03-07T19:32:21","slug":"libcabi-v-s-libcxxrt","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/gsoc2016-native-clang\/2016\/08\/28\/libcabi-v-s-libcxxrt\/","title":{"rendered":"libc++abi v.s. libcxxrt"},"content":{"rendered":"<p>If you&#8217;ve read my previous posts, you may already know that a C++ standard library needs something called an &#8220;ABI library&#8221; to do certain\u00a0low-level work for it. In the case of libc++, it supports libsupc++, libc++abi or libcxxrt as its ABI library. Among them, libsupc++ is not very well-known because\u00a0it&#8217;s a part of GCC and usually not shipped standalone. In this post, we&#8217;ll be concentrating on libc++abi and libcxxrt.<\/p>\n<p>libc++abi is the following effort by LLVM after it successfully developed a new C++ standard library \u2014 libc++. Developed by the same party, libc++abi works seamlessly with libc++. It&#8217;s now used on\u00a0Apple&#8217;s platforms.<\/p>\n<p>libcxxrt is developed by PathScale [1], a commercial compiler vendor, together\u00a0with the BSD communities. \u00a0It&#8217;s now used in the three BSD derivatives and proved to be of industry quality.<\/p>\n<p>While refactoring the ebuild for libc++, I hit a tough question: which ABI library to use as the default. libc++abi seems a more natural choice to me because it&#8217;s from the same bloodline as libc++. But libcxxrt should also be solid enough since\u00a0it&#8217;s used in those rock-steady BSDs without any problem. Out of curiosity, I decided to do a simple benchmark between the two rivals.<\/p>\n<p>I&#8217;m using a C++ program suggested by lu_zero for this benchmark [2]. I linked this program with libc++abi or libcxxrt (dynamically or statically), ran it three times and recorded the average runtime under each configuration. OpenMP is disabled for static linking because the OpenMP library used by clang is currently shared only on Gentoo. The test machine is a Gentoo VM with 4 cores and 4GB of memory. The parameter <code>SPP<\/code>\u00a0(in source code) is altered from its default to 100 to reduce runtime. Below are the benchmark figures:<\/p>\n<p>libc++abi, shared: 50.178s<br \/>\nlibcxxrt, shared: 54.558s<\/p>\n<p>libc++abi, static: 1m38.484s<br \/>\nlibcxxrt, static: 1m35.134s<\/p>\n<p>Apparently, libc++abi is slightly faster with dynamic linking, but a bit slower with static linking. Considering system fluctuation, the difference is nearly negligible. Due to its same bloodline as libc++, I&#8217;m going to keep libc++abi as the default ABI library in Gentoo \ud83d\ude42<\/p>\n<p>&nbsp;<\/p>\n<p>[1]\u00a0http:\/\/www.pathscale.com\/<br \/>\n[2]\u00a0https:\/\/github.com\/lighttransport\/nanort\/tree\/master\/examples\/path_tracer<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;ve read my previous posts, you may already know that a C++ standard library needs something called an &#8220;ABI library&#8221; to do certain\u00a0low-level work for it. In the case of libc++, it supports libsupc++, libc++abi or libcxxrt as its ABI library. Among them, libsupc++ is not very well-known because\u00a0it&#8217;s a part of GCC and &hellip; <a href=\"https:\/\/blogs.gentoo.org\/gsoc2016-native-clang\/2016\/08\/28\/libcabi-v-s-libcxxrt\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">libc++abi v.s. libcxxrt<\/span><\/a><\/p>\n","protected":false},"author":161,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/gsoc2016-native-clang\/wp-json\/wp\/v2\/posts\/75"}],"collection":[{"href":"https:\/\/blogs.gentoo.org\/gsoc2016-native-clang\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.gentoo.org\/gsoc2016-native-clang\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/gsoc2016-native-clang\/wp-json\/wp\/v2\/users\/161"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/gsoc2016-native-clang\/wp-json\/wp\/v2\/comments?post=75"}],"version-history":[{"count":1,"href":"https:\/\/blogs.gentoo.org\/gsoc2016-native-clang\/wp-json\/wp\/v2\/posts\/75\/revisions"}],"predecessor-version":[{"id":76,"href":"https:\/\/blogs.gentoo.org\/gsoc2016-native-clang\/wp-json\/wp\/v2\/posts\/75\/revisions\/76"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/gsoc2016-native-clang\/wp-json\/wp\/v2\/media?parent=75"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/gsoc2016-native-clang\/wp-json\/wp\/v2\/categories?post=75"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/gsoc2016-native-clang\/wp-json\/wp\/v2\/tags?post=75"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}