Skip to content

Fix compat between libc++ and emscripten's xlocale.h #23414

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

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions system/lib/libcxx/include/__locale_dir/locale_base_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H
#define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H

#if defined(_LIBCPP_MSVCRT_LIKE)
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__)
# include <xlocale.h>
#elif defined(_LIBCPP_MSVCRT_LIKE)
# include <__locale_dir/locale_base_api/win32.h>
#elif defined(_AIX) || defined(__MVS__)
# include <__locale_dir/locale_base_api/ibm.h>
Expand All @@ -25,8 +27,6 @@
# include <__locale_dir/locale_base_api/fuchsia.h>
#elif defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC)
# include <__locale_dir/locale_base_api/musl.h>
#elif defined(__APPLE__) || defined(__FreeBSD__)
# include <xlocale.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would adding emscripten here be less of a diff, so less churn in the next libc++ update? Or must the change be on top?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not possible because we would already have hit the _LIBCPP_HAS_MUSL_LIBC case above. Our case needs to come first.

#endif

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Expand Down
5 changes: 5 additions & 0 deletions test/other/test_xlocale.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#ifdef __cplusplus
// Test compatibility with libc++'s locale header
#include <locale>
#endif

#include <xlocale.h>
#include <stdio.h>

Expand Down
1 change: 1 addition & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -14279,6 +14279,7 @@ def test_prejs_unicode(self):
def test_xlocale(self):
# Test for xlocale.h compatibility header
self.do_other_test('test_xlocale.c')
self.do_other_test('test_xlocale.c', emcc_args=['-x', 'c++'])

def test_print_map(self):
self.run_process([EMCC, '-c', test_file('hello_world.c')])
Expand Down
Loading