public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] kasan: remove hwasan-kernel-mem-intrinsic-prefix=1 for clang-14
@ 2023-04-14  8:29 Arnd Bergmann
  2023-04-14 16:26 ` Nathan Chancellor
  0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2023-04-14  8:29 UTC (permalink / raw)
  To: Andrey Ryabinin, Masahiro Yamada, Nathan Chancellor,
	Nick Desaulniers, Marco Elver
  Cc: Arnd Bergmann, Nicolas Schier, Alexander Potapenko,
	Andrey Konovalov, Dmitry Vyukov, Vincenzo Frascino, Tom Rix,
	Andrew Morton, Michael Ellerman, Peter Zijlstra (Intel),
	linux-kbuild, kasan-dev, linux-kernel, llvm

From: Arnd Bergmann <arnd@arndb.de>

Unknown -mllvm options don't cause an error to be returned by clang, so
the cc-option helper adds the unknown hwasan-kernel-mem-intrinsic-prefix=1
flag to CFLAGS with compilers that are new enough for hwasan but too
old for this option. This causes a rather unreadable build failure:

fixdep: error opening file: scripts/mod/.empty.o.d: No such file or directory
make[4]: *** [/home/arnd/arm-soc/scripts/Makefile.build:252: scripts/mod/empty.o] Error 2
fixdep: error opening file: scripts/mod/.devicetable-offsets.s.d: No such file or directory
make[4]: *** [/home/arnd/arm-soc/scripts/Makefile.build:114: scripts/mod/devicetable-offsets.s] Error 2

Add a version check to only allow this option with clang-15, gcc-13
or later versions.

Fixes: 51287dcb00cc ("kasan: emit different calls for instrumentable memintrinsics")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
There is probably a better way to do this than to add version checks,
but I could not figure it out.
---
 scripts/Makefile.kasan | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan
index c186110ffa20..2cea0592e343 100644
--- a/scripts/Makefile.kasan
+++ b/scripts/Makefile.kasan
@@ -69,7 +69,12 @@ CFLAGS_KASAN := -fsanitize=kernel-hwaddress \
 		$(instrumentation_flags)
 
 # Instrument memcpy/memset/memmove calls by using instrumented __hwasan_mem*().
+ifeq ($(call clang-min-version, 150000),y)
 CFLAGS_KASAN += $(call cc-param,hwasan-kernel-mem-intrinsic-prefix=1)
+endif
+ifeq ($(call gcc-min-version, 130000),y)
+CFLAGS_KASAN += $(call cc-param,hwasan-kernel-mem-intrinsic-prefix=1)
+endif
 
 endif # CONFIG_KASAN_SW_TAGS
 
-- 
2.39.2


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

end of thread, other threads:[~2023-04-18 12:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-14  8:29 [PATCH] kasan: remove hwasan-kernel-mem-intrinsic-prefix=1 for clang-14 Arnd Bergmann
2023-04-14 16:26 ` Nathan Chancellor
2023-04-14 18:53   ` Arnd Bergmann
2023-04-14 19:09     ` Nathan Chancellor
2023-04-18 12:06   ` Marco Elver
2023-04-18 12:28     ` Arnd Bergmann

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