Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I determine if UBSAN has been compiled in using clang or gcc?

We use the following code to determine if -fsanitize=address has been specified at compile time for clang and gcc. How do we determine if -fsanitize=undefined has been specified?

    bool isSanitized = false;
#if defined(__has_feature)
#if __has_feature(address_sanitizer)
    isSanitized = true;
#endif
#elif defined(__SANITIZE_ADDRESS__)
    isSanitized = true;
#endif
like image 839
Jonathan Abrahams Avatar asked Sep 07 '16 13:09

Jonathan Abrahams


1 Answers

I suggest you file this as a bug to ASan github (or GCC bugzilla) about this (we already have defined for ASan and TSan so it makes sense to cook one for UBSan as well). For now it seems your only option is to pass a custom define together with -fsanitize-undefined in a Makefile.

like image 51
yugr Avatar answered Sep 18 '22 14:09

yugr