[libcxx-commits] [libcxx] c7da05f - [libc++] Don't export ABI tagged __str_to_float_c_locale specializations on MinGW (#229456)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Oct 16 04:54:55 PDT 2026
Author: Himadhith
Date: 2026-10-16T13:54:48+02:00
New Revision: c7da05f9828542daaf634a6f4277212b5f6194d5
URL: https://github.com/llvm/llvm-project/commit/c7da05f9828542daaf634a6f4277212b5f6194d5
DIFF: https://github.com/llvm/llvm-project/commit/c7da05f9828542daaf634a6f4277212b5f6194d5.diff
LOG: [libc++] Don't export ABI tagged __str_to_float_c_locale specializations on MinGW (#229456)
Fixes a regression caused by
https://github.com/llvm/llvm-project/pull/222081. The issue is that when
building the library with a different ABI tag configuration causes
breakage for mingw configurations.
This patch splits `#if defined(_LIBCPP_MSVCRT)` guard to wrap the
primary template declaration.
- MSVCRT path: primary keeps `_LIBCPP_HIDE_FROM_ABI`.
- non-MSVCRT path: primary has no `_LIBCPP_HIDE_FROM_ABI`, so no abi_tag
is inherited by any specialization.
See
https://github.com/llvm/llvm-project/pull/222081#issuecomment-6002367552
and
https://github.com/llvm/llvm-project/pull/218527#issuecomment-5984167461
for more details.
This also collapses `__str_to_float_c_locale` for `<float> & <double>`
to use inline `_strtof_l` and `_strtod_l ` as it's available on both
MSVCRT and MinGW.
Added:
Modified:
libcxx/include/__locale_dir/support/windows.h
libcxx/src/support/win32/locale_win32.cpp
Removed:
################################################################################
diff --git a/libcxx/include/__locale_dir/support/windows.h b/libcxx/include/__locale_dir/support/windows.h
index e4a030c72e701b..a72aaccccef159 100644
--- a/libcxx/include/__locale_dir/support/windows.h
+++ b/libcxx/include/__locale_dir/support/windows.h
@@ -177,29 +177,32 @@ _LIBCPP_EXPORTED_FROM_ABI const char* __get_locale_encoding(__locale_t __loc);
// the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+
template <class _FloatT>
_LIBCPP_HIDE_FROM_ABI _FloatT __str_to_float_c_locale(const char* __nptr, char** __endptr);
-#if defined(_LIBCPP_MSVCRT)
template <>
inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
return ::_strtof_l(__nptr, __endptr, __get_c_locale());
}
+template <>
+inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
+ return ::_strtod_l(__nptr, __endptr, __get_c_locale());
+}
+
+#if defined(_LIBCPP_MSVCRT)
template <>
inline _LIBCPP_HIDE_FROM_ABI long double __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
return ::_strtold_l(__nptr, __endptr, __get_c_locale());
}
#else
-template <>
-_LIBCPP_EXPORTED_FROM_ABI float __str_to_float_c_locale<float>(const char*, char**);
+// _strtold_l is unavailable on MinGW. Export a plain (non-template) helper so
+// that no abi_tag is inherited from the primary template, then delegate to it.
+_LIBCPP_EXPORTED_FROM_ABI long double __strtold_c_locale(const char*, char**);
template <>
-_LIBCPP_EXPORTED_FROM_ABI long double __str_to_float_c_locale<long double>(const char*, char**);
-#endif
-
-template <>
-inline _LIBCPP_HIDE_FROM_ABI double __str_to_float_c_locale<double>(const char* __nptr, char** __endptr) {
- return ::_strtod_l(__nptr, __endptr, __get_c_locale());
+inline _LIBCPP_HIDE_FROM_ABI long double __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
+ return __strtold_c_locale(__nptr, __endptr);
}
+#endif
//
// Character manipulation functions
diff --git a/libcxx/src/support/win32/locale_win32.cpp b/libcxx/src/support/win32/locale_win32.cpp
index a09f219e7f1bd4..3ab2107afa0e0a 100644
--- a/libcxx/src/support/win32/locale_win32.cpp
+++ b/libcxx/src/support/win32/locale_win32.cpp
@@ -298,15 +298,10 @@ const char* __get_locale_encoding(__locale_t loc) {
//
// Strtonum functions
//
+// _strtold_l is unavailable on MinGW; provide a plain exported helper instead
+// so that no abi_tag is inherited by the exported symbol.
#if !defined(_LIBCPP_MSVCRT)
-template <>
-float __str_to_float_c_locale<float>(const char* nptr, char** endptr) {
- __locale_guard __current(__get_c_locale());
- return std::strtof(nptr, endptr);
-}
-
-template <>
-long double __str_to_float_c_locale<long double>(const char* nptr, char** endptr) {
+long double __strtold_c_locale(const char* nptr, char** endptr) {
__locale_guard __current(__get_c_locale());
return std::strtold(nptr, endptr);
}
More information about the libcxx-commits
mailing list