1# $NetBSD: Makefile,v 1.9 2023/08/10 20:44:37 mrg Exp $
2
3.include <bsd.own.mk>
4
5TESTSDIR=	${TESTSBASE}/lib/libc/misc
6
7TESTS_C+=	t_ubsan
8TESTS_CXX+=	t_ubsanxx
9
10.PATH:		${NETBSDSRCDIR}/common/lib/libc/misc
11SRCS.t_ubsan=	t_ubsan.c
12SRCS.t_ubsanxx=	t_ubsanxx.cpp
13
14.if ${MKSANITIZER:Uno} != "yes" && ${MKLIBCSANITIZER:Uno} != "yes"
15# These tests are designed to be used against micro-UBSan only.
16# micro-UBSan is used in these tests as a standalone library only.
17CPPFLAGS+=		-DENABLE_TESTS
18SRCS.t_ubsan+=		ubsan.c
19SRCS.t_ubsanxx+=	ubsan.c
20UBSAN_FLAGS=		-fsanitize=undefined
21UBSAN_FLAGS+=		${${ACTIVE_CC} == "clang" :? -fsanitize=integer :}
22UBSAN_FLAGS+=		${${ACTIVE_CC} == "clang" :? -fsanitize=nullability :}
23CFLAGS+=		${UBSAN_FLAGS}
24CXXFLAGS+=		${UBSAN_FLAGS}
25CWARNFLAGS+=		-Wno-return-type -Wno-strict-aliasing
26CWARNFLAGS.clang+=	-Wno-incompatible-pointer-types-discards-qualifiers
27CWARNFLAGS.clang+=	-Wno-nullability-completeness 
28.endif
29COPTS.t_ubsan.c += -Wno-stack-protector
30COPTS.t_ubsanxx.cpp += -Wno-stack-protector
31COPTS.ubsan.c+=    ${${ACTIVE_CC} == "clang" && ${MACHINE_ARCH} == "powerpc":? -O0 :}
32
33COPTS.t_ubsan.c+=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 7:? -Wno-int-in-bool-context :}
34COPTS.t_ubsanxx.cpp+=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 7:? -Wno-int-in-bool-context :}
35COPTS.t_ubsan.c+=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 12:? -Wno-uninitialized :}
36COPTS.t_ubsanxx.cpp+=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 12:? -Wno-uninitialized :}
37
38COPTS.ubsan.c+=    	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 9:? -Wno-builtin-declaration-mismatch :}
39
40.include <bsd.test.mk>
41