blob: bd4da1af59532c96ebfab47b193c17908bdec740 [file] [log] [blame]
Marco Elverdfd402a2019-11-14 19:02:54 +01001# SPDX-License-Identifier: GPL-2.0
2ifdef CONFIG_KCSAN
3
Marco Elver17168f52020-05-21 16:20:38 +02004# GCC and Clang accept backend options differently. Do not wrap in cc-option,
5# because Clang accepts "--param" even if it is unused.
6ifdef CONFIG_CC_IS_CLANG
7cc-param = -mllvm -$(1)
8else
9cc-param = --param -$(1)
10endif
11
Marco Elver75d75b72020-05-21 16:20:39 +020012# Keep most options here optional, to allow enabling more compilers if absence
13# of some options does not break KCSAN nor causes false positive reports.
Marco Elver17168f52020-05-21 16:20:38 +020014CFLAGS_KCSAN := -fsanitize=thread \
Marco Elver75d75b72020-05-21 16:20:39 +020015 $(call cc-option,$(call cc-param,tsan-instrument-func-entry-exit=0) -fno-optimize-sibling-calls) \
Marco Elverd31d4d62020-05-21 16:20:40 +020016 $(call cc-option,$(call cc-param,tsan-instrument-read-before-write=1)) \
Marco Elver75d75b72020-05-21 16:20:39 +020017 $(call cc-param,tsan-distinguish-volatile=1)
Marco Elverdfd402a2019-11-14 19:02:54 +010018
19endif # CONFIG_KCSAN