[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:39:36 PDT 2026
https://github.com/oltolm created https://github.com/llvm/llvm-project/pull/216585
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.
>From 59fcf293230a4019cc3a6ff637000550b81a7f94 Mon Sep 17 00:00:00 2001
From: Oleg Tolmatcev <oleg.tolmatcev at gmail.com>
Date: Thu, 30 Jul 2026 19:51:53 +0200
Subject: [PATCH] [compiler-rt] Adjust ASan Windows tests for mingw-w64
Co-authored-by: Hannes Domani <ssbssa at yahoo.de>
---
.../test/asan/TestCases/Windows/fuse-lld.cpp | 10 ++++++----
.../test/asan/TestCases/Windows/unsymbolized.cpp | 16 +++++++++++-----
2 files changed, 17 insertions(+), 9 deletions(-)
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}\)}}
}
More information about the llvm-commits
mailing list