[libunwind] Disable calls to fprintf for baremetal targets.

We've been having issues with using libcxxabi and libunwind for baremetal
targets because fprintf is dependent on io functions, this patch disables calls
to fprintf when building for baremetal in release mode.

Differential Revision: https://reviews.llvm.org/D30340



git-svn-id: https://llvm.org/svn/llvm-project/libunwind/trunk@296135 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/src/config.h b/src/config.h
index 8e57ec3..2c04610 100644
--- a/src/config.h
+++ b/src/config.h
@@ -78,6 +78,12 @@
 #define _LIBUNWIND_BUILD_ZERO_COST_APIS 0
 #endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_ABORT(msg)                                                  \
+  do {                                                                         \
+    abort();                                                                   \
+  } while (0)
+#else
 #define _LIBUNWIND_ABORT(msg)                                                  \
   do {                                                                         \
     fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__,          \
@@ -85,9 +91,14 @@
     fflush(stderr);                                                            \
     abort();                                                                   \
   } while (0)
+#endif
 
+#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#define _LIBUNWIND_LOG(msg, ...)
+#else
 #define _LIBUNWIND_LOG(msg, ...)                                               \
   fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
+#endif
 
 #if defined(_LIBUNWIND_HAS_NO_THREADS)
   // only used with pthread calls, not needed for the single-threaded builds