[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wiiJ47YP7Q4AJC=YSfJdY-HK-8Bh7W=+hrZRqdM2UrAFg@mail.gmail.com>
Date: Tue, 14 Sep 2021 19:59:23 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Kees Cook <keescook@...omium.org>
Cc: Nathan Chancellor <nathan@...nel.org>,
Stephen Rothwell <sfr@...b.auug.org.au>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: linux: build failure: error: "__has_attribute" is not defined
On Tue, Sep 14, 2021 at 6:05 PM Tetsuo Handa
<penguin-kernel@...ove.sakura.ne.jp> 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.
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).
Now, arguably, commit 4eb6bd55cfb2 ("compiler.h: drop fallback
overflow checkers") has the exact same problem: it too ends up
changing both the kernel header files and the tooling header files.
But tooling really REALLY shouldn't be using those overflow macros, so
nobody should care.
Famous last words.
I think we should remove that "tools/include/linux/overflow.h" header
entirely. Yes, it is used - by tools/virtio/linux/kernel.h. But I
think that overflow handling code should be removed. It's just not
interesting in user tools.
Now, the _second_ bug was then that when Nathan fixed the tooling
header file in commit d0ee23f9d78b ("tools: compiler-gcc.h: Guard
error attribute use with __has_attribute"), he did it the wrong way.
The gcc docs are fairly clear about how to test for __has_attibute correctly:
https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fattribute.html
and a host build environment should probably have used
#if defined __has_attribute
# if __has_attribute (error)
...
and not used any version checks at all.
Of course, I'm not convinced it should do that __compiletime_error()
at all, and again, I think it would be better to remove the complexity
rather than anything else.
Anybody want to tackle those issues in
tools/include/linux/overflow.h
tools/include/linux/compiler-gcc.h
and try to simplify the code?
Linus
Powered by blists - more mailing lists