summaryrefslogtreecommitdiff
path: root/compiler-rt
diff options
context:
space:
mode:
authorAlvin Wong <alvin@alvinhc.com>2023-05-10 05:41:06 +0800
committerAlvin Wong <alvin@alvinhc.com>2023-05-16 19:53:49 +0800
commitfe4a5a08b96a10c5941840729af55c4dc874c1bf (patch)
tree6e4dd281ca9b8cb0b5c41ade044e85daef1eb22c /compiler-rt
parent6282315f8ae52fda7d2eaa1e2ecd6d3dbb614f51 (diff)
downloadllvm-fe4a5a08b96a10c5941840729af55c4dc874c1bf.tar.gz
[asan][test][win] Port more tests to not use clang-cl on MinGW (4)
This ports some tests that requires dead stripping or ICF. Differential Revision: https://reviews.llvm.org/D150269
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/test/asan/TestCases/Windows/dll_global_dead_strip.c10
-rw-r--r--compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cpp10
-rw-r--r--compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp10
-rw-r--r--compiler-rt/test/asan/TestCases/Windows/global_dead_strip.c8
-rw-r--r--compiler-rt/test/asan/lit.cfg.py4
5 files changed, 23 insertions, 19 deletions
diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_global_dead_strip.c b/compiler-rt/test/asan/TestCases/Windows/dll_global_dead_strip.c
index 1871c001dd9a..a0c96622efee 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_global_dead_strip.c
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_global_dead_strip.c
@@ -1,10 +1,10 @@
-// UNSUPPORTED: target={{.*-windows-gnu}}
-
-// RUN: %clang_cl_asan -Od %p/dll_host.cpp -Fe%t
+// RUN: %clang_cl_asan %Od %p/dll_host.cpp %Fe%t
//
-// RUN: %clang_cl_asan /Gw -LD -Od %s -Fe%t.dll
+// RUN: %clang_cl_nocxx_asan %Gw %LD %Od %s %Fe%t.dll
// RUN: %env_asan_opts=report_globals=2 %run %t %t.dll 2>&1 | FileCheck %s --check-prefix=NOSTRIP
-// RUN: %clang_cl_asan /Gw -LD -O2 %s -Fe%t.dll -link -opt:ref
+// RUN: %clang_cl_nocxx_asan %Gw %LD -O2 %s %Fe%t.dll \
+// RUN: %if target={{.*-windows-gnu}} %{ -Wl,--gc-sections %} \
+// RUN: %else %{ -link -opt:ref %}
// RUN: %env_asan_opts=report_globals=2 %run %t %t.dll 2>&1 | FileCheck %s --check-prefix=STRIP
#include <stdio.h>
diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cpp
index 6ab61ae0a6c4..0a96752f9d0b 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cpp
@@ -1,11 +1,11 @@
-// UNSUPPORTED: target={{.*-windows-gnu}}
-
-// RUN: %clang_cl_asan -Od %p/dll_host.cpp -Fe%t
-// RUN: %clang_cl_asan -Wno-fortify-source -LD -Od %s -Fe%t.dll
+// RUN: %clang_cl_asan %Od %p/dll_host.cpp %Fe%t
+// RUN: %clang_cl_asan -Wno-fortify-source %LD %Od %s %Fe%t.dll
// RUN: not %run %t %t.dll 2>&1 | FileCheck %s
// Test that it works correctly even with ICF enabled.
-// RUN: %clang_cl_asan -Wno-fortify-source -LD -Od %s -Fe%t.dll -link /OPT:REF /OPT:ICF
+// RUN: %clang_cl_asan -Wno-fortify-source %LD %Od %s %Fe%t.dll \
+// RUN: %if target={{.*-windows-gnu}} %{ -Wl,--gc-sections,--icf=all %} \
+// RUN: %else %{ -link /OPT:REF /OPT:ICF %}
// RUN: not %run %t %t.dll 2>&1 | FileCheck %s
#include <stdio.h>
diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp
index 222c14356c55..27b343f439cb 100644
--- a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp
@@ -1,11 +1,11 @@
-// UNSUPPORTED: target={{.*-windows-gnu}}
-
-// RUN: %clang_cl_asan -Od %p/dll_host.cpp -Fe%t
-// RUN: %clang_cl_asan -Wno-fortify-source -LD -Od %s -Fe%t.dll
+// RUN: %clang_cl_asan %Od %p/dll_host.cpp %Fe%t
+// RUN: %clang_cl_asan -Wno-fortify-source %LD %Od %s %Fe%t.dll
// RUN: not %run %t %t.dll 2>&1 | FileCheck %s
// Test that it works correctly even with ICF enabled.
-// RUN: %clang_cl_asan -Wno-fortify-source -LD -Od %s -Fe%t.dll -link /OPT:REF /OPT:ICF
+// RUN: %clang_cl_asan -Wno-fortify-source %LD %Od %s %Fe%t.dll \
+// RUN: %if target={{.*-windows-gnu}} %{ -Wl,--gc-sections,--icf=all %} \
+// RUN: %else %{ -link /OPT:REF /OPT:ICF %}
// RUN: not %run %t %t.dll 2>&1 | FileCheck %s
#include <stdio.h>
diff --git a/compiler-rt/test/asan/TestCases/Windows/global_dead_strip.c b/compiler-rt/test/asan/TestCases/Windows/global_dead_strip.c
index 32d4a181ab38..0e15120a46f7 100644
--- a/compiler-rt/test/asan/TestCases/Windows/global_dead_strip.c
+++ b/compiler-rt/test/asan/TestCases/Windows/global_dead_strip.c
@@ -1,8 +1,8 @@
-// UNSUPPORTED: target={{.*-windows-gnu}}
-
-// RUN: %clang_cl_asan /Gw /Od %s /Fe%t.exe
+// RUN: %clang_cl_nocxx_asan %Gw %Od %s %Fe%t.exe
// RUN: %env_asan_opts=report_globals=2 %t.exe 2>&1 | FileCheck %s --check-prefix=NOSTRIP
-// RUN: %clang_cl_asan /Gw /O2 %s /Fe%t.exe -link -opt:ref
+// RUN: %clang_cl_nocxx_asan %Gw -O2 %s %Fe%t.exe \
+// RUN: %if target={{.*-windows-gnu}} %{ -Wl,--gc-sections %} \
+// RUN: %else %{ -link -opt:ref %}
// RUN: %env_asan_opts=report_globals=2 %t.exe 2>&1 | FileCheck %s --check-prefix=STRIP
#include <stdio.h>
diff --git a/compiler-rt/test/asan/lit.cfg.py b/compiler-rt/test/asan/lit.cfg.py
index 01eff0fbe392..03ac2063c397 100644
--- a/compiler-rt/test/asan/lit.cfg.py
+++ b/compiler-rt/test/asan/lit.cfg.py
@@ -156,11 +156,13 @@ if platform.system() == 'Windows':
clang_cl_asan_invocation = build_invocation(clang_cl_asan_cxxflags)
clang_cl_asan_invocation = clang_cl_asan_invocation.replace("clang.exe","clang-cl.exe")
config.substitutions.append( ("%clang_cl_asan ", clang_cl_asan_invocation) )
+ config.substitutions.append( ("%clang_cl_nocxx_asan ", clang_cl_asan_invocation) )
config.substitutions.append( ("%Od", "-Od") )
config.substitutions.append( ("%Fe", "-Fe") )
config.substitutions.append( ("%LD", "-LD") )
config.substitutions.append( ("%MD", "-MD") )
config.substitutions.append( ("%MT", "-MT") )
+ config.substitutions.append( ("%Gw", "-Gw") )
base_lib = os.path.join(config.compiler_rt_libdir, "clang_rt.asan%%s%s.lib" % config.target_suffix)
config.substitutions.append( ("%asan_lib", base_lib % "") )
@@ -171,11 +173,13 @@ if platform.system() == 'Windows':
# behaviour for MSVC target, substitute clang-cl flags with gcc-like ones.
config.substitutions.append( ("%clang_cl ", build_invocation(target_cxxflags)) )
config.substitutions.append( ("%clang_cl_asan ", build_invocation(clang_asan_cxxflags)) )
+ config.substitutions.append( ("%clang_cl_nocxx_asan ", build_invocation(clang_asan_cflags)) )
config.substitutions.append( ("%Od", "-O0") )
config.substitutions.append( ("%Fe", "-o") )
config.substitutions.append( ("%LD", "-shared") )
config.substitutions.append( ("%MD", "") )
config.substitutions.append( ("%MT", "") )
+ config.substitutions.append( ("%Gw", "-fdata-sections") )
# FIXME: De-hardcode this path.
asan_source_dir = os.path.join(