[libcxx-commits] [libcxx] [libc++] Fix the locale base API on Linux with musl (PR #128936)

via libcxx-commits libcxx-commits at lists.llvm.org
Wed Feb 26 14:15:17 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Brian Cain (androm3da)

<details>
<summary>Changes</summary>

Since `363bfd6090b0 ([libc++] Use the new locale base API on Linux (#<!-- -->128007), 2025-02-24)`, musl targets will fail to build with errors like the below:

    In file included from /[b/f/w/src/git/out/stage2/include/c++/v1/__locale:14](https://cs.corp.google.com/piper///depot/google3/b/f/w/src/git/out/stage2/include/c%2B%2B/v1/__locale?l=14):
    In file included from /[b/f/w/src/git/out/stage2/include/c++/v1/__locale_dir/locale_base_api.h:123](https://cs.corp.google.com/piper///depot/google3/b/f/w/src/git/out/stage2/include/c%2B%2B/v1/__locale_dir/locale_base_api.h?l=123):
    /[b/f/w/src/git/out/stage2/include/c++/v1/__locale_dir/support/linux.h:98](https://cs.corp.google.com/piper///depot/google3/b/f/w/src/git/out/stage2/include/c%2B%2B/v1/__locale_dir/support/linux.h?l=98):12: error: no member named 'strtoll_l' in the global namespace
       98 |   return ::strtoll_l(__nptr, __endptr, __base, __loc);
          |          ~~^
    /[b/f/w/src/git/out/stage2/include/c++/v1/__locale_dir/support/linux.h:103](https://cs.corp.google.com/piper///depot/google3/b/f/w/src/git/out/stage2/include/c%2B%2B/v1/__locale_dir/support/linux.h?l=103):10: error: no member named 'strtoull_l' in the global namespace; did you mean '__strtoull'?
      103 |   return ::strtoull_l(__nptr, __endptr, __base, __loc);
          |          ^~~~~~~~~~~~
          |          __strtoull
    /[b/f/w/src/git/out/stage2/include/c++/v1/__locale_dir/support/linux.h:102](https://cs.corp.google.com/piper///depot/google3/b/f/w/src/git/out/stage2/include/c%2B%2B/v1/__locale_dir/support/linux.h?l=102):1: note: '__strtoull' declared here
      102 | __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) {
          | ^
    2 errors generated.

---
Full diff: https://github.com/llvm/llvm-project/pull/128936.diff


1 Files Affected:

- (modified) libcxx/include/__locale_dir/support/linux.h (+8) 


``````````diff
diff --git a/libcxx/include/__locale_dir/support/linux.h b/libcxx/include/__locale_dir/support/linux.h
index f1662c0112603..00c99eb5ea351 100644
--- a/libcxx/include/__locale_dir/support/linux.h
+++ b/libcxx/include/__locale_dir/support/linux.h
@@ -95,12 +95,20 @@ inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __
 }
 
 inline _LIBCPP_HIDE_FROM_ABI long long __strtoll(const char* __nptr, char** __endptr, int __base, __locale_t __loc) {
+#if !defined(_LIBCPP_HAS_MUSL_LIBC)
   return ::strtoll_l(__nptr, __endptr, __base, __loc);
+#else
+  return ::strtoll(__nptr, __endptr, __base);
+#endif
 }
 
 inline _LIBCPP_HIDE_FROM_ABI unsigned long long
 __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) {
+#if !defined(_LIBCPP_HAS_MUSL_LIBC)
   return ::strtoull_l(__nptr, __endptr, __base, __loc);
+#else
+  return ::strtoull(__nptr, __endptr, __base);
+#endif
 }
 
 //

``````````

</details>


https://github.com/llvm/llvm-project/pull/128936


More information about the libcxx-commits mailing list