-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc++] Fix the locale base API on Linux with musl #128936
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
Conversation
✅ With the latest revision this PR passed the C/C++ code formatter. |
b8ab545
to
08a49e8
Compare
Since 363bfd6 ([libc++] Use the new locale base API on Linux (llvm#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.
08a49e8
to
2fbb3b0
Compare
@llvm/pr-subscribers-libcxx Author: Brian Cain (androm3da) ChangesSince
Full diff: https://github.com/llvm/llvm-project/pull/128936.diff 1 Files Affected:
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
}
//
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the fix and sorry for the slow reaction time.
Do you know if this means we can actually get rid of this code path in locale_base_api.h
?
# elif defined(__wasi__) || _LIBCPP_HAS_MUSL_LIBC
# include <__locale_dir/locale_base_api/musl.h>
This can be landed as soon as the CI is green. If someone lands this before I do, please edit the commit message to avoid butchering Thanks for the fix @androm3da |
Instead of `#if defined(_LIBCPP_HAS_MUSL_LIBC)`, we can rely on `#if _LIBCPP_HAS_MUSL_LIBC` directly. This should address these failures: # .---command stdout------------ # | /__w/llvm-project/llvm-project/build/frozen-cxx03-headers/libcxx/test-suite-install/include/c++/v1/__locale_dir/support/linux.h:98:6: error: '_LIBCPP_HAS_MUSL_LIBC' is always defined to 1 or 0. [libcpp-internal-ftms,-warnings-as-errors] # | 98 | #if !defined(_LIBCPP_HAS_MUSL_LIBC) # | | ^ # | /__w/llvm-project/llvm-project/build/frozen-cxx03-headers/libcxx/test-suite-install/include/c++/v1/__locale_dir/support/linux.h:108:6: error: '_LIBCPP_HAS_MUSL_LIBC' is always defined to 1 or 0. [libcpp-internal-ftms,-warnings-as-errors] # | 108 | #if !defined(_LIBCPP_HAS_MUSL_LIBC) # | | ^ # `-----------------------------
Note that this fix was actually proposed by @pirama-arumuga-nainar. Even though @pirama-arumuga-nainar is the author of the first commit in this PR I think GH will take my name as the author when it's merged. So I'll add a |
Will GH catenate the commit messages in the squash-and-merge? In which case I'm happy to edit it so that it reflects the original commit message in the first commit. Is that what you meant, or what butchering specifically should I try to avoid? |
This change shouldn't impact |
The separate definitions are still needed for
Thanks for the credit, but no need to go out of the way for this. I'm happy to just have the breakage fixed. |
I'll rebase this after #128950 lands to see if that addresses the CI issues. |
Ironically, #121795 will get rid of this code anyways... |
Just to be clear: I didn't mean that #121795 should block this. I found it just ironic that if I landed the patch a bit earlier this never would have happened. |
Since `363bfd6090b0 ([libc++] Use the new locale base API on Linux (llvm#128007), 2025-02-24)`, musl targets will fail to build with errors due to missing strtoll_l functions. Co-authored-by: Pirama Arumuga Nainar <[email protected]>
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: