Dear all,
I want to use LLVM (clang, clang++) as compiler on Windows in a MinGW
environment together with sanitizers (ASAN and UB). I am using the MinGW
distribution provided by winlibs.com which is based on MinGW-w64 7.0.0 -
release 3 and comes with LLVM 10. Unfortunately, the runtime libraries
necessary for ASAN are missing.
I compiled the missing runtime libraries myself from the LLVM repository
and copied the libraries into the distribution. I was not able to get
ASAN working with the GNU ld linker, so I have replaced ld.exe with
lld.exe. The effective linker now is the LLVM lld linker. With these
changes I am able to compile programs with and without sanitizers activated.
However, I ran into the problem that sometimes (not reproducable) lld
just hangs indefinitely. There have been issues with lld and winpthreads
which caused deadlocks in the past. Maybe, the problem I am facing is
similar. When attaching with lldb to a hanging ld.exe program, I see
that the process is stuck inside ntdll.dll (function WinDBG or something
similar, I don't exactly recall right now).
I tried to compile lld myself but was not successful. Using ld as linker
does not work for ASAN. And the proposed solution on this site
https://github.com/android/ndk/issues/855 to give the lld linker the
flag --no-threads does not work because the flag is not known. This is
quite strange as the flag is mentioned in the usage text that is shown
when running lld with the --help flag.
Once the code is compiled the sanitizers and the generated executables
work fine. Manually one can just abort the compilation and re-start it
if lld hangs. However, I want to automate the build process in a script
and hence the hangs are a show stopper.
At this point I woud be very happy for any help. Maybe there is a better
way to get support for sanitizers than my approach? Maybe there is a
workaround for the lld hangups? Maybe someone has a good idea how I can
debug why lld.exe hangs or maybe it's a known issue. Or maybe someone
knows how to get sanitizers working using GNU ld. I am grateful for any
hints.
Thank you so much.
--Michael
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public