xref: /openbmc/linux/scripts/Makefile.kcsan (revision e68dcd8e)
1dfd402a4SMarco Elver# SPDX-License-Identifier: GPL-2.0
2dfd402a4SMarco Elverifdef CONFIG_KCSAN
3dfd402a4SMarco Elver
417168f5cSMarco Elver# GCC and Clang accept backend options differently. Do not wrap in cc-option,
517168f5cSMarco Elver# because Clang accepts "--param" even if it is unused.
617168f5cSMarco Elverifdef CONFIG_CC_IS_CLANG
717168f5cSMarco Elvercc-param = -mllvm -$(1)
817168f5cSMarco Elverelse
9e68dcd8eSMarco Elvercc-param = --param $(1)
1017168f5cSMarco Elverendif
1117168f5cSMarco Elver
1275d75b7aSMarco Elver# Keep most options here optional, to allow enabling more compilers if absence
1375d75b7aSMarco Elver# of some options does not break KCSAN nor causes false positive reports.
1417168f5cSMarco ElverCFLAGS_KCSAN := -fsanitize=thread \
1575d75b7aSMarco Elver	$(call cc-option,$(call cc-param,tsan-instrument-func-entry-exit=0) -fno-optimize-sibling-calls) \
16d31d4d6bSMarco Elver	$(call cc-option,$(call cc-param,tsan-instrument-read-before-write=1)) \
1775d75b7aSMarco Elver	$(call cc-param,tsan-distinguish-volatile=1)
18dfd402a4SMarco Elver
19dfd402a4SMarco Elverendif # CONFIG_KCSAN
20