[PATCH] D28383: build: add a heuristic to determine the C++ ABI

Saleem Abdulrasool via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 5 15:21:52 PST 2017


compnerd created this revision.
compnerd added reviewers: EricWF, mclow.lists, smeenai, kastiglione.
compnerd added subscribers: cfe-commits, rnk.
compnerd set the repository for this revision to rL LLVM.
Herald added a subscriber: mgorny.

We need to have a more principled method to detect the C++ ABI we are
targeting.  Add a heuristic to determine that and pass it to the build.


Repository:
  rL LLVM

https://reviews.llvm.org/D28383

Files:
  CMakeLists.txt
  include/__config
  include/__config_site.in


Index: include/__config_site.in
===================================================================
--- include/__config_site.in
+++ include/__config_site.in
@@ -22,5 +22,6 @@
 #cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD
 #cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL
 #cmakedefine _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
+#cmakedefine _LIBCPP_USES_MS_ABI
 
 #endif // _LIBCPP_CONFIG_SITE
Index: include/__config
===================================================================
--- include/__config
+++ include/__config
@@ -33,6 +33,12 @@
 #define _LIBCPP_ABI_VERSION 1
 #endif
 
+#if defined(_LIBCPP_USES_MS_ABI)
+#define _LIBCPP_ABI_MS
+#else
+#define _LIBCPP_ABI_IA
+#endif
+
 #if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
 // Change short string representation so that string data starts at offset 0,
 // improving its alignment in some cases.
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -522,6 +522,17 @@
 config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL)
 config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
 
+# Indicate the ABI that we are targeting.  If the c++abi library is none and we
+# are building for windows, assume that we want the Microsoft C++ ABI.  Note
+# that MinGW uses the itanium ABI and still reports as WIN32 under CMake.  If we
+# are targeting the itanium ABI, then we must have one of the itanium ABI
+# support libraries (libc++abi, libsupc++, or libcxxrt).  Windows itanium and
+# MinGW both will use one of those to provide the support routines which
+# differentiates it from MS ABI.
+if(WIN32 AND NOT MINGW AND "${LIBCXX_CXX_ABI}" STREQUAL "none")
+  config_define_if(TRUE _LIBCPP_USES_MS_ABI)
+endif()
+
 # By default libc++ on Windows expects to use a shared library, which requires
 # the headers to use DLL import/export semantics. However when building a
 # static library only we modify the headers to disable DLL import/export.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28383.83314.patch
Type: text/x-patch
Size: 2015 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170105/95619c8a/attachment-0001.bin>


More information about the cfe-commits mailing list