Skip to content

Commit a6bdf3f

Browse files
authored
[asan][windows][tests] support MSVC compiler-id in asan tests (llvm#109706)
This follows up on llvm#108255 to allow actually running the test suite with MSVC. Note, however, that MSVC can't yet build compiler-rt, most tests don't yet pass with msvc, and building and testing with different compilers is ill-supported. Follow ups will fix the first two issues, the third is future work. Note that `/Zi` is removed from the clang-cl command line, but lit as a whole adds `-gcodeview`, so there should still be debug info.
1 parent 71ca9fc commit a6bdf3f

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

compiler-rt/test/asan/lit.cfg.py

+16-6
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,16 @@ def build_invocation(compile_flags, with_lto=False):
153153
if platform.system() == "Windows":
154154
# MSVC-specific tests might also use the clang-cl.exe driver.
155155
if target_is_msvc:
156-
clang_cl_cxxflags = [
157-
"-Wno-deprecated-declarations",
158-
"-WX",
159-
"-D_HAS_EXCEPTIONS=0",
160-
"-Zi",
161-
] + target_cflags
156+
clang_cl_cxxflags = (
157+
[
158+
"-WX",
159+
"-D_HAS_EXCEPTIONS=0",
160+
]
161+
+ config.debug_info_flags
162+
+ target_cflags
163+
)
164+
if config.compiler_id != "MSVC":
165+
clang_cl_cxxflags = ["-Wno-deprecated-declarations"] + clang_cl_cxxflags
162166
clang_cl_asan_cxxflags = ["-fsanitize=address"] + clang_cl_cxxflags
163167
if config.asan_dynamic:
164168
clang_cl_asan_cxxflags.append("-MD")
@@ -286,6 +290,12 @@ def build_invocation(compile_flags, with_lto=False):
286290
[config.compiler_rt_libdir, os.environ.get("PATH", "")]
287291
)
288292

293+
# msvc needs to be instructed where the compiler-rt libraries are
294+
if config.compiler_id == "MSVC":
295+
config.environment["LIB"] = os.path.pathsep.join(
296+
[config.compiler_rt_libdir, config.environment.get("LIB", "")]
297+
)
298+
289299
# Default test suffixes.
290300
config.suffixes = [".c", ".cpp"]
291301

0 commit comments

Comments
 (0)