^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # GCC and Clang accept backend options differently. Do not wrap in cc-option,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) # because Clang accepts "--param" even if it is unused.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) ifdef CONFIG_CC_IS_CLANG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) cc-param = -mllvm -$(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) cc-param = --param $(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) # Keep most options here optional, to allow enabling more compilers if absence
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) # of some options does not break KCSAN nor causes false positive reports.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) export CFLAGS_KCSAN := -fsanitize=thread \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) $(call cc-option,$(call cc-param,tsan-instrument-func-entry-exit=0) -fno-optimize-sibling-calls) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) $(call cc-option,$(call cc-param,tsan-compound-read-before-write=1),$(call cc-option,$(call cc-param,tsan-instrument-read-before-write=1))) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) $(call cc-param,tsan-distinguish-volatile=1)