[cfe-dev] OT: UBsan and Asan makefile targets

Jeffrey Walton noloader at gmail.com
Wed Jul 15 21:58:16 PDT 2015


Hi Everyone,

Great work on the sanitizers. I can't express how useful they are.

The Crypto++ project just promoted them to first class makefile
targets for internal testing.

For other who want to do the same, one can perform similar to the
following if using GNU Make (sorry, the Posix Make folks are out of
luck):

  # Undefined Behavior Sanitzier (Clang and G++)
  ifeq ($(findstring ubsan,$(MAKECMDGOALS)),ubsan)
  CXXFLAGS += -fsanitize=undefined
  endif # UBsan

  # Address Sanitzier (Clang and G++)
  ifeq ($(findstring asan,$(MAKECMDGOALS)),asan)
  CXXFLAGS += -fsanitize=address
  endif # Asan

Then, we provide a recipe for them:

  asan ubsan: libcryptopp.a cryptest.exe

Jeff



More information about the cfe-dev mailing list