[compiler-rt] [compiler-rt] Clean up Windows includes in sanitizer runtimes (PR #216586)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 16 10:41:10 PDT 2026
https://github.com/oltolm created https://github.com/llvm/llvm-project/pull/216586
None
>From 40d1c5c3cab8de3f00f61a173258dc2de47eb46c Mon Sep 17 00:00:00 2001
From: Oleg Tolmatcev <oleg.tolmatcev at gmail.com>
Date: Thu, 30 Jul 2026 19:52:05 +0200
Subject: [PATCH] [compiler-rt] Clean up Windows includes in sanitizer runtimes
Co-authored-by: Hannes Domani <ssbssa at yahoo.de>
---
compiler-rt/lib/asan/asan_malloc_win.cpp | 14 ++++++++------
compiler-rt/lib/builtins/emutls.c | 1 +
compiler-rt/lib/builtins/gcc_personality_v0.c | 2 +-
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/compiler-rt/lib/asan/asan_malloc_win.cpp b/compiler-rt/lib/asan/asan_malloc_win.cpp
index e728591cc145e..abb1b496d1b40 100644
--- a/compiler-rt/lib/asan/asan_malloc_win.cpp
+++ b/compiler-rt/lib/asan/asan_malloc_win.cpp
@@ -14,12 +14,14 @@
#include "sanitizer_common/sanitizer_allocator_interface.h"
#include "sanitizer_common/sanitizer_platform.h"
#if SANITIZER_WINDOWS
-#include "asan_allocator.h"
-#include "asan_interceptors.h"
-#include "asan_internal.h"
-#include "asan_stack.h"
-#include "interception/interception.h"
-#include <stddef.h>
+# include <stddef.h>
+
+# include "asan_allocator.h"
+# include "asan_interceptors.h"
+# include "asan_internal.h"
+# include "asan_stack.h"
+# include "interception/interception.h"
+# include "sanitizer_common/sanitizer_win_defs.h"
// Intentionally not including windows.h here, to avoid the risk of
// pulling in conflicting declarations of these functions. (With mingw-w64,
diff --git a/compiler-rt/lib/builtins/emutls.c b/compiler-rt/lib/builtins/emutls.c
index a8a5d7c0749a8..9d127e991a9b4 100644
--- a/compiler-rt/lib/builtins/emutls.c
+++ b/compiler-rt/lib/builtins/emutls.c
@@ -138,6 +138,7 @@ static __inline void emutls_unlock(void) { pthread_mutex_unlock(&emutls_mutex);
#include <assert.h>
#include <malloc.h>
#include <stdio.h>
+#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
static LPCRITICAL_SECTION emutls_mutex;
diff --git a/compiler-rt/lib/builtins/gcc_personality_v0.c b/compiler-rt/lib/builtins/gcc_personality_v0.c
index 6d92a7b248f3c..02d4e65d78d1c 100644
--- a/compiler-rt/lib/builtins/gcc_personality_v0.c
+++ b/compiler-rt/lib/builtins/gcc_personality_v0.c
@@ -22,8 +22,8 @@
#endif
#if defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)
+#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
-#include <winnt.h>
EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, void *, PCONTEXT,
PDISPATCHER_CONTEXT,
More information about the llvm-commits
mailing list