Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-2.6-microblaze.git] / scripts / Makefile.ubsan
1 # SPDX-License-Identifier: GPL-2.0
2
3 export CFLAGS_UBSAN :=
4
5 ifdef CONFIG_UBSAN_ALIGNMENT
6       CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment)
7 endif
8
9 ifdef CONFIG_UBSAN_BOUNDS
10       ifdef CONFIG_CC_IS_CLANG
11             CFLAGS_UBSAN += -fsanitize=array-bounds
12       else
13             CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds)
14       endif
15 endif
16
17 ifdef CONFIG_UBSAN_LOCAL_BOUNDS
18       CFLAGS_UBSAN += -fsanitize=local-bounds
19 endif
20
21 ifdef CONFIG_UBSAN_MISC
22       CFLAGS_UBSAN += $(call cc-option, -fsanitize=shift)
23       CFLAGS_UBSAN += $(call cc-option, -fsanitize=integer-divide-by-zero)
24       CFLAGS_UBSAN += $(call cc-option, -fsanitize=unreachable)
25       CFLAGS_UBSAN += $(call cc-option, -fsanitize=signed-integer-overflow)
26       CFLAGS_UBSAN += $(call cc-option, -fsanitize=object-size)
27       CFLAGS_UBSAN += $(call cc-option, -fsanitize=bool)
28       CFLAGS_UBSAN += $(call cc-option, -fsanitize=enum)
29 endif
30
31 ifdef CONFIG_UBSAN_TRAP
32       CFLAGS_UBSAN += $(call cc-option, -fsanitize-undefined-trap-on-error)
33 endif
34
35       # -fsanitize=* options makes GCC less smart than usual and
36       # increase number of 'maybe-uninitialized false-positives
37       CFLAGS_UBSAN += $(call cc-option, -Wno-maybe-uninitialized)