This is an archive of the discontinued LLVM Phabricator instance.

[libc++][Modules] locale fails to compile with clang modules when _LIBCPP_LOCALE__L_EXTENSIONS is undefined
ClosedPublic

Authored by iana on Aug 23 2023, 1:52 PM.

Details

Summary

When __locale_dir/locale_base_api/locale_guard.h is compiled independently, as it is when it's in its own clang module, it fails to compile due to locale_t being undefined. It needs to include __locale to get that, instead of just clocale.

Diff Detail

Event Timeline

iana created this revision.Aug 23 2023, 1:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2023, 1:53 PM
Herald added a subscriber: ributzka. · View Herald Transcript
iana requested review of this revision.Aug 23 2023, 1:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2023, 1:53 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
iana edited the summary of this revision. (Show Details)Aug 23 2023, 1:53 PM

It looks like we don't have unit tests/CI for undef(_LIBCPP_HAS_NO_LOCALIZATION) + undef(_LIBCPP_LOCALE__L_EXTENSIONS). If anyone knows how to set that up please let me know!

ldionne added inline comments.Aug 24 2023, 11:03 AM
libcxx/include/__locale_dir/locale_base_api/locale_guard.h
12–14

We still need <clocale> because we are using setlocale(...) and friends. But we should indeed add <__locale> because that is what defines locale_t when libcxx/include/__support/xlocale/__nop_locale_mgmt.h is used.

iana updated this revision to Diff 553200.Aug 24 2023, 11:04 AM

Put the clocale include back

libcxx/include/__locale_dir/locale_base_api/locale_guard.h
12–14

👍 put <clocale> back

iana marked an inline comment as done.Aug 24 2023, 11:05 AM
iana updated this revision to Diff 553202.Aug 24 2023, 11:06 AM

Add a comment why we're including __locale because it's not obvious

iana added inline comments.Aug 24 2023, 11:07 AM
libcxx/include/__locale_dir/locale_base_api/locale_guard.h
12–14

and added the comment

ldionne accepted this revision.Aug 24 2023, 11:16 AM

This LGTM.

This revision is now accepted and ready to land.Aug 24 2023, 11:16 AM