Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0
0002 # GCC and Clang accept backend options differently. Do not wrap in cc-option,
0003 # because Clang accepts "--param" even if it is unused.
0004 ifdef CONFIG_CC_IS_CLANG
0005 cc-param = -mllvm -$(1)
0006 else
0007 cc-param = --param $(1)
0008 endif
0009 
0010 # Keep most options here optional, to allow enabling more compilers if absence
0011 # of some options does not break KCSAN nor causes false positive reports.
0012 kcsan-cflags := -fsanitize=thread -fno-optimize-sibling-calls \
0013         $(call cc-option,$(call cc-param,tsan-compound-read-before-write=1),$(call cc-option,$(call cc-param,tsan-instrument-read-before-write=1))) \
0014         $(call cc-param,tsan-distinguish-volatile=1)
0015 
0016 ifdef CONFIG_CC_IS_GCC
0017 # GCC started warning about operations unsupported by the TSan runtime. But
0018 # KCSAN != TSan, so just ignore these warnings.
0019 kcsan-cflags += -Wno-tsan
0020 endif
0021 
0022 ifndef CONFIG_KCSAN_WEAK_MEMORY
0023 kcsan-cflags += $(call cc-option,$(call cc-param,tsan-instrument-func-entry-exit=0))
0024 endif
0025 
0026 export CFLAGS_KCSAN := $(kcsan-cflags)