This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Remove use of internal glibc macros to determine if c8rtomb() and mbrtoc8() are present
ClosedPublic

Authored by tahonermann on Jan 25 2023, 3:17 PM.

Details

Reviewers
ldionne
Mordante
Group Reviewers
Restricted Project
Summary

When support for declaring the c8rtomb() and mbrtoc8() functions within the std namespace was added in commit 7e7013c5d4b1b3996c8dba668c5a94bb33b2999b, internal glibc macros were used to determine if C2X extensions are enabled. Specifically, a check for whether __GLIBC_USE is defined and whether __GLIBC_USE(ISOC2X) is non-0 was added. __GLIBC_USE is an internal detail of the glibc implementation that may be changed or removed in the future potentially leading to inconsistency or compilation failures. This change removes the use of the internal glibc macro to avoid such problems. Unfortunately, without another mechanism to determine if C2X extensions are enabled, this removal will result in inconsistent declarations of the c8rtomb() and mbrtoc8() functions; when C++ char8_t support is not enabled, but C2X extensions are, these functions will be declared in the global namespace but not in the std namespace. This situation will improve when C23 support is finalized and the check can be re-implemented using __STDC_VERSION__.

Diff Detail

Event Timeline

tahonermann created this revision.Jan 25 2023, 3:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 25 2023, 3:17 PM
tahonermann requested review of this revision.Jan 25 2023, 3:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 25 2023, 3:17 PM
Herald added 1 blocking reviewer(s): Restricted Project. · View Herald Transcript
ldionne accepted this revision.Jan 26 2023, 2:17 PM

TBH this seems reasonable to me. If this seems reasonable to you, I'll go with your judgement here.

libcxx/include/__config
1223

Nitpick, but when you upload your patches, please consider using arc diff so that context is available in the diffs!

This revision is now accepted and ready to land.Jan 26 2023, 2:17 PM

Thanks @ldionne, I'm heading out of town for the weekend, so I'll wait to push this until Monday.

I meant to get this in before the Clang 16 branch, but life and stuff. I'll file an issue to cherry-pick the change for the release branch once committed. Please let me know if you have any thoughts on that.

libcxx/include/__config
1223

Oops, I forgot the -U99999 option when generating the diff.

Thanks @ldionne, I'm heading out of town for the weekend, so I'll wait to push this until Monday.

I meant to get this in before the Clang 16 branch, but life and stuff. I'll file an issue to cherry-pick the change for the release branch once committed. Please let me know if you have any thoughts on that.

That sounds fine. The release manager should reach out to me and I'll let them know it's good to go.

Rebase and test update to ignore any declarations present in the global namespace when char8_t support is not enabled.

CI failures are due to test time outs in unrelated tests.

Assuming no new concerns about the added changes to update a test, I'll commit this later today.

tahonermann closed this revision.Feb 2 2023, 10:35 AM

Sigh, I forgot to tag the commit with a link to this differential review. Closing manually.

https://github.com/llvm/llvm-project/issues/60517 has been filed to backport this change for the LLVM 16 release.