<html 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=utf-8">
<meta name="Title" content="">
<meta name="Keywords" content="">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@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:0in;
        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-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.msoIns
        {mso-style-type:export-only;
        mso-style-name:"";
        text-decoration:underline;
        color:teal;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Eric and I discussed this further on IRC, and r314965 implements his suggestions.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:12.0pt;color:black">From: </span></b><span style="font-size:12.0pt;color:black">Eric Fiselier <eric@efcs.ca><br>
<b>Date: </b>Wednesday, October 4, 2017 at 6:11 PM<br>
<b>To: </b>Shoaib Meenai <smeenai@fb.com><br>
<b>Cc: </b>cfe-commits <cfe-commits@lists.llvm.org><br>
<b>Subject: </b>Re: [libcxx] r314949 - [libc++] Allow users to explicitly specify ABI<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Wed, Oct 4, 2017 at 5:44 PM, Shoaib Meenai via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Author: smeenai<br>
Date: Wed Oct  4 16:44:38 2017<br>
New Revision: 314949<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D314949-26view-3Drev&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=FfTS_aoYUPTcrKzdSBjzDilbxxSRUA__6T0fQtUoDw4&s=cckMmTlQdJTp0e-PZSnITzPCbwRVbumfloKSl3KQOGM&e=" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=314949&view=rev</a><br>
Log:<br>
[libc++] Allow users to explicitly specify ABI<br>
<br>
libc++'s current heuristic for detecting Itanium vs. Microsoft ABI falls<br>
short in some cases. For example, it will detect windows-itanium targets<br>
as using the Microsoft ABI, since they set `_MSC_VER` (for compatibility<br>
with Microsoft headers). Leave the current heuristic in place by default<br>
but also allow users to explicitly specify the ABI if need be.<br>
<br>
Modified:<br>
    libcxx/trunk/CMakeLists.txt<br>
    libcxx/trunk/include/__config<br>
    libcxx/trunk/include/__<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__config-5Fsite.in&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=FfTS_aoYUPTcrKzdSBjzDilbxxSRUA__6T0fQtUoDw4&s=DFPNV_9W5sjp5dUlpv6oF__hPknbPHkZ22xnaZhWOfQ&e=" target="_blank">config_site.in</a><br>
<br>
Modified: libcxx/trunk/CMakeLists.txt<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_libcxx_trunk_CMakeLists.txt-3Frev-3D314949-26r1-3D314948-26r2-3D314949-26view-3Ddiff&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=FfTS_aoYUPTcrKzdSBjzDilbxxSRUA__6T0fQtUoDw4&s=LJoAA9_RLFbfZHWQ0omY5NNRseSbizGWiRSUeJPtuSY&e=" target="_blank">
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=314949&r1=314948&r2=314949&view=diff</a><br>
==============================================================================<br>
--- libcxx/trunk/CMakeLists.txt (original)<br>
+++ libcxx/trunk/CMakeLists.txt Wed Oct  4 16:44:38 2017<br>
@@ -99,6 +99,8 @@ cmake_dependent_option(LIBCXX_INSTALL_EX<br>
         "LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF)<br>
 set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")<br>
 option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)<br>
+option(LIBCXX_ABI_ITANIUM "Ignore auto-detection and force use of the Itanium ABI.")<br>
+option(LIBCXX_ABI_MICROSOFT "Ignore auto-detection and force use of the Microsoft ABI.")<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Shouldn't these specify a default option?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"> option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)<br>
<br>
 if (NOT LIBCXX_ENABLE_SHARED AND NOT LIBCXX_ENABLE_STATIC)<br>
@@ -337,6 +339,10 @@ if (LIBCXX_HAS_MUSL_LIBC AND NOT LIBCXX_<br>
                       "when building for Musl with LIBCXX_HAS_MUSL_LIBC.")<br>
 endif()<br>
<br>
+if (LIBCXX_ABI_ITANIUM AND LIBCXX_ABI_MICROSOFT)<br>
+  message(FATAL_ERROR "Only one of LIBCXX_ABI_ITANIUM and LIBCXX_ABI_MICROSOFT can be specified.")<br>
+endif ()<br>
+<br>
 #===============================================================================<br>
 # Configure System<br>
 #===============================================================================<br>
@@ -594,6 +600,8 @@ if (NOT LIBCXX_ABI_VERSION EQUAL "1")<br>
   config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION)<br>
 endif()<br>
 config_define_if(LIBCXX_ABI_UNSTABLE _LIBCPP_ABI_UNSTABLE)<br>
