[libcxx-commits] [libcxx] Fix builds with macOS SDKs older than 10.13 (PR #134548)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Apr 6 09:59:02 PDT 2025
https://github.com/Un1q32 created https://github.com/llvm/llvm-project/pull/134548
`sys/_types/_mbstate_t.h` was added in the 10.9 SDK, but it didn't include `machine/types.h` for you until 10.13, this results in a funny situation where partial libc++ builds are possible with the 10.8 SDK and the 10.13 SDK but not 10.9-10.12, since you'll get an error about `__darwin_mbstate_t` not being defined (`sys/_types/_mbstate_t.h` just does `typedef __darwin_mbstate_t mbstate_t;`). I know versions before 10.13 aren't officially supported, but it would be nice to keep supporting partial builds at least.
>From 4d6795305bcbe3d335aae399bc04d51342987674 Mon Sep 17 00:00:00 2001
From: Un1q32 <joey.t.reinhart at gmail.com>
Date: Sun, 6 Apr 2025 12:00:15 -0400
Subject: [PATCH] Fix builds with macOS SDKs older than 10.13
---
libcxx/include/__cxx03/__mbstate_t.h | 1 +
libcxx/include/__mbstate_t.h | 1 +
2 files changed, 2 insertions(+)
diff --git a/libcxx/include/__cxx03/__mbstate_t.h b/libcxx/include/__cxx03/__mbstate_t.h
index 6c7cfaaa8fe5b..07a30ee881795 100644
--- a/libcxx/include/__cxx03/__mbstate_t.h
+++ b/libcxx/include/__cxx03/__mbstate_t.h
@@ -42,6 +42,7 @@
#elif __has_include(<bits/types/mbstate_t.h>)
# include <bits/types/mbstate_t.h> // works on most Unixes
#elif __has_include(<sys/_types/_mbstate_t.h>)
+# include <machine/types.h>
# include <sys/_types/_mbstate_t.h> // works on Darwin
#elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) && __has_include_next(<wchar.h>)
# include_next <wchar.h> // fall back to the C standard provider of mbstate_t
diff --git a/libcxx/include/__mbstate_t.h b/libcxx/include/__mbstate_t.h
index c23ea7113ca70..6a819dd34af72 100644
--- a/libcxx/include/__mbstate_t.h
+++ b/libcxx/include/__mbstate_t.h
@@ -42,6 +42,7 @@
#elif __has_include(<bits/types/mbstate_t.h>)
# include <bits/types/mbstate_t.h> // works on most Unixes
#elif __has_include(<sys/_types/_mbstate_t.h>)
+# include <machine/types.h>
# include <sys/_types/_mbstate_t.h> // works on Darwin
#elif __has_include_next(<wchar.h>)
# include_next <wchar.h> // use the C standard provider of mbstate_t if present
More information about the libcxx-commits
mailing list