<div dir="ltr"><div>TL;DR, add clang_rt.asan-i386.lib to the list of libraries you link and use the static, release CRT (/MT).</div><div><br></div><div>Thanks for trying it!<br></div><div><br></div><div>The problem is that you have to link the AddressSanitizer runtime library to resolve those symbols. It's distributed as a static library called clang_rt.asan-i386.lib and added to the linker search path by the VS integration.</div>
<div><br></div>However, MSBuild invokes the link.exe tool directly, so there isn't an opportunity for clang to inject the ASan RTL onto the link line like we do on Unix. We would inject it into .drectve at compile time, but you actually need to use a *different* asan RTL depending on whether you are building a DLL or an exe. At compile time, we're just making .obj files, and there's no flag that can tell us if we're building objs for a DLL.<div>
<br></div><div>Speaking of which, if you are making a DLL, use clang_rt.asan_dll_thunk-i386.lib. =/</div><div><br></div><div>You also have to use the static, release CRT to avoid symbol conflicts between the asan RT and the CRT, because in essence they are both trying to provide malloc, and coexisting can be tricky.</div>
<div><br></div><div><div>I recommend wrapping up these options in a separate "ASan" configuration parallel to Debug/Release, which we showed in the demo.</div><div><br></div></div><div>Timur knows more, he's been working on asan in particular.</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Sep 20, 2013 at 12:27 PM, Szymon Gatner <span dir="ltr"><<a href="mailto:szymon.gatner@gmail.com" target="_blank">szymon.gatner@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I just downloaded Windows / MSVC Clang installer. Integration with VC++2012 went fine and I am able to build executables with LLVM toolchain (YEY!) but after adding "-fsanitize=address" I am getting:</div>
<div><br></div><div><div>1>main.obj : error LNK2019: unresolved external symbol ___asan_report_store4 referenced in function _main</div><div>1>main.obj : error LNK2019: unresolved external symbol ___asan_report_load4 referenced in function _main</div>
<div>1>main.obj : error LNK2019: unresolved external symbol ___asan_report_load1 referenced in function _main</div><div>1>main.obj : error LNK2019: unresolved external symbol ___asan_init_v3 referenced in function _asan.module_ctor</div>
<div><br></div><div>I did see Chandler using it in his talk on GN2013 so I assume I am doing something wrong. </div><div><br></div><div>Since this is my first post on this list I also want to thank all you guys for this awesome compiler. I recently have of pleasure using it on OS X (tho XCode sucks) and it would be just the best thing if I could also switch to Cland on Windows. Thanks again!</div>
<div><br></div>Regards,
</div><div>Szymon Gatner</div></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>