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. 1269562e49SMarco Elverkcsan-cflags := -fsanitize=thread -fno-optimize-sibling-calls \ 1314e2ac8dSMarco 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))) \ 1475d75b7aSMarco Elver $(call cc-param,tsan-distinguish-volatile=1) 1569562e49SMarco Elver 16*116af35eSMarco Elverifdef CONFIG_CC_IS_GCC 17*116af35eSMarco Elver# GCC started warning about operations unsupported by the TSan runtime. But 18*116af35eSMarco Elver# KCSAN != TSan, so just ignore these warnings. 19*116af35eSMarco Elverkcsan-cflags += -Wno-tsan 20*116af35eSMarco Elverendif 21*116af35eSMarco Elver 2269562e49SMarco Elverifndef CONFIG_KCSAN_WEAK_MEMORY 2369562e49SMarco Elverkcsan-cflags += $(call cc-option,$(call cc-param,tsan-instrument-func-entry-exit=0)) 2469562e49SMarco Elverendif 2569562e49SMarco Elver 2669562e49SMarco Elverexport CFLAGS_KCSAN := $(kcsan-cflags) 27