[llvm] Fix references to required libraries when building LLVM with ASAN and MultiThreaded[Debug] on Windows (PR #139657)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 12 12:04:22 PDT 2025
https://github.com/dgg5503 updated https://github.com/llvm/llvm-project/pull/139657
>From ae2499bfccb424787ea41dbdf6530dd207973cc1 Mon Sep 17 00:00:00 2001
From: Douglas Gliner <Douglas.Gliner at sony.com>
Date: Mon, 12 May 2025 19:00:01 -0700
Subject: [PATCH] Fix references to required libraries when building LLVM with
ASAN and MultiThreaded[Debug] on Windows
---
llvm/cmake/modules/HandleLLVMOptions.cmake | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index c427a65ee030c..2fcc5330d25bc 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -1037,13 +1037,14 @@ if(LLVM_USE_SANITIZER)
# lld string tail merging interacts badly with ASAN on Windows, turn it off here
# See https://github.com/llvm/llvm-project/issues/62078
append("/opt:nolldtailmerge" CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
+ # Static and dynamic C runtimes all load ASAN as a DLL
+ # See https://devblogs.microsoft.com/cppblog/msvc-address-sanitizer-one-dll-for-all-runtime-configurations/
+ append("clang_rt.asan_dynamic-${arch}.lib" CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
if (${CMAKE_MSVC_RUNTIME_LIBRARY} MATCHES "^(MultiThreaded|MultiThreadedDebug)$")
- append("/wholearchive:clang_rt.asan-${arch}.lib /wholearchive:clang_rt.asan_cxx-${arch}.lib"
- CMAKE_EXE_LINKER_FLAGS)
- append("/wholearchive:clang_rt.asan_dll_thunk-${arch}.lib"
- CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
+ append("/wholearchive:clang_rt.asan_static_runtime_thunk-${arch}.lib"
+ CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
else()
- append("clang_rt.asan_dynamic-${arch}.lib /wholearchive:clang_rt.asan_dynamic_runtime_thunk-${arch}.lib"
+ append("/wholearchive:clang_rt.asan_dynamic_runtime_thunk-${arch}.lib"
CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
endif()
endif()
More information about the llvm-commits
mailing list