-
Notifications
You must be signed in to change notification settings - Fork 13.4k
release/18.x: [libc++] Simplify the implementation of <stddef.h> (#86843) #87374
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
@llvm/pr-subscribers-libcxx Author: None (llvmbot) ChangesBackport 2950283 Requested by: @ian-twilightcoder Full diff: https://github.com/llvm/llvm-project/pull/87374.diff 1 Files Affected:
diff --git a/libcxx/include/stddef.h b/libcxx/include/stddef.h
index 887776b150e49d..470b5408336c6d 100644
--- a/libcxx/include/stddef.h
+++ b/libcxx/include/stddef.h
@@ -7,18 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#if defined(__need_ptrdiff_t) || defined(__need_size_t) || defined(__need_wchar_t) || defined(__need_NULL) || \
- defined(__need_wint_t)
-
-# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-# endif
-
-# include_next <stddef.h>
-
-#elif !defined(_LIBCPP_STDDEF_H)
-# define _LIBCPP_STDDEF_H
-
/*
stddef.h synopsis
@@ -36,16 +24,19 @@
*/
-# include <__config>
+#include <__config>
+
+// Note: This include is outside of header guards because we sometimes get included multiple times
+// with different defines and the underlying <stddef.h> will know how to deal with that.
+#include_next <stddef.h>
+
+#ifndef _LIBCPP_STDDEF_H
+# define _LIBCPP_STDDEF_H
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
-# if __has_include_next(<stddef.h>)
-# include_next <stddef.h>
-# endif
-
# ifdef __cplusplus
typedef decltype(nullptr) nullptr_t;
# endif
|
Doesn't seem to have anything to do with this change. |
I agree the test failure here is a fluke. Merging this to LLVM 18 would be fine with me, however we are fairly late in the release cycle and this change is a bit tricky: we sometimes have surprises when changing C compatibility headers. I would have preferred merging this earlier in the release cycle. We definitely need this fix downstream, however since we haven't seen any issue related to this upstream, I would also be OK with not merging to I'll let the release manager decide. |
@tstellar what do you think? I'm a little nervous someone else will run into mysterious errors where |
Libc++'s own <stddef.h> is complicated by the need to handle various platform-specific macros and to support duplicate inclusion. In reality, we only need to add a declaration of nullptr_t to it, so we can simply include the underlying <stddef.h> outside of our guards to let it handle re-inclusion itself. (cherry picked from commit 2950283)
Well, I wish I would've known that. We cherry-picked it because it's a regression that was introduced in LLVM 18, and I am worried that it will cause issues on some platforms. |
I just started that process here: #88214 (comment) |
Hi @ian-twilightcoder (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. |
I don't think this needs a release note, it's a pretty minor change. |
Backport 2950283
Requested by: @ian-twilightcoder