[compiler-rt] [asan][test] Check Windows CRT linkage through object directives (PR #226342)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 24 19:54:29 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: kingakasa
<details>
<summary>Changes</summary>
use_after_return_linkage.cpp currently checks linker output for "Creating library" and the absence of LIBCMT. The first line depends on linker chatter, while that output does not directly establish which CRT default-library directives were emitted.
Compile the object separately and inspect its COFF directives with llvm-readobj. Require /DEFAULTLIB:msvcrt.lib, reject LIBCMT case-insensitively, and retain the DLL link step.
Validation: the changed test passes independently, including directive checks and DLL linking. The original test also passes in this environment. Its existing asan-dynamic-runtime requirement is retained; the static CRT configuration marks it unsupported.
Tested independently on Windows x64 using a fresh Release LLVM/Clang build with assertions enabled and a matching Release ASan runtime, based on `6dc4a4ba2850369afd537001377fb9d404653d26`.
Changed-line clang-format and git diff --check pass.
Assisted-by: OpenAI Codex
---
Full diff: https://github.com/llvm/llvm-project/pull/226342.diff
1 Files Affected:
- (modified) compiler-rt/test/asan/TestCases/Windows/msvc/use_after_return_linkage.cpp (+6-3)
``````````diff
diff --git a/compiler-rt/test/asan/TestCases/Windows/msvc/use_after_return_linkage.cpp b/compiler-rt/test/asan/TestCases/Windows/msvc/use_after_return_linkage.cpp
index cacf461b4f33a1..d804a601ff1f7b 100644
--- a/compiler-rt/test/asan/TestCases/Windows/msvc/use_after_return_linkage.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/msvc/use_after_return_linkage.cpp
@@ -2,9 +2,12 @@
// directives.
// REQUIRES: asan-dynamic-runtime
-// RUN: %clang_cl_asan -LD %s | FileCheck %s
-// CHECK: Creating library
-// CHECK-NOT: LIBCMT
+// RUN: %clang_cl_asan -c %s -Fo%t.obj
+// RUN: llvm-readobj --coff-directives %t.obj | FileCheck %s
+// RUN: %clang_cl_asan -LD %t.obj -Fe%t.dll
+// CHECK-NOT: {{[Ll][Ii][Bb][Cc][Mm][Tt]}}
+// CHECK: /DEFAULTLIB:msvcrt.lib
+// CHECK-NOT: {{[Ll][Ii][Bb][Cc][Mm][Tt]}}
void foo(int *p) { *p = 42; }
``````````
</details>
https://github.com/llvm/llvm-project/pull/226342
More information about the llvm-commits
mailing list