xref: /openbmc/linux/scripts/Makefile.kcsan (revision 75d75b7a)
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
917168f5cSMarco 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) \
1675d75b7aSMarco Elver	$(call cc-param,tsan-distinguish-volatile=1)
17dfd402a4SMarco Elver
18dfd402a4SMarco Elverendif # CONFIG_KCSAN
19