This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Stop using strict availability markup on Apple
AbandonedPublic

Authored by ldionne on Aug 18 2023, 7:48 AM.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

We've been increasingly running into issues with availability markup
in the library lately. In particular, the fact that strict availability
markup causes functions to act as-if they were deleted breaks the library
in various ways, making it impossible AFAICT to enable availability markup
for PMR. It also causes a lot of spurious diagnostics in e.g. <format>,
as can be seen by the multiple TODO comments removed in this patch.

This patch uses non-strict availability markup instead, which is used
much more widely on Apple platforms. The difference is that using an
unavailable API will trigger a warning instead of an error, and that
using an unavailable API will cause a weak-definition to be emitted
(so it is possible to check at runtime whether the API is available).

This should resolve several difficulties we've been having with availability
markup, which I believe to have tracked down to fundamental implementation
constraints with the strict version of availability. In other words,
strict has some properties which are fundamentally undesirable for us,
and it was always possible to work around them but it isn't anymore.

This will also make it possible for users to branch on whether an API
is available at runtime, which has been requested by users.

As a follow-up to this patch, I should be able to clean up even more
availability workarounds in the library.

rdar://100138498

Diff Detail

Unit TestsFailed

Event Timeline

ldionne created this revision.Aug 18 2023, 7:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2023, 7:48 AM
Herald added a subscriber: arphaman. · View Herald Transcript
ldionne requested review of this revision.Aug 18 2023, 7:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2023, 7:48 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne planned changes to this revision.Aug 18 2023, 7:49 AM

Note that this is still experimental. I want to run this through CI and I still want to have a few discussions before my mind is set that this is the right solution.

I'm not familiar enough with the Apple's availability markup to give a proper review. However I really like that this patch fixes the availability issues for format. Thanks for working on this.

libcxx/test/libcxx/diagnostics/format.nodiscard_extensions.compile.pass.cpp
13

I like this change :-)

ldionne abandoned this revision.Sep 19 2023, 11:39 AM

[Github PR transition cleanup]

I'm going to abandon this here and reopen on Github when I'm ready to push for this again.