[PATCH] D58765: [sanitizers] Don't use Windows Trace Logging on MinGW

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 28 02:41:41 PST 2019


mstorsjo created this revision.
mstorsjo added reviewers: mcgov, rnk.
Herald added subscribers: Sanitizers, kubamracek.
Herald added projects: LLVM, Sanitizers.

mingw-w64 currently is lacking the headers for this feature.

Make the include lowercase at the same time. We consistently use lowercase for windows header includes, as windows itself is case insensitive, the SDK headers (in general, not necessarily considering this particular header) aren't consistent among themselves about what the proper canonical capitalization for headers are, and MinGW uses all lowercase names for the headers (as it is often used on case sensitive filesystems).

In case mingw-w64 later gets this header, we can revert this (but keep the include lowercased).

Should this be factored into some general define in some header (which one?) like SANITIZER_WIN_TRACE or so, to avoid duplicating the condition all over the place?


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D58765

Files:
  lib/sanitizer_common/sanitizer_common.h
  lib/sanitizer_common/sanitizer_win.cc


Index: lib/sanitizer_common/sanitizer_win.cc
===================================================================
--- lib/sanitizer_common/sanitizer_win.cc
+++ lib/sanitizer_common/sanitizer_win.cc
@@ -20,7 +20,9 @@
 #include <io.h>
 #include <psapi.h>
 #include <stdlib.h>
-#include <TraceLoggingProvider.h>
+#ifndef __MINGW32__
+#include <traceloggingprovider.h>
+#endif
 
 #include "sanitizer_common.h"
 #include "sanitizer_file.h"
@@ -32,6 +34,7 @@
 #if defined(PSAPI_VERSION) && PSAPI_VERSION == 1
 #pragma comment(lib, "psapi")
 #endif
+#ifndef __MINGW32__
 //  Windows trace logging provider init
 #pragma comment(lib, "advapi32.lib")
 TRACELOGGING_DECLARE_PROVIDER(g_asan_provider);
@@ -39,6 +42,9 @@
 TRACELOGGING_DEFINE_PROVIDER(g_asan_provider, "AddressSanitizerLoggingProvider",
                              (0x6c6c766d, 0x3846, 0x4e6a, 0xa4, 0xfb, 0x5b,
                               0x53, 0x0b, 0xd0, 0xf3, 0xfa));
+#else
+#define TraceLoggingUnregister(x)
+#endif
 
 // A macro to tell the compiler that this part of the code cannot be reached,
 // if the compiler supports this feature. Since we're using this in
@@ -1080,6 +1086,7 @@
   return sysinfo.dwNumberOfProcessors;
 }
 
+#ifndef __MINGW32__
 // TODO(mcgov): Rename this project-wide to PlatformLogInit
 void AndroidLogInit(void) {
   HRESULT hr = TraceLoggingRegister(g_asan_provider);
@@ -1103,6 +1110,7 @@
                       TraceLoggingValue(buffer, "AsanReportContents"));
   }
 }
+#endif
 
 }  // namespace __sanitizer
 
Index: lib/sanitizer_common/sanitizer_common.h
===================================================================
--- lib/sanitizer_common/sanitizer_common.h
+++ lib/sanitizer_common/sanitizer_common.h
@@ -804,7 +804,7 @@
 
 void WriteToSyslog(const char *buffer);
 
-#if SANITIZER_MAC || SANITIZER_WINDOWS
+#if SANITIZER_LINUX || (SANITIZER_WINDOWS && !defined(__MINGW32__))
 void LogFullErrorReport(const char *buffer);
 #else
 INLINE void LogFullErrorReport(const char *buffer) {}
@@ -818,7 +818,7 @@
 INLINE void LogMessageOnPrintf(const char *str) {}
 #endif
 
-#if SANITIZER_LINUX || SANITIZER_WINDOWS
+#if SANITIZER_LINUX || (SANITIZER_WINDOWS && !defined(__MINGW32__))
 // Initialize Android logging. Any writes before this are silently lost.
 void AndroidLogInit();
 void SetAbortMessage(const char *);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58765.188691.patch
Type: text/x-patch
Size: 2320 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190228/917f9a68/attachment.bin>


More information about the llvm-commits mailing list