[PATCH] D36719: [libc++] Add site config option for ABI macros

Shoaib Meenai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 14 16:04:42 PDT 2017

smeenai created this revision.
Herald added a subscriber: mgorny.

Some ABI macros affect headers, so it's nice to have a site config
option for them. Add a LIBCXX_ABI_DEFINES cmake macro to allow
specifying a list of ABI macros to define in the site config.

The primary design constraint (as discussed with Eric on IRC a while
back) was to not have to repeat the ABI macro names in cmake, which only
leaves a free-form cmake list as an option. A somewhat unfortunate
consequence is that we can't verify that the ABI macros being defined
actually exist, though we can at least perform some basic sanity
checking, since all the ABI macros begin with _LIBCPP_ABI_.



Index: utils/libcxx/test/config.py
--- utils/libcxx/test/config.py
+++ utils/libcxx/test/config.py
@@ -658,7 +658,7 @@
                     % feature_macros[m])
-            assert m.startswith('_LIBCPP_HAS_') or m == '_LIBCPP_ABI_UNSTABLE'
+            assert m.startswith('_LIBCPP_HAS_') or m.startswith('_LIBCPP_ABI_')
             m = m.lower()[1:].replace('_', '-')
         return feature_macros
Index: include/__config_site.in
--- include/__config_site.in
+++ include/__config_site.in
@@ -24,4 +24,6 @@
Index: CMakeLists.txt
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -607,6 +607,18 @@
+  set(abi_defines)
+  foreach (abi_define ${LIBCXX_ABI_DEFINES})
+    if (NOT abi_define MATCHES "^_LIBCPP_ABI_")
+      message(SEND_ERROR "Invalid ABI macro ${abi_define} in LIBCXX_ABI_DEFINES")
+    endif()
+    list(APPEND abi_defines "#define ${abi_define}")
+  endforeach()
+  string(REPLACE ";" "\n" abi_defines "${abi_defines}")
+  config_define(${abi_defines} _LIBCPP_ABI_DEFINES)
 # 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: D36719.111090.patch
Type: text/x-patch
Size: 1923 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170814/d9762b01/attachment.bin>

More information about the cfe-commits mailing list