Re: linux: build failure: error: "__has_attribute" is not defined

From: Nick Desaulniers
Date: Wed Sep 15 2021 - 00:00:48 EST


On Tue, Sep 14, 2021 at 7:59 PM Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Tue, Sep 14, 2021 at 6:05 PM Tetsuo Handa
> <penguin-kernel@xxxxxxxxxxxxxxxxxxx> wrote:
> >
> > It would be nice if Makefile can also check gcc version used for building tools.
>
> I think the real problem is that the tool headers are cut-down from
> the real kernel headers, but not cut down enough, so they are still
> very complex, often with stuff that just isn't worth it in user space
> at all.
>
> And they _look_ like kernel headers - both in naming and in contents.
> But they really aren't.
>
> And it turns out there are two independent bugs here.
>
> Bug #1 is that the tool header files look _so_ much like the main
> kernel header files, that Nick thought that the
>
> #if GCC_VERSION >= 40300
>
> was about the compiler we compile the kernel with.
>
> But no, it's about the host compiler.
>
> Easy mistake to make when the naming is so similar and the contents
> are often also fairly closely related too.

No, I got that.

I don't get why you wouldn't keep those in sync, at least the minimum
supported compiler version for both. Sure, for cross compiling HOSTCC
and CC could be wildly different versions, but why should the minimum
supported version differ between the two?

Do we even document anywhere what's the lowest support compiler
version for tools/ or HOSTCC?

> But basically, commit 4e59869aa655 ("compiler-gcc.h: drop checks for
> older GCC versions") was buggy, because it took the kernel compiler
> version logic ("we require 5.1 to build the kernel") and applied it to
> the tooling header files too (we do _not_ require the kernel compiler
> for host tools).

That the minimum versions don't need to match between the two is
surprising to me. Probably to the reviewers of those patches, too.
--
Thanks,
~Nick Desaulniers