[compiler-rt] fe4a5a0 - [asan][test][win] Port more tests to not use clang-cl on MinGW (4)

Alvin Wong via llvm-commits llvm-commits at lists.llvm.org
Tue May 16 04:54:28 PDT 2023


Author: Alvin Wong
Date: 2023-05-16T19:53:49+08:00
New Revision: fe4a5a08b96a10c5941840729af55c4dc874c1bf

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

LOG: [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

Added: 
    

Modified: 
    compiler-rt/test/asan/TestCases/Windows/dll_global_dead_strip.c
    compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cpp
    compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cpp
    compiler-rt/test/asan/TestCases/Windows/global_dead_strip.c
    compiler-rt/test/asan/lit.cfg.py

Removed: 
    


################################################################################
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 @@ def build_invocation(compile_flags):
     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 @@ def build_invocation(compile_flags):
     # 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(


        


More information about the llvm-commits mailing list