<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 4, 2017 at 5:44 PM, Shoaib Meenai via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: smeenai<br>
Date: Wed Oct  4 16:44:38 2017<br>
New Revision: 314949<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=314949&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>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="http://config_site.in" rel="noreferrer" target="_blank">config_<wbr>site.in</a><br>
<br>
Modified: libcxx/trunk/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=314949&r1=314948&r2=314949&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/<wbr>CMakeLists.txt?rev=314949&r1=<wbr>314948&r2=314949&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<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_<wbr>INSTALL_EX<br>
         "LIBCXX_ENABLE_EXPERIMENTAL_<wbr>LIBRARY;LIBCXX_INSTALL_<wbr>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.")<br></blockquote><div><br></div><div>Shouldn't these specify a default option?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 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>
 #=============================<wbr>==============================<wbr>====================<br>
 # Configure System<br>
 #=============================<wbr>==============================<wbr>====================<br>
@@ -594,6 +600,8 @@ if (NOT LIBCXX_ABI_VERSION EQUAL "1")<br>
   config_define(${LIBCXX_ABI_<wbr>VERSION} _LIBCPP_ABI_VERSION)<br>
 endif()<br>
 config_define_if(LIBCXX_ABI_<wbr>UNSTABLE _LIBCPP_ABI_UNSTABLE)<br>
+config_define_if(LIBCXX_ABI_<wbr>ITANIUM _LIBCPP_ABI_ITANIUM)<br>
+config_define_if(LIBCXX_ABI_<wbr>MICROSOFT _LIBCPP_ABI_MICROSOFT)<br>
<br></blockquote><div>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</div><div>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</div><div>Linux or Windows.</div><div><br></div><div>However, like you said, the attempt of this is to override the automatic detection done in the headers. Maybe the name</div><div>should reflect that (Ex. _LIBCPP_ABI_ITANIUM_OVERRIDE)? And then the autodetection can operate by checking for an override first?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 config_define_if_not(LIBCXX_<wbr>ENABLE_GLOBAL_FILESYSTEM_<wbr>NAMESPACE _LIBCPP_HAS_NO_GLOBAL_<wbr>FILESYSTEM_NAMESPACE)<br>
 config_define_if_not(LIBCXX_<wbr>ENABLE_STDIN _LIBCPP_HAS_NO_STDIN)<br>
<br>
Modified: libcxx/trunk/include/__config<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=314949&r1=314948&r2=314949&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/include/_<wbr>_config?rev=314949&r1=314948&<wbr>r2=314949&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<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_<wbr>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="http://config_site.in" rel="noreferrer" target="_blank">config_<wbr>site.in</a><br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config_site.in?rev=314949&r1=314948&r2=314949&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/include/_<wbr>_config_site.in?rev=314949&r1=<wbr>314948&r2=314949&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/include/__<a href="http://config_site.in" rel="noreferrer" target="_blank">config_<wbr>site.in</a> (original)<br>
+++ libcxx/trunk/include/__<a href="http://config_site.in" rel="noreferrer" target="_blank">config_<wbr>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_<wbr>FILESYSTEM_NAMESPACE<br>
 #cmakedefine _LIBCPP_HAS_NO_STDIN<br>
 #cmakedefine _LIBCPP_HAS_NO_STDOUT<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>