On 22/10/2025 10:01, Hesham Almatary wrote:
The CHERI port of Linux, similar to CheriBSD, now uses __has_feature() to check whether the compiler supports CHERI and provides the proper flags to enable it. However, __has_feature() only exists in Clang and recent versions of GCC. Building with older GCC versions that do not define this macro will cause the Linux build to fail.
This commit adds backward compatibility for such cases by defining __has_feature() to 0.
Signed-off-by: Hesham Almatary Hesham.Almatary@cl.cam.ac.uk
include/linux/compiler_types.h | 8 ++++++++ 1 file changed, 8 insertions(+)
Applied on morello/next, thanks!
- Kevin
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index f67fc7b9d..d92163333 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -11,6 +11,14 @@ #define __has_builtin(x) (0) #endif +/*
- __has_feature is supported in Clang and GCC >= 14.
- For older GCC versions, define __has_feature manually.
- */
+#ifndef __has_feature +#define __has_feature(x) 0 +#endif
#ifndef __ASSEMBLY__ /*