3

I'm trying to use the gcc address sanitizer in Qt by adding CONFIG += sanitizer sanitize_address to my .pro file but I'm getting an error: cannot find -lasan.

How should I install the library?

I'm using the MinGW provided by Qt but I could also try a standalone version.


Related question: MinGW-w64's gcc and Address Sanitizer

Drew Dormann
  • 59,987
  • 13
  • 123
  • 180
Josu Goñi
  • 1,178
  • 1
  • 10
  • 26

1 Answers1

5

Unfortunately GCC does not support Asan on Windows: here's an excerpt from libsanitizer/configure.tgt:

case "${target}" in
  x86_64-*-linux* | i?86-*-linux*)
    ...
  powerpc*-*-linux*)
    ...
  sparc*-*-linux*)
    ...
  s390*-*-linux*)
    ...
  sparc*-*-solaris2.11*)
    ...
  arm*-*-linux*)
    ...
  mips*64*-*-linux*)
    ...
  mips*-*-linux*)
    ...
  aarch64*-*-linux*)
    ...
  x86_64-*-darwin[1]* | i?86-*-darwin[1]*)
    ...
  x86_64-*-solaris2.11* | i?86-*-solaris2.11*)
    ...
  *)
    UNSUPPORTED=1
    ;;
esac

Note that Clang supports it (with some effort - see wiki for details) and many people have successfully used it.

yugr
  • 19,769
  • 3
  • 51
  • 96
  • I can read this `ASAN, TSAN and USAN are great technologies which are available in GCC. Unfortunately they are not completely usable on Windows. A proper review and tests are needed before anything.` [here](http://mingw-w64.org/doku.php/contribute). Can you confirm it can't be used so I mark your answer as correct? – Josu Goñi Mar 24 '19 at 23:35
  • @JosuGoñi I've added some prooflinks. Note that adding support in GCC shouldn't be hard, just none of major contributors has been interested in it. – yugr Mar 25 '19 at 08:21
  • 1
    @JosuGoñi that excerpt now lives at https://www.mingw-w64.org/contribute/#thorough-status-report-for-sanitizers-asan-tsan-usan – Helder Magalhães Jan 12 '22 at 11:25