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 --- 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 --- 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 --- 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 --- 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 --- a/compiler-rt/test/asan/lit.cfg.py +++ b/compiler-rt/test/asan/lit.cfg.py @@ -156,11 +156,13 @@ 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 @@ # 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(