When trying to build libcxxabi on linux, I discovered that clang's
unwind.h doesn't provide enough definitions. This patch allows linux
builds to take advantage of libunwind if that's installed.

Another option would be to just copy the interfaces out of
http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/libgcc-s-ddefs.html,
but since we're relying on the system to provide definitions anyway,
it seems more sensible to try to pull the interface from the system
too.

Jeffrey
diff --git a/lib/Headers/unwind.h b/lib/Headers/unwind.h
index 28ad804..a99c8a1 100644
--- a/lib/Headers/unwind.h
+++ b/lib/Headers/unwind.h
@@ -23,9 +23,19 @@
 
 /* See "Data Definitions for libgcc_s" in the Linux Standard Base.*/
 
-#if defined(__APPLE__) && __has_include_next(<unwind.h>)
-/* Darwin typically has its own unwind.h; use it. */
-#  include_next <unwind.h>
+#if __has_include_next(<unwind.h>)
+/* Darwin and libunwind provide an unwind.h. If that's available, use
+ * it. libunwind wraps some of its definitions in #ifdef _GNU_SOURCE,
+ * so define that around the include.*/
+# ifndef _GNU_SOURCE
+#  define _SHOULD_UNDEFINE_GNU_SOURCE
+#  define _GNU_SOURCE
+# endif
+# include_next <unwind.h>
+# ifdef _SHOULD_UNDEFINE_GNU_SOURCE
+#  undef _GNU_SOURCE
+#  undef _SHOULD_UNDEFINE_GNU_SOURCE
+# endif
 #else
 
 #include <stdint.h>
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to