xref: /OK3568_Linux_fs/kernel/scripts/Makefile.kcsan (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun# GCC and Clang accept backend options differently. Do not wrap in cc-option,
3*4882a593Smuzhiyun# because Clang accepts "--param" even if it is unused.
4*4882a593Smuzhiyunifdef CONFIG_CC_IS_CLANG
5*4882a593Smuzhiyuncc-param = -mllvm -$(1)
6*4882a593Smuzhiyunelse
7*4882a593Smuzhiyuncc-param = --param $(1)
8*4882a593Smuzhiyunendif
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun# Keep most options here optional, to allow enabling more compilers if absence
11*4882a593Smuzhiyun# of some options does not break KCSAN nor causes false positive reports.
12*4882a593Smuzhiyunexport CFLAGS_KCSAN := -fsanitize=thread \
13*4882a593Smuzhiyun	$(call cc-option,$(call cc-param,tsan-instrument-func-entry-exit=0) -fno-optimize-sibling-calls) \
14*4882a593Smuzhiyun	$(call cc-option,$(call cc-param,tsan-compound-read-before-write=1),$(call cc-option,$(call cc-param,tsan-instrument-read-before-write=1))) \
15*4882a593Smuzhiyun	$(call cc-param,tsan-distinguish-volatile=1)
16