Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [PATCH] overflow: disable failing tests for older clang versions
@ 2022-10-05 22:21 Nick Desaulniers
  2022-10-06  5:17 ` kernel test robot
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Desaulniers @ 2022-10-05 22:21 UTC (permalink / raw)
  To: Kees Cook
  Cc: Nathan Chancellor, Tom Rix, Daniel Latypov, Gwan-gyeong Mun,
	Gustavo A. R. Silva, linux-kernel, llvm, Nick Desaulniers

Building the overflow kunit tests with clang-11 fails with:

$ ./tools/testing/kunit/kunit.py run --arch=arm --make_options LLVM=1 \
overflow
...
ld.lld: error: undefined symbol: __mulodi4
...

Clang 11 and earlier generate unwanted libcalls for signed output,
unsigned input.

Disable these tests for now, but should these become used in the kernel
we might consider that as justification for dropping clang-11 support.
Keep the clang-11 build alive a little bit longer.

Avoid -Wunused-function warnings via __maybe_unused.

Link: https://github.com/ClangBuiltLinux/linux/issues/1711
Link: https://github.com/llvm/llvm-project/commit/3203143f1356a4e4e3ada231156fc6da6e1a9f9d
Reported-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 lib/overflow_kunit.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/lib/overflow_kunit.c b/lib/overflow_kunit.c
index f385ca652b74..d035768ed734 100644
--- a/lib/overflow_kunit.c
+++ b/lib/overflow_kunit.c
@@ -254,6 +254,7 @@ static void do_test_ ## n(struct kunit *test, const struct test_ ## n *p) \
 	check_one_op(t, fmt, mul, "*", p->b, p->a, p->prod, p->p_of);	\
 }									\
 									\
+__maybe_unused								\
 static void n ## _overflow_test(struct kunit *test) {			\
 	unsigned i;							\
 									\
@@ -716,12 +717,23 @@ static struct kunit_case overflow_test_cases[] = {
 	KUNIT_CASE(u32_u32__u32_overflow_test),
 	KUNIT_CASE(s32_s32__s32_overflow_test),
 /* Clang 13 and earlier generate unwanted libcalls on 32-bit. */
-#if BITS_PER_LONG == 64
+#if defined(CONFIG_CC_IS_GCC) || \
+	(defined(CONFIG_CC_IS_CLANG) && \
+		(__clang_major__ > 13 || BITS_PER_LONG == 64))
 	KUNIT_CASE(u64_u64__u64_overflow_test),
 	KUNIT_CASE(s64_s64__s64_overflow_test),
 #endif
-	KUNIT_CASE(u32_u32__u8_overflow_test),
+/*
+ * Clang 11 and earlier generate unwanted libcalls for signed output, unsigned
+ * input.
+ * https://github.com/llvm/llvm-project/commit/3203143f1356a4e4e3ada231156fc6da6e1a9f9d
+ */
+#if defined(CONFIG_CC_IS_GCC) || \
+	(defined(CONFIG_CC_IS_CLANG) && \
+		(__clang_major__ > 11 || BITS_PER_LONG == 64))
 	KUNIT_CASE(u32_u32__int_overflow_test),
+#endif
+	KUNIT_CASE(u32_u32__u8_overflow_test),
 	KUNIT_CASE(u8_u8__int_overflow_test),
 	KUNIT_CASE(int_int__u8_overflow_test),
 	KUNIT_CASE(shift_sane_test),

base-commit: 833477fce7a14d43ae4c07f8ddc32fa5119471a2
-- 
2.38.0.rc1.362.ged0d419d3c-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-10-06 23:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-05 22:21 [PATCH] overflow: disable failing tests for older clang versions Nick Desaulniers
2022-10-06  5:17 ` kernel test robot
2022-10-06 17:17   ` [PATCH v2] " Nick Desaulniers
2022-10-06 22:58     ` Kees Cook
2022-10-06 23:01       ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox