Skip to content

Commit ea91a1d

Browse files
arndbKAGA-KOKO
authored andcommitted
ubsan, kcsan: Don't combine sanitizer with kcov on clang
Clang does not allow -fsanitize-coverage=trace-{pc,cmp} together with -fsanitize=bounds or with ubsan: clang: error: argument unused during compilation: '-fsanitize-coverage=trace-pc' [-Werror,-Wunused-command-line-argument] clang: error: argument unused during compilation: '-fsanitize-coverage=trace-cmp' [-Werror,-Wunused-command-line-argument] To avoid the warning, check whether clang can handle this correctly or disallow ubsan and kcsan when kcov is enabled. Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Marco Elver <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Marco Elver <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://bugs.llvm.org/show_bug.cgi?id=45831 Link: https://lore.kernel.org/lkml/[email protected] Link: https://lkml.kernel.org/r/[email protected]
1 parent 37d1a04 commit ea91a1d

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lib/Kconfig.kcsan

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,20 @@
33
config HAVE_ARCH_KCSAN
44
bool
55

6+
config KCSAN_KCOV_BROKEN
7+
def_bool KCOV && CC_HAS_SANCOV_TRACE_PC
8+
depends on CC_IS_CLANG
9+
depends on !$(cc-option,-Werror=unused-command-line-argument -fsanitize=thread -fsanitize-coverage=trace-pc)
10+
help
11+
Some versions of clang support either KCSAN and KCOV but not the
12+
combination of the two.
13+
See https://bugs.llvm.org/show_bug.cgi?id=45831 for the status
14+
in newer releases.
15+
616
menuconfig KCSAN
717
bool "KCSAN: dynamic data race detector"
818
depends on HAVE_ARCH_KCSAN && DEBUG_KERNEL && !KASAN
19+
depends on !KCSAN_KCOV_BROKEN
920
select STACKTRACE
1021
help
1122
The Kernel Concurrency Sanitizer (KCSAN) is a dynamic

lib/Kconfig.ubsan

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,20 @@ config UBSAN_TRAP
2626
the system. For some system builders this is an acceptable
2727
trade-off.
2828

29+
config UBSAN_KCOV_BROKEN
30+
def_bool KCOV && CC_HAS_SANCOV_TRACE_PC
31+
depends on CC_IS_CLANG
32+
depends on !$(cc-option,-Werror=unused-command-line-argument -fsanitize=bounds -fsanitize-coverage=trace-pc)
33+
help
34+
Some versions of clang support either UBSAN or KCOV but not the
35+
combination of the two.
36+
See https://bugs.llvm.org/show_bug.cgi?id=45831 for the status
37+
in newer releases.
38+
2939
config UBSAN_BOUNDS
3040
bool "Perform array index bounds checking"
3141
default UBSAN
42+
depends on !UBSAN_KCOV_BROKEN
3243
help
3344
This option enables detection of directly indexed out of bounds
3445
array accesses, where the array size is known at compile time.

0 commit comments

Comments
 (0)