[compiler-rt] 391dd41 - [compiler-rt] Clean up Windows includes in sanitizer runtimes (#216586)

via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 16 17:44:01 PDT 2026


Author: oltolm
Date: 2026-08-16T17:43:56-07:00
New Revision: 391dd417e0864e2d1b50550e041e80b6a153a528

URL: https://github.com/llvm/llvm-project/commit/391dd417e0864e2d1b50550e041e80b6a153a528
DIFF: https://github.com/llvm/llvm-project/commit/391dd417e0864e2d1b50550e041e80b6a153a528.diff

LOG: [compiler-rt] Clean up Windows includes in sanitizer runtimes (#216586)

Extracted from https://github.com/llvm/llvm-project/pull/209902.
It's one of the patches that enables ASan and UBSan in GCC for Windows.

Co-authored-by: Hannes Domani <ssbssa at yahoo.de>

Added: 
    

Modified: 
    compiler-rt/lib/asan/asan_malloc_win.cpp
    compiler-rt/lib/builtins/emutls.c
    compiler-rt/lib/builtins/gcc_personality_v0.c

Removed: 
    


################################################################################
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