Skip to content

Commit 46b4986

Browse files
committed
Fix compat between libc++ and emscripten's xlocale.h
libc++ was assuming that musl doesn't have `xlocale.h` which is true, but emscripten adds xlocale.h for compatibility (I'm not sure we really need to, but we do). Fixes: #23413
1 parent d0df369 commit 46b4986

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

system/lib/libcxx/include/__locale_dir/locale_base_api.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
#ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H
1010
#define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H
1111

12-
#if defined(_LIBCPP_MSVCRT_LIKE)
12+
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__)
13+
# include <xlocale.h>
14+
#elif defined(_LIBCPP_MSVCRT_LIKE)
1315
# include <__locale_dir/locale_base_api/win32.h>
1416
#elif defined(_AIX) || defined(__MVS__)
1517
# include <__locale_dir/locale_base_api/ibm.h>
@@ -25,8 +27,6 @@
2527
# include <__locale_dir/locale_base_api/fuchsia.h>
2628
#elif defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC)
2729
# include <__locale_dir/locale_base_api/musl.h>
28-
#elif defined(__APPLE__) || defined(__FreeBSD__)
29-
# include <xlocale.h>
3030
#endif
3131

3232
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

test/other/test_xlocale.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#ifdef __cplusplus
2+
// Test compatality with libc++'s locale header
3+
#include <locale>
4+
#endif
5+
16
#include <xlocale.h>
27
#include <stdio.h>
38

test/test_other.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14279,6 +14279,7 @@ def test_prejs_unicode(self):
1427914279
def test_xlocale(self):
1428014280
# Test for xlocale.h compatibility header
1428114281
self.do_other_test('test_xlocale.c')
14282+
self.do_other_test('test_xlocale.c', emcc_args=['-x', 'c++'])
1428214283

1428314284
def test_print_map(self):
1428414285
self.run_process([EMCC, '-c', test_file('hello_world.c')])

0 commit comments

Comments
 (0)