From 7d5433c17251662d99e8074e0ae1b578e89f868d Mon Sep 17 00:00:00 2001 From: Charlie Barto Date: Tue, 12 Mar 2024 10:19:14 -0700 Subject: [PATCH 1/2] support MSVC compiler-id in asan tests First, don't pass arguments that "real" msvc doesn't understand Second, add the compiler-rt lib directory to the LIB environment variable --- compiler-rt/test/asan/lit.cfg.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/compiler-rt/test/asan/lit.cfg.py b/compiler-rt/test/asan/lit.cfg.py index 05ed7e8dd294e..91351d12fd5f3 100644 --- a/compiler-rt/test/asan/lit.cfg.py +++ b/compiler-rt/test/asan/lit.cfg.py @@ -154,11 +154,11 @@ def build_invocation(compile_flags, with_lto=False): # MSVC-specific tests might also use the clang-cl.exe driver. if target_is_msvc: clang_cl_cxxflags = [ - "-Wno-deprecated-declarations", "-WX", "-D_HAS_EXCEPTIONS=0", - "-Zi", - ] + target_cflags + ] + config.debug_info_flags + target_cflags + if config.compiler_id != "MSVC": + clang_cl_cxxflags = ["-Wno-deprecated-declarations"] + clang_cl_cxxflags clang_cl_asan_cxxflags = ["-fsanitize=address"] + clang_cl_cxxflags if config.asan_dynamic: clang_cl_asan_cxxflags.append("-MD") @@ -286,6 +286,12 @@ def build_invocation(compile_flags, with_lto=False): [config.compiler_rt_libdir, os.environ.get("PATH", "")] ) +# msvc needs to be instructed where the compiler-rt libraries are +if config.compiler_id == "MSVC": + config.environment["LIB"] = os.path.pathsep.join( + [config.compiler_rt_libdir, config.environment.get("LIB", "")] + ) + # Default test suffixes. config.suffixes = [".c", ".cpp"] From 64f35ce33cf1c06ed942bf1667f6593bcb8bde49 Mon Sep 17 00:00:00 2001 From: Charlie Barto Date: Mon, 23 Sep 2024 14:45:36 -0700 Subject: [PATCH 2/2] reformat asan lit.cfg.py --- compiler-rt/test/asan/lit.cfg.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/compiler-rt/test/asan/lit.cfg.py b/compiler-rt/test/asan/lit.cfg.py index 91351d12fd5f3..dac3ef00a99af 100644 --- a/compiler-rt/test/asan/lit.cfg.py +++ b/compiler-rt/test/asan/lit.cfg.py @@ -153,10 +153,14 @@ def build_invocation(compile_flags, with_lto=False): if platform.system() == "Windows": # MSVC-specific tests might also use the clang-cl.exe driver. if target_is_msvc: - clang_cl_cxxflags = [ - "-WX", - "-D_HAS_EXCEPTIONS=0", - ] + config.debug_info_flags + target_cflags + clang_cl_cxxflags = ( + [ + "-WX", + "-D_HAS_EXCEPTIONS=0", + ] + + config.debug_info_flags + + target_cflags + ) if config.compiler_id != "MSVC": clang_cl_cxxflags = ["-Wno-deprecated-declarations"] + clang_cl_cxxflags clang_cl_asan_cxxflags = ["-fsanitize=address"] + clang_cl_cxxflags