From fe4a5a08b96a10c5941840729af55c4dc874c1bf Mon Sep 17 00:00:00 2001 From: Alvin Wong Date: Wed, 10 May 2023 05:41:06 +0800 Subject: [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 --- .../test/asan/TestCases/Windows/dll_global_dead_strip.c | 10 +++++----- .../test/asan/TestCases/Windows/dll_intercept_memcpy.cpp | 10 +++++----- .../test/asan/TestCases/Windows/dll_intercept_memset.cpp | 10 +++++----- compiler-rt/test/asan/TestCases/Windows/global_dead_strip.c | 8 ++++---- compiler-rt/test/asan/lit.cfg.py | 4 ++++ 5 files changed, 23 insertions(+), 19 deletions(-) (limited to 'compiler-rt') 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 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 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 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 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( -- cgit v1.2.1