[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
Mon Jun 16 12:26:53 PDT 2025


dgg5503 wrote:

Hi @barcharcraz ,

I re-reviewed these changes and can confirm they are still necessary in the case of building LLVM / Clang with `-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded[Debug] -DLLVM_USE_SANITIZER=Address` -- at least when building using Clang-CL and lld-link from the latest Clang / LLVM binary package (20.1.7).

> but I question if we really need to be messing with the linker flags here in the first place. This is exactly what the clang driver does if you link through it with /fsanitize=address or what link.exe does when it sees the asan directive.

It indeed does look like the appropriate libraries will be added automatically as per:
https://github.com/llvm/llvm-project/blob/fccab5d757778204666d70e2f1592952fc8b336d/clang/lib/Driver/ToolChains/MSVC.cpp#L203-L228

However, at least from the CMake options I'm using and my build environment, it appears that linking is invoked directly via the linker rather than linking via the compiler driver invoking the linker. Therefore, unless there's a CMake flag or some other bits of configuration I may be overlooking (please let me know if that is the case), it seems like this change is required.

I will wait a few more days before merging to give you time to reply in-case there's extra discussion that may be worth having.

Thanks again for reviewing, sorry if my pings were a bit annoying 😅...

https://github.com/llvm/llvm-project/pull/139657


More information about the llvm-commits mailing list