-
Notifications
You must be signed in to change notification settings - Fork 12.1k
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
[libc++] Only include <setjmp.h> from the C library if it exists #81887
Conversation
@llvm/pr-subscribers-libcxx Author: Louis Dionne (ldionne) ChangesIn 2cea1ba, we removed the <setjmp.h> header provided by libc++. However, we did not conditionally include the underlying <setjmp.h> header only if the C library provides one, which we otherwise do consistently (see e.g. 647ddc0). rdar://122978778 Full diff: https://github.com/llvm/llvm-project/pull/81887.diff 1 Files Affected:
diff --git a/libcxx/include/csetjmp b/libcxx/include/csetjmp
index d219c8e6cb2250..9012cad22ebe74 100644
--- a/libcxx/include/csetjmp
+++ b/libcxx/include/csetjmp
@@ -33,7 +33,13 @@ void longjmp(jmp_buf env, int val);
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <setjmp.h>
+// <setjmp.h> is not provided by libc++
+#if __has_include(<setjmp.h>)
+# include <setjmp.h>
+# ifdef _LIBCPP_SETJMP_H
+# error "If libc++ starts defining <setjmp.h>, the __has_include check should move to libc++'s <setjmp.h>"
+# endif
+#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
|
This broke some code downstream and we think this could have a negative impact on freestanding users (who are most likely not to have a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Does this need to be backported to the release branch? |
Yes, sorry I am going OOO and I forgot to merge this one. Merged from my phone just now. /cherry-pick d8278b6 |
/pull-request #82045 |
In 2cea1ba, we removed the <setjmp.h> header provided by libc++. However, we did not conditionally include the underlying <setjmp.h> header only if the C library provides one, which we otherwise do consistently (see e.g. 647ddc0).
rdar://122978778