<div dir="ltr"><div dir="ltr"><div>Hello,</div><div><br></div><div>I would like to use ASan/UBsan on Windows together with clang-cl and lld-link.</div><div><br></div><div>Is it nowadays possible to somehow pass the sanitizer flags to lld-link in order to get automatic linking?</div><div><br></div><div><br></div><div>The following commands ...</div><div>__________________________</div><div>echo int main() { return 0;} > test.cpp</div><div>clang-cl test.cpp /c -fsanitize=address</div><div>lld-link *.obj /OUT:"test.exe" -fsanitize=address</div><div>__________________________</div><div><br></div><div><br></div><div>... just give me the following errors:</div><div>___________________________</div><div>lld-link.exe: warning: ignoring unknown argument: -fsanitize=address</div><div>lld-link.exe: error: undefined symbol: ___asan_init</div><div>>>> referenced by test.obj:(_asan.module_ctor)</div><div>lld-link.exe: error: undefined symbol: ___asan_version_mismatch_check_v8</div><div>>>> referenced by test.obj:(_asan.module_ctor)</div><div>___________________________</div><div><br></div><div><br></div><div>I know there is the following possibility to find the parameters to "manually" add everything to the lld-link (or link.exe) call:</div><div>___________________________</div><div>clang-cl -v -fsanitize=address test.cpp 2>&1 | find "link.exe"</div><div> "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\link.exe" -out:test.exe -nologo -debug -incremental:no "C:\\Program Files (x86)\\LLVM\\lib\\clang\\7.0.1\\lib\\windows\\clang_rt.asan-i386.lib" "-wholearchive:C:\\Program Files (x86)\\LLVM\\lib\\clang\\7.0.1\\lib\\windows\\clang_rt.asan-i386.lib" "C:\\Program Files (x86)\\LLVM\\lib\\clang\\7.0.1\\lib\\windows\\clang_rt.asan_cxx-i386.lib" "-wholearchive:C:\\Program Files (x86)\\LLVM\\lib\\clang\\7.0.1\\lib\\windows\\clang_rt.asan_cxx-i386.lib" "C:\\Users\\markus\\AppData\\Local\\Temp\\test-941b84.obj"</div><div>___________________________</div><div><br></div><div><br></div><div>But adopting these paths for every minor version change of clang sounds like an awful idea. The idea of writing a script that automates finding these paths in a build system just feels very wrong, too ...</div><div><br></div><div><br></div><div>Is there any mechanism to pass the -fsanitize=... flags on to lld-link like it is done for non-MSVC builds?</div><div><br></div><div>Best regards</div><div>Markus Haberlander</div><div><br></div></div></div>