# How to tell CMake on windows to use the compiler to call the linker

**URL:** https://discourse.cmake.org/t/how-to-tell-cmake-on-windows-to-use-the-compiler-to-call-the-linker/8086
**Category:** Code
**Tags:** os:windows, comp:clang
**Created:** [May 9, 2023, 3:23pm UTC](https://discourse.cmake.org/t/how-to-tell-cmake-on-windows-to-use-the-compiler-to-call-the-linker/8086 "2023-05-09T15:23:27Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Febbe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/febbe/32/2529_2.png) [@Febbe](https://discourse.cmake.org/u/Febbe)
#### Post date: [May 9, 2023, 3:23pm UTC](https://discourse.cmake.org/t/how-to-tell-cmake-on-windows-to-use-the-compiler-to-call-the-linker/8086/1 "2023-05-09T15:23:27Z")

</div>

I have a Toolchain file, which sets my preferred compiler to clang-cl and the linker to lld-link

But, when I want to use -fsanitize=address, lld-link does not know the correct location of the sanitzer runtime library. clang++ could know where to find it, but it is only used on linux to call the linker.

My question is, how I can force cmake, to call the Linker via the compiler, e.g. using `clang-cl -fuse-ld=lld`.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [May 10, 2023, 11:04am UTC](https://discourse.cmake.org/t/how-to-tell-cmake-on-windows-to-use-the-compiler-to-call-the-linker/8086/2 "2023-05-10T11:04:25Z")

</div>

@brad.king

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [May 10, 2023, 3:39pm UTC](https://discourse.cmake.org/t/how-to-tell-cmake-on-windows-to-use-the-compiler-to-call-the-linker/8086/3 "2023-05-10T15:39:51Z")

</div>

This is tracked in [CMake Issue 24243](https://gitlab.kitware.com/cmake/cmake/-/issues/24243). See [this post](https://gitlab.kitware.com/cmake/cmake/-/issues/24243#note_1289513) for a possible path forward.
