如何在链接到动态 Visual C++ 运行时的 Windows 上构建 clang compiler-rt?

How to build clang compiler-rt on Windows linked against dynamic Visual C++ runtimes?

我想在 Windows 上将 clang-cl 与地址清理器一起使用。当尝试使用来自官方安装程序的预构建 llvm/clang 包时,我收到链接器错误,因为我的应用程序需要链接到动态 CRT (/MD) 而不是静态 CRT (/MT,llvm/clang 安装程序使用此构建了 compiler-rt)。

我想在 Qt 中使用它,因为我没能用 /MT 构建 Qt 本身。

根据 google 工程师的 these 幻灯片,使用 /MT 构建 compiler-rt/asan 是可能的。

these instructions 相比,在构建 llvm/clang 时,为了使用 /MT 构建 compiler-rt,我需要更改什么?

事实证明,我的 link 错误有 another 原因。

要查找所需的库,请使用以下命令构建一个小型 hello-world 应用程序,检查生成的 linker 命令并 link 显式查找所需的库:

clang-cl -v -fsanitize=address /MD test.cpp

PR35343(目前未解决)是关于在 lld-link 中支持自动 linking 消毒剂库,就像在其他平台上所做的那样。