blob: 37cb504c77e136e6838a166d184978c4e5e0d97a [file] [log] [blame]
Marco Elverdfd402a2019-11-14 19:02:54 +01001# SPDX-License-Identifier: GPL-2.0
Marco Elver17168f52020-05-21 16:20:38 +02002# GCC and Clang accept backend options differently. Do not wrap in cc-option,
3# because Clang accepts "--param" even if it is unused.
4ifdef CONFIG_CC_IS_CLANG
5cc-param = -mllvm -$(1)
6else
Marco Elvere68dcd82020-06-18 11:31:16 +02007cc-param = --param $(1)
Marco Elver17168f52020-05-21 16:20:38 +02008endif
9
Marco Elver75d75b72020-05-21 16:20:39 +020010# Keep most options here optional, to allow enabling more compilers if absence
11# of some options does not break KCSAN nor causes false positive reports.
Masahiro Yamadabb273212020-09-10 22:44:29 +090012export CFLAGS_KCSAN := -fsanitize=thread \
Marco Elver75d75b72020-05-21 16:20:39 +020013 $(call cc-option,$(call cc-param,tsan-instrument-func-entry-exit=0) -fno-optimize-sibling-calls) \
Marco Elver14e2ac82020-07-24 09:00:01 +020014 $(call cc-option,$(call cc-param,tsan-compound-read-before-write=1),$(call cc-option,$(call cc-param,tsan-instrument-read-before-write=1))) \
Marco Elver75d75b72020-05-21 16:20:39 +020015 $(call cc-param,tsan-distinguish-volatile=1)