[libcxx-commits] [libcxx] [libc++] Don't export ABI tagged __str_to_float_c_locale specializations on MinGW (PR #229456)
Venkatesh Srinivasan via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Oct 20 13:58:53 PDT 2026
venk-ks wrote:
Hi @Himadhith,
Commit c7da05f9828542daaf634a6f4277212b5f6194d5 (PR #229456: "[libc++] Don't export ABI tagged __str_to_float_c_locale specializations on MinGW") broke the MinGW/Windows cross-compilation of libc++:
```
libcxx/include/__locale_dir/support/windows.h:183:12: error: no member named '_strtof_l' in the global namespace
return ::_strtof_l(__nptr, __endptr, __get_c_locale());
~~^
1 error generated.
```
**Root Cause:**
In commit c7da05f98285, `__str_to_float_c_locale<float>` was moved out of `#if defined(_LIBCPP_MSVCRT)` so that it applies unconditionally on Windows, and the MinGW-specific specialization in `libcxx/src/support/win32/locale_win32.cpp` was removed.
However, in standard MinGW-w64 environments targeting `msvcrt.dll`, `::_strtof_l` is not exposed in the global namespace in `<locale.h>`/`<stdlib.h>` (unlike UCRT environments).
Could you please revert this commit or provide a fix for MinGW environments lacking `_strtof_l` in the global namespace?
**Suggested fix:**
We can mirror the pattern already introduced for long double: provide a plain (non-template) exported helper `__strtof_c_locale` in `locale_win32.cpp` so that no `abi_tag` is inherited:
In `libcxx/src/support/win32/locale_win32.cpp`:
```
#if !defined(_LIBCPP_MSVCRT)
float __strtof_c_locale(const char* nptr, char** endptr) {
__locale_guard __current(__get_c_locale());
return std::strtof(nptr, endptr);
}
long double __strtold_c_locale(const char* nptr, char** endptr) {
__locale_guard __current(__get_c_locale());
return std::strtold(nptr, endptr);
}
#endif
```
And in `libcxx/include/__locale_dir/support/windows.h`:
```
#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 long double __str_to_float_c_locale<long double>(const char* __nptr, char** __endptr) {
return ::_strtold_l(__nptr, __endptr, __get_c_locale());
}
#else
_LIBCPP_EXPORTED_FROM_ABI float __strtof_c_locale(const char*, char**);
_LIBCPP_EXPORTED_FROM_ABI long double __strtold_c_locale(const char*, char**);
template <>
inline _LIBCPP_HIDE_FROM_ABI float __str_to_float_c_locale<float>(const char* __nptr, char** __endptr) {
return __strtof_c_locale(__nptr, __endptr);
}
template <>
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
```
https://github.com/llvm/llvm-project/pull/229456
More information about the libcxx-commits
mailing list