+config_define_if(LIBCXX_ABI_ITANIUM _LIBCPP_ABI_ITANIUM)<br>
+config_define_if(LIBCXX_ABI_MICROSOFT _LIBCPP_ABI_MICROSOFT)<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal">I'm not a fan of the direction this is going in. It seems to require the generation and use of a __config_site header<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">in all cases where it's used. I don't think we want to require that in the common case where you're using Itanium on<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Linux or Windows.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">However, like you said, the attempt of this is to override the automatic detection done in the headers. Maybe the name<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">should reflect that (Ex. _LIBCPP_ABI_ITANIUM_OVERRIDE)? And then the autodetection can operate by checking for an override first?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"> config_define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE)<br>
 config_define_if_not(LIBCXX_ENABLE_STDIN _LIBCPP_HAS_NO_STDIN)<br>
<br>
Modified: libcxx/trunk/include/__config<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_libcxx_trunk_include_-5F-5Fconfig-3Frev-3D314949-26r1-3D314948-26r2-3D314949-26view-3Ddiff&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=FfTS_aoYUPTcrKzdSBjzDilbxxSRUA__6T0fQtUoDw4&s=tvy2iLdreg0H7Q_MnfrAK_3incAXulpdzljgAwQKG-w&e=" target="_blank">
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=314949&r1=314948&r2=314949&view=diff</a><br>
==============================================================================<br>
--- libcxx/trunk/include/__config (original)<br>
+++ libcxx/trunk/include/__config Wed Oct  4 16:44:38 2017<br>
@@ -157,11 +157,15 @@<br>
<br>
 // FIXME: ABI detection should be done via compiler builtin macros. This<br>
 // is just a placeholder until Clang implements such macros. For now assume<br>
-// that Windows compilers pretending to be MSVC++ target the microsoft ABI.<br>
-#if defined(_WIN32) && defined(_MSC_VER)<br>
-# define _LIBCPP_ABI_MICROSOFT<br>
-#else<br>
-# define _LIBCPP_ABI_ITANIUM<br>
+// that Windows compilers pretending to be MSVC++ target the Microsoft ABI,<br>
+// and allow the user to explicitly specify the ABI to handle cases where this<br>
+// heuristic falls short.<br>
+#if !defined(_LIBCPP_ABI_ITANIUM) && !defined(_LIBCPP_ABI_MICROSOFT)<br>
+# if defined(_WIN32) && defined(_MSC_VER)<br>
+#  define _LIBCPP_ABI_MICROSOFT<br>
+# else<br>
+#  define _LIBCPP_ABI_ITANIUM<br>
+# endif<br>
 #endif<br>
<br>
 // Need to detect which libc we're using if we're on Linux.<br>
<br>
Modified: libcxx/trunk/include/__<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__config-5Fsite.in&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=FfTS_aoYUPTcrKzdSBjzDilbxxSRUA__6T0fQtUoDw4&s=DFPNV_9W5sjp5dUlpv6oF__hPknbPHkZ22xnaZhWOfQ&e=" target="_blank">config_site.in</a><br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_libcxx_trunk_include_-5F-5Fconfig-5Fsite.in-3Frev-3D314949-26r1-3D314948-26r2-3D314949-26view-3Ddiff&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=FfTS_aoYUPTcrKzdSBjzDilbxxSRUA__6T0fQtUoDw4&s=Rg-KKft-HF2-v-QJ1nWPRgmlFH_1lwORx4JGwgU6vXA&e=" target="_blank">
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config_site.in?rev=314949&r1=314948&r2=314949&view=diff</a><br>
==============================================================================<br>
--- libcxx/trunk/include/__<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__config-5Fsite.in&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=FfTS_aoYUPTcrKzdSBjzDilbxxSRUA__6T0fQtUoDw4&s=DFPNV_9W5sjp5dUlpv6oF__hPknbPHkZ22xnaZhWOfQ&e=" target="_blank">config_site.in</a>
 (original)<br>
+++ libcxx/trunk/include/__<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__config-5Fsite.in&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=FfTS_aoYUPTcrKzdSBjzDilbxxSRUA__6T0fQtUoDw4&s=DFPNV_9W5sjp5dUlpv6oF__hPknbPHkZ22xnaZhWOfQ&e=" target="_blank">config_site.in</a>
 Wed Oct  4 16:44:38 2017<br>
@@ -12,6 +12,8 @@<br>
<br>
 #cmakedefine _LIBCPP_ABI_VERSION @_LIBCPP_ABI_VERSION@<br>
 #cmakedefine _LIBCPP_ABI_UNSTABLE<br>
+#cmakedefine _LIBCPP_ABI_ITANIUM<br>
+#cmakedefine _LIBCPP_ABI_MICROSOFT<br>
 #cmakedefine _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE<br>
 #cmakedefine _LIBCPP_HAS_NO_STDIN<br>
 #cmakedefine _LIBCPP_HAS_NO_STDOUT<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Dcommits&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=FfTS_aoYUPTcrKzdSBjzDilbxxSRUA__6T0fQtUoDw4&s=dZkfFqYiz1I7piI6omswkTMBWfOVWN57_yumHBs6O3M&e=" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</body>
</html>