* [PATCH linux-next] tools: compiler-gcc.h: Keep compatible with older GCC versions
@ 2022-01-02 12:02 cgel.zte
2022-01-03 14:46 ` Alexander Lobakin
0 siblings, 1 reply; 3+ messages in thread
From: cgel.zte @ 2022-01-02 12:02 UTC (permalink / raw)
To: torvalds, nathan, ndesaulniers, keescook
Cc: wang.yong12, xu.xin16, linux-kernel, llvm, Zeal Robot
From: xu xin <xu.xin16@zte.com.cn>
When HOST CC = gcc (GCC) 4.8.5, we found that there is an error occurring:
Undefined __has_attribute as we built the whole kernel and tools.
To solve this, this patch is given to keep the compatibility with older
GCC versions.
Reported-by: Zeal Robot <zealci@zte.com.cn>
Co-developed-by: wangyong <wang.yong12@zte.com.cn>
Signed-off-by: xu xin <xu.xin16@zte.com.cn>
---
tools/include/linux/compiler-gcc.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/include/linux/compiler-gcc.h b/tools/include/linux/compiler-gcc.h
index 8816f06fc6c7..333ed16b3b12 100644
--- a/tools/include/linux/compiler-gcc.h
+++ b/tools/include/linux/compiler-gcc.h
@@ -16,6 +16,10 @@
# define __fallthrough __attribute__ ((fallthrough))
#endif
+#ifndef __has_attribute
+# define __has_attribute(x) 0 /* Compatibility with GCC versions < 5.x */
+#endif
+
#if __has_attribute(__error__)
# define __compiletime_error(message) __attribute__((error(message)))
#endif
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH linux-next] tools: compiler-gcc.h: Keep compatible with older GCC versions
2022-01-02 12:02 [PATCH linux-next] tools: compiler-gcc.h: Keep compatible with older GCC versions cgel.zte
@ 2022-01-03 14:46 ` Alexander Lobakin
2022-01-06 6:25 ` xu xin
0 siblings, 1 reply; 3+ messages in thread
From: Alexander Lobakin @ 2022-01-03 14:46 UTC (permalink / raw)
To: cgel.zte
Cc: Alexander Lobakin, torvalds, nathan, ndesaulniers, keescook,
wang.yong12, xu.xin16, linux-kernel, llvm, Zeal Robot
From: cgel.zte@gmail.com
Date: Sun, 2 Jan 2022 12:02:01 +0000
> From: xu xin <xu.xin16@zte.com.cn>
>
> When HOST CC = gcc (GCC) 4.8.5, we found that there is an error occurring:
^^^^^
From [0]:
Program Minimal version
GNU C 5.1
This applies to both HOSTCC and CC.
> Undefined __has_attribute as we built the whole kernel and tools.
>
> To solve this, this patch is given to keep the compatibility with older
> GCC versions.
>
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Co-developed-by: wangyong <wang.yong12@zte.com.cn>
> Signed-off-by: xu xin <xu.xin16@zte.com.cn>
> ---
> tools/include/linux/compiler-gcc.h | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/tools/include/linux/compiler-gcc.h b/tools/include/linux/compiler-gcc.h
> index 8816f06fc6c7..333ed16b3b12 100644
> --- a/tools/include/linux/compiler-gcc.h
> +++ b/tools/include/linux/compiler-gcc.h
> @@ -16,6 +16,10 @@
> # define __fallthrough __attribute__ ((fallthrough))
> #endif
>
> +#ifndef __has_attribute
> +# define __has_attribute(x) 0 /* Compatibility with GCC versions < 5.x */
> +#endif
> +
> #if __has_attribute(__error__)
> # define __compiletime_error(message) __attribute__((error(message)))
> #endif
> --
> 2.25.1
[0] https://elixir.bootlin.com/linux/v5.16-rc8/source/Documentation/process/changes.rst#L32
Al
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH linux-next] tools: compiler-gcc.h: Keep compatible with older GCC versions
2022-01-03 14:46 ` Alexander Lobakin
@ 2022-01-06 6:25 ` xu xin
0 siblings, 0 replies; 3+ messages in thread
From: xu xin @ 2022-01-06 6:25 UTC (permalink / raw)
To: alexandr.lobakin
Cc: cgel.zte, ndesaulniers, keescook, linux-kernel, llvm, nathan,
torvalds, xu.xin16
> GNU C 5.1
> This applies to both HOSTCC and CC.
> > Undefined __has_attribute as we built the whole kernel and tools.
> >
> > To solve this, this patch is given to keep the compatibility with older
> > GCC versions.
Yes, but I think this error is a little unfriendly to users using a
lower version of host GCC when cross compiling.
Perhaps "#if gcc_version > = 51000" could be added to avoid the error
'Undefined __has_attribute'
or we can add `#error "hostcc don't support _has_attribute` to remind
the user of the cause of the error.
Or just use my previous patch.
I hope we can do something here to promote the situation as Nathan talked
before:
https://lore.kernel.org/all/91B93D4D-BEC8-4ACD-B71F-27C54D8B1B78@kernel.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-06 6:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-02 12:02 [PATCH linux-next] tools: compiler-gcc.h: Keep compatible with older GCC versions cgel.zte
2022-01-03 14:46 ` Alexander Lobakin
2022-01-06 6:25 ` xu xin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).