Skip to content

Commit e68dcd8

Browse files
melverpaulmckrcu
authored andcommitted
kcsan: Re-add GCC as a supported compiler
GCC version 11 recently implemented all requirements to correctly support KCSAN: 1. Correct no_sanitize-attribute inlining behaviour: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=4089df8ef4a63126b0774c39b6638845244c20d2 2. --param=tsan-distinguish-volatile https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=ab2789ec507a94f1a75a6534bca51c7b39037ce0 3. --param=tsan-instrument-func-entry-exit https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=06712fc68dc9843d9af7c7ac10047f49d305ad76 Therefore, we can re-enable GCC for KCSAN, and document the new compiler requirements. Signed-off-by: Marco Elver <[email protected]> Cc: Martin Liska <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 56b031f commit e68dcd8

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

Documentation/dev-tools/kcsan.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ approach to detect races. KCSAN's primary purpose is to detect `data races`_.
88
Usage
99
-----
1010

11-
KCSAN requires Clang version 11 or later.
11+
KCSAN is supported by both GCC and Clang. With GCC we require version 11 or
12+
later, and with Clang also require version 11 or later.
1213

1314
To enable KCSAN configure the kernel with::
1415

lib/Kconfig.kcsan

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ config HAVE_ARCH_KCSAN
44
bool
55

66
config HAVE_KCSAN_COMPILER
7-
def_bool CC_IS_CLANG && $(cc-option,-fsanitize=thread -mllvm -tsan-distinguish-volatile=1)
7+
def_bool (CC_IS_CLANG && $(cc-option,-fsanitize=thread -mllvm -tsan-distinguish-volatile=1)) || \
8+
(CC_IS_GCC && $(cc-option,-fsanitize=thread --param tsan-distinguish-volatile=1))
89
help
910
For the list of compilers that support KCSAN, please see
1011
<file:Documentation/dev-tools/kcsan.rst>.

scripts/Makefile.kcsan

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ifdef CONFIG_KCSAN
66
ifdef CONFIG_CC_IS_CLANG
77
cc-param = -mllvm -$(1)
88
else
9-
cc-param = --param -$(1)
9+
cc-param = --param $(1)
1010
endif
1111

1212
# Keep most options here optional, to allow enabling more compilers if absence

0 commit comments

Comments
 (0)