Skip to contentSkip to conversation

kasan: remove hwasan-kernel-mem-intrinsic-prefix=1 for clang-14

PATCH In review Arnd Bergmann 3 participants 3 messages Apr 18, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 kasan: remove hwasan-kernel-mem-intrinsic-prefix=1 for clang-14

From: Arnd Bergmann <[email protected]>

Some unknown -mllvm options (i.e. those starting with the letter "h") 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")

---
v2: use one-line version check for both clang and gcc, clarify changelog text

---
 scripts/Makefile.kasan | 2 ++
 1 file changed, 2 insertions(+)
scripts/Makefile.kasan +2 -0
index c186110ffa20..390658a2d5b7 100644
@@ -69,7 +69,9 @@ CFLAGS_KASAN := -fsanitize=kernel-hwaddress \
 		$(instrumentation_flags)
 
 # Instrument memcpy/memset/memmove calls by using instrumented __hwasan_mem*().
+ifeq ($(call clang-min-version, 150000)$(call gcc-min-version, 130000),y)
 CFLAGS_KASAN += $(call cc-param,hwasan-kernel-mem-intrinsic-prefix=1)
+endif
 
 endif # CONFIG_KASAN_SW_TAGS
 
Signature · 1 line
2.39.2
Reviewed-by on v2 1/1
#1 lore raw
Quoted 15 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Some unknown -mllvm options (i.e. those starting with the letter "h") 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

Quoted 6 lines

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")

Thanks!

Quoted 24 lines

---
v2: use one-line version check for both clang and gcc, clarify changelog text

---
 scripts/Makefile.kasan | 2 ++
 1 file changed, 2 insertions(+)
scripts/Makefile.kasan +2 -1
index c186110ffa20..390658a2d5b7 100644
@@ -69,7 +69,9 @@ CFLAGS_KASAN := -fsanitize=kernel-hwaddress \
                $(instrumentation_flags)
 
 # Instrument memcpy/memset/memmove calls by using instrumented __hwasan_mem*().
+ifeq ($(call clang-min-version, 150000)$(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

maintainer Reviewed-by on v2 1/1
#2 lore raw
In reply to Arnd Bergmann
Quoted 14 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Some unknown -mllvm options (i.e. those starting with the letter "h") 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

Quoted 6 lines

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")

Kudos to Marco for figuring out the 'starting with the letter "h"' part of this issue :)

Quoted 23 lines

---
v2: use one-line version check for both clang and gcc, clarify changelog text

---
 scripts/Makefile.kasan | 2 ++
 1 file changed, 2 insertions(+)
scripts/Makefile.kasan +2 -0
index c186110ffa20..390658a2d5b7 100644
@@ -69,7 +69,9 @@ CFLAGS_KASAN := -fsanitize=kernel-hwaddress \
 		$(instrumentation_flags)
 
 # Instrument memcpy/memset/memmove calls by using instrumented __hwasan_mem*().
+ifeq ($(call clang-min-version, 150000)$(call gcc-min-version, 130000),y)
 CFLAGS_KASAN += $(call cc-param,hwasan-kernel-mem-intrinsic-prefix=1)
+endif
 
 endif # CONFIG_KASAN_SW_TAGS
 
Signature · 1 line
2.39.2