Re: [clang] stack protector and f1f029c7bf

From: H. Peter Anvin
Date: Fri May 25 2018 - 07:56:27 EST


On 05/24/18 14:27, Nick Desaulniers wrote:
> https://godbolt.org/g/oku8ux
>
> Is there a more canonical way the kernel does feature detection that looks
> better than:
>

Hm. I though we had, but it doesn't seem so. For cc we only seem to be
able to detect flags. For as we have rules that can detect new
instructions; something similar in Kbuild would be good.

> diff --git a/arch/x86/include/asm/irqflags.h
> b/arch/x86/include/asm/irqflags.h
> index 89f08955fff7..90974b5d023c 100644
> --- a/arch/x86/include/asm/irqflags.h
> +++ b/arch/x86/include/asm/irqflags.h
> @@ -13,6 +13,8 @@
> * Interrupt control:
> */
>
> +#ifdef GCC_VERSION
> +#if GCC_VERSION < 40900

We don't actually test if GCC_VERSION is defined anywhere in the kernel.
We probably should explicitly define it to either 0 or some baseline
version if it is undefined. (Clang defines __GNUC__ so it will define
GCC_VERSION.)

-hpa