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