xref: /openbmc/linux/scripts/Makefile.kcsan (revision 14e2ac8d)
1dfd402a4SMarco Elver# SPDX-License-Identifier: GPL-2.0
217168f5cSMarco Elver# GCC and Clang accept backend options differently. Do not wrap in cc-option,
317168f5cSMarco Elver# because Clang accepts "--param" even if it is unused.
417168f5cSMarco Elverifdef CONFIG_CC_IS_CLANG
517168f5cSMarco Elvercc-param = -mllvm -$(1)
617168f5cSMarco Elverelse
7e68dcd8eSMarco Elvercc-param = --param $(1)
817168f5cSMarco Elverendif
917168f5cSMarco Elver
1075d75b7aSMarco Elver# Keep most options here optional, to allow enabling more compilers if absence
1175d75b7aSMarco Elver# of some options does not break KCSAN nor causes false positive reports.
1217168f5cSMarco ElverCFLAGS_KCSAN := -fsanitize=thread \
1375d75b7aSMarco Elver	$(call cc-option,$(call cc-param,tsan-instrument-func-entry-exit=0) -fno-optimize-sibling-calls) \
1414e2ac8dSMarco Elver	$(call cc-option,$(call cc-param,tsan-compound-read-before-write=1),$(call cc-option,$(call cc-param,tsan-instrument-read-before-write=1))) \
1575d75b7aSMarco Elver	$(call cc-param,tsan-distinguish-volatile=1)
16