Skip to content

Commit 43b132e

Browse files
committed
fix(port): 判据是「哪个 C 库」,不是「哪个 C 库,在 Apple 上」
覆盖里原来写的是 `_LIBCPP_HAS_MUSL_LIBC && defined(__APPLE__)`,因为 Apple 是 第一个暴露它的目标。实测 2026-08-23 的第二个:x86_64-windows-gnu 在 openkal 上走 _LIBCPP_MSVCRT_LIKE → support/windows.h,停在 `_locale_t` —— 那是微软的 C 运行时, 而这个程序的 C 库是 musl。同一个形状,第二种目标格式。 ⇒ 把规则收窄到一个平台,就意味着每个平台再写一遍。upstream 问的是「底下是哪个 C 库」;这里回答它,于是每一个答案是 musl 的目标都到达同一个后端 —— 而在 ELF 上 那本来就是它到达的那个。
1 parent 7b5d6b9 commit 43b132e

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

port/include/__locale_dir/locale_base_api.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,19 @@
5252

5353
#include <__config>
5454

55-
#if _LIBCPP_HAS_LOCALIZATION && _LIBCPP_HAS_MUSL_LIBC && defined(__APPLE__)
56-
// The one case upstream's chain answers wrongly for this configuration. Every
57-
// other target — including musl on ELF, where `__linux__` is defined and the
58-
// chain already reaches the same header — falls through to upstream below.
55+
// ⭐ THE PREDICATE IS THE C LIBRARY, FULL STOP — NOT "the C library, on Apple".
56+
//
57+
// It was `&& defined(__APPLE__)` at first, because Apple was the target that
58+
// exposed it. Measured 2026-08-23 on the next one: `x86_64-windows-gnu` over
59+
// openkal takes `_LIBCPP_MSVCRT_LIKE` → `support/windows.h` and stops on
60+
// `_locale_t`, which is Microsoft's C runtime, for a program whose C library
61+
// is musl. Same shape, second object format.
62+
//
63+
// ⇒ Narrowing the rule to one platform would have meant writing it again per
64+
// platform. The question upstream asks is which C library is beneath; this
65+
// answers it, and every target where the answer is musl now reaches the same
66+
// backend — which on ELF is the one it already reached.
67+
#if _LIBCPP_HAS_LOCALIZATION && _LIBCPP_HAS_MUSL_LIBC
5968
# include <__locale_dir/support/linux.h>
6069
#else
6170
# include_next <__locale_dir/locale_base_api.h>

0 commit comments

Comments
 (0)