# $NetBSD: Makefile.sanitizer,v 1.16 2020/09/15 05:19:34 mrg Exp $
SANITIZER=${GCCDIST}/libsanitizer
.PATH: ${SANITIZER}/interception ${SANITIZER}/sanitizer_common
INTERCEPTION_SRCS= \
interception_linux.cc \
interception_mac.cc \
interception_type_test.cc \
interception_win.cc
# XXXmknative
SANITIZER_SRCS+= \
sancov_flags.cc \
sanitizer_allocator.cc \
sanitizer_allocator_checks.cc \
sanitizer_allocator_report.cc \
sanitizer_common.cc \
sanitizer_common_libcdep.cc \
sanitizer_coverage_libcdep_new.cc \
sanitizer_deadlock_detector1.cc \
sanitizer_deadlock_detector2.cc \
sanitizer_errno.cc \
sanitizer_file.cc \
sanitizer_flag_parser.cc \
sanitizer_flags.cc \
sanitizer_libc.cc \
sanitizer_libignore.cc \
sanitizer_linux.cc \
sanitizer_linux_libcdep.cc \
sanitizer_linux_s390.cc \
sanitizer_mac.cc \
sanitizer_netbsd.cc \
sanitizer_openbsd.cc \
sanitizer_persistent_allocator.cc \
sanitizer_platform_limits_linux.cc \
sanitizer_platform_limits_netbsd.cc \
sanitizer_platform_limits_openbsd.cc \
sanitizer_platform_limits_solaris.cc \
sanitizer_posix.cc \
sanitizer_posix_libcdep.cc \
sanitizer_printf.cc \
sanitizer_procmaps_bsd.cc \
sanitizer_procmaps_common.cc \
sanitizer_procmaps_linux.cc \
sanitizer_procmaps_mac.cc \
sanitizer_procmaps_solaris.cc \
sanitizer_rtems.cc \
sanitizer_solaris.cc \
sanitizer_stackdepot.cc \
sanitizer_stacktrace.cc \
sanitizer_stacktrace_libcdep.cc \
sanitizer_stacktrace_printer.cc \
sanitizer_stacktrace_sparc.cc \
sanitizer_stoptheworld_linux_libcdep.cc \
sanitizer_stoptheworld_netbsd_libcdep.cc \
sanitizer_suppressions.cc \
sanitizer_symbolizer.cc \
sanitizer_symbolizer_libbacktrace.cc \
sanitizer_symbolizer_libcdep.cc \
sanitizer_symbolizer_mac.cc \
sanitizer_symbolizer_posix_libcdep.cc \
sanitizer_symbolizer_report.cc \
sanitizer_symbolizer_win.cc \
sanitizer_termination.cc \
sanitizer_thread_registry.cc \
sanitizer_tls_get_addr.cc \
sanitizer_unwind_linux_libcdep.cc \
sanitizer_unwind_win.cc \
sanitizer_win.cc
# The linux build does this to avoid preinit sections on shared libraries
CSHLIBFLAGS+= -DPIC
#SRCS+= ${INTERCEPTION_SRCS} ${SANITIZER_SRCS} ${UBSAN_SRCS}
SRCS+= ${INTERCEPTION_SRCS} ${SANITIZER_SRCS}
CPPFLAGS+=-I${SANITIZER}/include -I${SANITIZER}
CPPFLAGS.sanitizer_netbsd.cc+=-I${GCCDIST}/gcc/ginclude
CPPFLAGS+=-D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
CPPFLAGS+=-D__STDC_LIMIT_MACROS -DSANITIZER_HAS_EXCEPTIONS=1
CPPFLAGS+=-DSANITIZER_NEEDS_SEGV=1
#CPPFLAGS+=-DCAN_SANITIZE_UB=0
LIBDPLIBS+= pthread ${.CURDIR}/../../../../../lib/libpthread
COPTS+=-std=gnu++11 -fsized-deallocation -fvisibility=hidden
COPTS+=-fno-builtin -fno-exceptions -fno-rtti -funwind-tables
# Can't profile without it`
#-fomit-frame-pointer
.if ${MACHINE_ARCH} == "vax"
COPTS.sanitizer_allocator.cc += -O1
COPTS.sanitizer_common.cc += -O1
COPTS.sanitizer_common_libcdep.cc += -O1
COPTS.sanitizer_coverage_libcdep.cc += -O1
COPTS.sanitizer_coverage_mapping_libcdep.cc += -O1
COPTS.sanitizer_deadlock_detector1.cc += -O1
COPTS.sanitizer_mac.cc += -O1
COPTS.sanitizer_netbsd.cc += -O1
COPTS.sanitizer_posix.cc += -O1
COPTS.sanitizer_printf.cc += -O1
COPTS.sanitizer_procmaps_common.cc += -O1
COPTS.sanitizer_stackdepot.cc += -O1
COPTS.sanitizer_symbolizer_libcdep.cc += -O1
COPTS.sanitizer_symbolizer_report.cc += -O1
COPTS.ubsan_diag.cc += -O1
COPTS.ubsan_init.cc += -O1
.endif