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