Skip to content

[asan][windows][tests] support MSVC compiler-id in asan tests #109706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

barcharcraz
Copy link
Contributor

This follows up on #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.

First, don't pass arguments that "real" msvc doesn't understand
Second, add the compiler-rt lib directory to the LIB environment variable
@llvmbot
Copy link
Member

llvmbot commented Sep 23, 2024

@llvm/pr-subscribers-compiler-rt-sanitizer

@llvm/pr-subscribers-platform-windows

Author: Charlie Barto (barcharcraz)

Changes

This follows up on #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.


Full diff: https://github.com/llvm/llvm-project/pull/109706.diff

1 Files Affected:

  • (modified) compiler-rt/test/asan/lit.cfg.py (+9-3)
diff --git a/compiler-rt/test/asan/lit.cfg.py b/compiler-rt/test/asan/lit.cfg.py
index 05ed7e8dd294e3..91351d12fd5f3e 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"]
 

Copy link

github-actions bot commented Sep 23, 2024

✅ With the latest revision this PR passed the Python code formatter.

@barcharcraz barcharcraz merged commit a6bdf3f into llvm:main Sep 24, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants