From f19456c4821c0801d4379a975000e7d2eeb2754f Mon Sep 17 00:00:00 2001 From: Pedro Henrique Penna Date: Mon, 29 Jun 2026 19:29:36 -0700 Subject: [PATCH] [nanvix] fix(libcxx): add Nanvix platform support (clock + rune table) Stage-1 build of libc++ failed with two platform-detection errors: chrono.cpp: error: "Monotonic clock not implemented on this platform" __locale: error: unknown rune table for this platform -- do you mean to define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE? Both are because libc++ does not recognize Nanvix. Add it: - chrono.cpp: Nanvix provides clock_gettime() and CLOCK_MONOTONIC (declared in , defined in libc.a), so add __nanvix__ to the targets that define _LIBCPP_HAS_CLOCK_GETTIME (alongside OpenBSD/hurd); steady_clock then uses clock_gettime(CLOCK_MONOTONIC). The libc's does not advertise _POSIX_TIMERS, which is why the generic detection missed it. - __config + __cxx03/__config: Nanvix has no platform ctype "rune table", so use libc++'s built-in default table by adding __nanvix__ to the _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE list (as NuttX/Fuchsia/wasi do). The locale base API falls through to the BSD POSIX fallbacks, keeping localization (, , ) enabled. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- libcxx/include/__config | 2 +- libcxx/include/__cxx03/__config | 2 +- libcxx/src/chrono.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libcxx/include/__config b/libcxx/include/__config index 6db13aec2339a..6750f32609067 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -907,7 +907,7 @@ typedef __char32_t char32_t; # endif # if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \ - _LIBCPP_HAS_MUSL_LIBC || defined(__OpenBSD__) || defined(__LLVM_LIBC__) + _LIBCPP_HAS_MUSL_LIBC || defined(__OpenBSD__) || defined(__LLVM_LIBC__) || defined(__nanvix__) # define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE # endif diff --git a/libcxx/include/__cxx03/__config b/libcxx/include/__cxx03/__config index 0172f76cef912..8c1f25a5ffdb9 100644 --- a/libcxx/include/__cxx03/__config +++ b/libcxx/include/__cxx03/__config @@ -792,7 +792,7 @@ typedef __char32_t char32_t; # endif # if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \ - defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__) + defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__) || defined(__nanvix__) # define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE # endif diff --git a/libcxx/src/chrono.cpp b/libcxx/src/chrono.cpp index 20387ea76124b..4174c53e2bf6f 100644 --- a/libcxx/src/chrono.cpp +++ b/libcxx/src/chrono.cpp @@ -38,7 +38,7 @@ // OpenBSD and GPU do not have a fully conformant suite of POSIX timers, but // it does have clock_gettime and CLOCK_MONOTONIC which is all we need. #if defined(__APPLE__) || defined(__gnu_hurd__) || defined(__OpenBSD__) || defined(__AMDGPU__) || \ - defined(__NVPTX__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) + defined(__NVPTX__) || defined(__nanvix__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) # define _LIBCPP_HAS_CLOCK_GETTIME #endif