[compiler-rt] [compiler-rt] Adjust ASan Windows tests for mingw-w64 (PR #216585)

via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 16 10:40:10 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: oltolm (oltolm)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/216585.diff


2 Files Affected:

- (modified) compiler-rt/test/asan/TestCases/Windows/fuse-lld.cpp (+6-4) 
- (modified) compiler-rt/test/asan/TestCases/Windows/unsymbolized.cpp (+11-5) 


``````````diff
diff --git a/compiler-rt/test/asan/TestCases/Windows/fuse-lld.cpp b/compiler-rt/test/asan/TestCases/Windows/fuse-lld.cpp
index 5fa5945df4dc0..b689b403fcb92 100644
--- a/compiler-rt/test/asan/TestCases/Windows/fuse-lld.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/fuse-lld.cpp
@@ -2,8 +2,8 @@
 //
 // REQUIRES: lld-available
 //
-// RUN: %clangxx_asan -O2 %s -o %t.exe -g -gcodeview -fuse-ld=lld -Wl,-debug
-// RUN: not %run %t.exe 2>&1 | FileCheck %s
+// RUN: %clangxx_asan %if target={{.*-windows-gnu}} %{ -gcodeview -gcolumn-info -Wl,--pdb= %} %else %{ -g -gcodeview -Wl,-debug %} -O2 %s -o %t.exe -fuse-ld=lld
+// RUN: not %run %t.exe 2>&1 | FileCheck %s --check-prefixes=CHECK,%if target={{.*-windows-msvc.*}} %{MSVC%} %else %{MINGW%}
 
 #include <stdlib.h>
 
@@ -13,7 +13,9 @@ int main() {
   return x[5];
   // CHECK: heap-use-after-free
   // CHECK: free
-  // CHECK: main{{.*}}fuse-lld.cpp:[[@LINE-4]]:3
+  // MSVC: main{{.*}}fuse-lld.cpp:[[@LINE-4]]:3
+  // MINGW: {{.*fuse-lld.cpp.tmp.exe\+0x14000[0-9a-f]+}}
   // CHECK: malloc
-  // CHECK: main{{.*}}fuse-lld.cpp:[[@LINE-7]]:20
+  // MSVC: main{{.*}}fuse-lld.cpp:[[@LINE-8]]:20
+  // MINGW: {{.*fuse-lld.cpp.tmp.exe\+0x14000[0-9a-f]+}}
 }
diff --git a/compiler-rt/test/asan/TestCases/Windows/unsymbolized.cpp b/compiler-rt/test/asan/TestCases/Windows/unsymbolized.cpp
index ade5e5b914be8..29c9c3f7f15b9 100644
--- a/compiler-rt/test/asan/TestCases/Windows/unsymbolized.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/unsymbolized.cpp
@@ -3,9 +3,13 @@
 // which is the default image base of an executable.
 
 // RUN: rm -f %t.pdb
-// RUN: %clangxx_asan -c -O2 %s -o %t.obj
-// RUN: lld-link /nologo /OUT:%t.exe %t.obj -defaultlib:libcmt -nodefaultlib:msvcrt -defaultlib:oldnames %asan_static_runtime_thunk %asan_lib
-// RUN: not %run %t.exe 2>&1 | FileCheck %s
+// RUN: %if target={{.*-windows-gnu}} %{ \
+// RUN:   %clangxx_asan -O2 %s -o %t.exe -gcodeview -gcolumn-info -fuse-ld=lld \
+// RUN: %} %else %{ \
+// RUN:   %clangxx_asan -c -O2 %s -o %t.obj && \
+// RUN:   lld-link /nologo /OUT:%t.exe %t.obj -defaultlib:libcmt -nodefaultlib:msvcrt -defaultlib:oldnames %asan_static_runtime_thunk %asan_lib \
+// RUN: %}
+// RUN: not %run %t.exe 2>&1 | FileCheck %s --check-prefixes=CHECK,%if target={{.*-windows-msvc.*}} %{MSVC%} %else %{MINGW%}
 // REQUIRES: lld-available
 
 #include "../defines.h"
@@ -22,6 +26,8 @@ int do_uaf(void) {
   free(x);
   return x[5];
   // CHECK: AddressSanitizer: heap-use-after-free
-  // CHECK: #0 {{0x[a-f0-9]+ \(.*[\\/]unsymbolized.cpp.*.exe\+(0x40|0x14000)[a-f0-9]{4}\)}}
-  // CHECK: #1 {{0x[a-f0-9]+ \(.*[\\/]unsymbolized.cpp.*.exe\+(0x40|0x14000)[a-f0-9]{4}\)}}
+  // MSVC: #0 {{0x[a-f0-9]+ \(.*[\\/]unsymbolized.cpp.*.exe\+(0x40|0x14000)[a-f0-9]{4}\)}}
+  // MSVC: #1 {{0x[a-f0-9]+ \(.*[\\/]unsymbolized.cpp.*.exe\+(0x40|0x14000)[a-f0-9]{4}\)}}
+  // MINGW: #0 {{0x[a-f0-9]+ in do_uaf\(\) \(.*[\\/]unsymbolized.cpp.*.exe\+0x14000[a-f0-9]{4}\)}}
+  // MINGW: #1 {{0x[a-f0-9]+ in main \(.*[\\/]unsymbolized.cpp.*.exe\+0x14000[a-f0-9]{4}\)}}
 }

``````````

</details>


https://github.com/llvm/llvm-project/pull/216585


More information about the llvm-commits mailing list