-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libcxx] adds opt out mechanism for using __wrap_iter for array and s… #84226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…tring_view `__config` was unconditionally opting users into this change, and to opt out required either a manual edit of the header, or getting users to manually define each unstable ABI macro they want to support. This patch strikes a middle-ground by adding an opt-out mechanism.
@llvm/pr-subscribers-libcxx Author: Christopher Di Bella (cjdb) Changes…tring_view
Full diff: https://github.com/llvm/llvm-project/pull/84226.diff 2 Files Affected:
diff --git a/libcxx/docs/ReleaseNotes/19.rst b/libcxx/docs/ReleaseNotes/19.rst
index 04f16610f8117e..955cadaa914439 100644
--- a/libcxx/docs/ReleaseNotes/19.rst
+++ b/libcxx/docs/ReleaseNotes/19.rst
@@ -49,6 +49,9 @@ Improvements and New Features
-----------------------------
- The performance of growing ``std::vector`` has been improved for trivially relocatable types.
+- ``std::array`` and ``std::string_view`` are no longer pointers in the unstable ABI by default, and
+ can be reverted to raw pointers by defining the macros ``_LIBCPP_ABI_NO_USE_WRAP_ITER_IN_STD_ARRAY``
+ and ``_LIBCPP_ABI_NO_USE_WRAP_ITER_IN_STD_STRING_VIEW``.
Deprecations and Removals
-------------------------
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 3a438e85a7b819..70f15cce54a309 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -178,8 +178,14 @@
// pointers, which prevents people from relying on a non-portable implementation
// detail. This is especially useful because enabling bounded iterators hardening
// requires code not to make these assumptions.
-# define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY
-# define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW
+
+# if !defined(_LIBCPP_ABI_NO_USE_WRAP_ITER_IN_STD_ARRAY)
+# define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY
+# endif
+
+# if !defined(_LIBCPP_ABI_NO_USE_WRAP_ITER_IN_STD_STRING_VIEW)
+# define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW
+# endif
# elif _LIBCPP_ABI_VERSION == 1
# if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF))
// Enable compiling copies of now inline methods into the dylib to support
|
It wasn't my impression that anybody was requesting a different mechanism though, so I'd rather not introduce this additional complexity. After all, the requirement of being able to tweak this value without a "vendor" modifying the headers seems arbitrary to me, at that point it's just as good as setting something in the |
Some vendors have a "no custom patches" policy, meaning that they're unable to adjust this without opting into everything manually, which has problems of its own. It's a relatively small maintenance cost for us to make these opt-out, but a potentially large maintenance cost to ask vendors to constantly monitor what's added to the unstable ABI. I can make it less arbitrary by adding opt-outs for everything, which was going to be my next patch. We could alternatively start it as a Discourse discussion and then move to GitHub if there's consensus. A good analogy is Clang's warning policy: most are opt-in by default, and all are opt-out with |
This is an arbitrary policy, though. I totally get the desire to minimize custom patches, but eradicating them entirely is not realistic unless that vendor pushes a lot of its complexities upstream. I'm saying this irrespective of the specific issue we have right here.
If a vendor finds the need to constantly monitor what's added to the unstable ABI, it means they simply shouldn't be opting into the unstable ABI wholesale by setting
For the reason stated above, I don't think it makes sense to do that. |
It seems I misread this as |
It is possible to set arbitrary ABI defines via Those end up in the So the canonical way of cherry-picking ABI flags to enable via e.g. a CMake cache is to set |
That's very clear, thank you for breaking it down! |
…tring_view
__config
was unconditionally opting users into this change, and to opt out required either a manual edit of the header, or getting users to manually define each unstable ABI macro they want to support. This patch strikes a middle-ground by adding an opt-out mechanism.