git: c809b0184d0a - main - libc++: fix compiling <locale> with -fmodules
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 18 May 2025 20:05:07 UTC
The branch main has been updated by dim:
URL: https://cgit.FreeBSD.org/src/commit/?id=c809b0184d0a6543bc5327d4252fa56a07ce4689
commit c809b0184d0a6543bc5327d4252fa56a07ce4689
Author: Jordan Gordeev <jgopensource@proton.me>
AuthorDate: 2025-05-18 19:55:05 +0000
Commit: Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2025-05-18 20:04:42 +0000
libc++: fix compiling <locale> with -fmodules
In /usr/include/c++/v1/__locale_dir/locale_base_api.h, xlocale.h is
included without first including stdio.h and stdlib.h, which causes
functions like strtoll_l() or sscanf_l() to not be declared.
When compiling with -fmodules, locale_base_api.h is processed separately
due to a declaration in /usr/include/c++/v1/module.modulemap, and this
will cause errors due to the above undeclared symbols.
Meanwhile, upstream has substantially reorganized this part of libc++'s
headers, so apply a minimalistic workaround: specifically when compiling
with -fmodules, add includes of stdio.h and stdlib.h.
PR: 286342
MFC after: 1 week
---
.../llvm-project/libcxx/include/__locale_dir/locale_base_api.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/contrib/llvm-project/libcxx/include/__locale_dir/locale_base_api.h b/contrib/llvm-project/libcxx/include/__locale_dir/locale_base_api.h
index 8c000c558c52..e43e87375069 100644
--- a/contrib/llvm-project/libcxx/include/__locale_dir/locale_base_api.h
+++ b/contrib/llvm-project/libcxx/include/__locale_dir/locale_base_api.h
@@ -25,7 +25,13 @@
# include <__locale_dir/locale_base_api/fuchsia.h>
#elif defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC)
# include <__locale_dir/locale_base_api/musl.h>
-#elif defined(__APPLE__) || defined(__FreeBSD__)
+#elif defined(__APPLE__)
+# include <xlocale.h>
+#elif defined(__FreeBSD__)
+# if __has_feature(modules)
+# include <stdio.h>
+# include <stdlib.h>
+# endif
# include <xlocale.h>
#endif