From a33d5a9939aa3c0bcdb0f951c0bc4b96071bda2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 5 Apr 2023 10:18:38 +0300 Subject: [PATCH] [libunwind] Fflush stderr after each log message In most configs, stderr is line buffered by default, but in some cases on Windows (running in git bash, or running in Wine) stderr can end up fully buffered. See 2ec75a0869ab01fa9caf310e8a31eb7716182d30 for a similar change for the output from lit itself. This has no effect on libunwind when the log messages aren't enabled via the environment variables. Differential Revision: https://reviews.llvm.org/D147632 --- libunwind/src/config.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libunwind/src/config.h b/libunwind/src/config.h index 4bbac951624f9..6707d591361df 100644 --- a/libunwind/src/config.h +++ b/libunwind/src/config.h @@ -162,10 +162,14 @@ #define _LIBUNWIND_LOG0(msg) #define _LIBUNWIND_LOG(msg, ...) #else -#define _LIBUNWIND_LOG0(msg) \ - fprintf(stderr, "libunwind: " msg "\n") -#define _LIBUNWIND_LOG(msg, ...) \ - fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__) +#define _LIBUNWIND_LOG0(msg) do { \ + fprintf(stderr, "libunwind: " msg "\n"); \ + fflush(stderr); \ + } while (0) +#define _LIBUNWIND_LOG(msg, ...) do { \ + fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__); \ + fflush(stderr); \ + } while (0) #endif #if defined(NDEBUG)