[PATCH] D126706: [CMake] Improve support for ASAN on Windows with MSVC cl & clang-cl

Markus Böck via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 31 14:55:37 PDT 2022


zero9178 added inline comments.


================
Comment at: llvm/cmake/modules/HandleLLVMOptions.cmake:897
+        if (${LLVM_USE_CRT_${uppercase_CMAKE_BUILD_TYPE}} MATCHES "^(MT|MTd)$")
+          append("/wholearchive:clang_rt.asan-x86_64.lib /wholearchive:clang_rt.asan_cxx-x86_64.lib"
+            CMAKE_EXE_LINKER_FLAGS)
----------------
rnk wrote:
> This assumes x86_64, while i386 is also a possibility.
> 
> I wish we hadn't embedded the architecture into our library names. =/
They may even possibly not have a suffix at all if the clang toolchain has per target runtime directories. In that case it is eg. called just `clang_rt.asan.lib` on my machine. 

So this seems like if we want it to actually handle all possible options we'll have to loop and check for the existence of those files.
One can use either `clang-cl /clang:-print-runtime-dir` to get the directory of the runtime files if the clang version is new enough or otherwise `clang-cl /clang:-print-libgcc-file-name /clang:--rtlib=compiler-rt` to get the (likely non existent) builtins file to extract the directory from. The latter is quite a hack however that has worked well for me so far.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126706/new/

https://reviews.llvm.org/D126706



More information about the llvm-commits mailing list