Re: [PATCH] compiler.h: Avoid the usage of __typeof_unqual__() when __GENKSYMS__ is defined

From: Masahiro Yamada
Date: Fri Apr 04 2025 - 08:56:24 EST


On Fri, Apr 4, 2025 at 7:25 PM Uros Bizjak <ubizjak@xxxxxxxxx> wrote:
>
> Current version of genksyms doesn't know anything about __typeof_unqual__()
> operator. Avoid the usage of __typeof_unqual__() with genksyms to prevent
> errors when symbols are versioned.
>
> There were no problems with gendwarfksyms.
>
> Signed-off-by: Uros Bizjak <ubizjak@xxxxxxxxx>
> Fixes: ac053946f5c40 ("compiler.h: introduce TYPEOF_UNQUAL() macro")
> Reported-by: Paul Menzel <pmenzel@xxxxxxxxxxxxx>
> Closes: https://lore.kernel.org/lkml/81a25a60-de78-43fb-b56a-131151e1c035@xxxxxxxxxxxxx/
> Cc: Sami Tolvanen <samitolvanen@xxxxxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> ---


Why don't you add it to the genksyms keyword table?


diff --git a/scripts/genksyms/keywords.c b/scripts/genksyms/keywords.c
index b85e0979a00c..901baf632ed2 100644
--- a/scripts/genksyms/keywords.c
+++ b/scripts/genksyms/keywords.c
@@ -17,6 +17,7 @@ static struct resword {
{ "__signed__", SIGNED_KEYW },
{ "__typeof", TYPEOF_KEYW },
{ "__typeof__", TYPEOF_KEYW },
+ { "__typeof_unqual__", TYPEOF_KEYW },
{ "__volatile", VOLATILE_KEYW },
{ "__volatile__", VOLATILE_KEYW },
{ "__builtin_va_list", VA_LIST_KEYW },






> include/linux/compiler.h | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/compiler.h b/include/linux/compiler.h
> index 27725f1ab5ab..98057f93938c 100644
> --- a/include/linux/compiler.h
> +++ b/include/linux/compiler.h
> @@ -229,10 +229,10 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
> /*
> * Use __typeof_unqual__() when available.
> *
> - * XXX: Remove test for __CHECKER__ once
> - * sparse learns about __typeof_unqual__().
> + * XXX: Remove test for __GENKSYMS__ once "genksyms" handles
> + * __typeof_unqual__(), and test for __CHECKER__ once "sparse" handles it.
> */
> -#if CC_HAS_TYPEOF_UNQUAL && !defined(__CHECKER__)
> +#if CC_HAS_TYPEOF_UNQUAL && !defined(__GENKSYMS__) && !defined(__CHECKER__)
> # define USE_TYPEOF_UNQUAL 1
> #endif
>
> --
> 2.49.0
>
>


--
Best Regards
Masahiro Yamada