linux-toolchains.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Linus Torvalds <torvalds@linuxfoundation.org>
Cc: Florian Weimer <fweimer@redhat.com>,
	Nathan Chancellor <nathan@kernel.org>,
	Masahiro Yamada <masahiroy@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	clang-built-linux <clang-built-linux@googlegroups.com>,
	llvm@lists.linux.dev, linux-toolchains@vger.kernel.org
Subject: Re: [GIT PULL v2] Kbuild updates for v5.15-rc1
Date: Sat, 4 Sep 2021 14:15:31 -0500	[thread overview]
Message-ID: <20210904191531.GS1583@gate.crashing.org> (raw)
In-Reply-To: <CAHk-=wi+XKYN+3u=_fm=ExqpEaHdER0XuKxVauHYVCPKpKR97Q@mail.gmail.com>

On Sat, Sep 04, 2021 at 10:22:25AM -0700, Linus Torvalds wrote:
> On Sat, Sep 4, 2021 at 8:19 AM Florian Weimer <fweimer@redhat.com> wrote:
> > In any case, it would be nice to know what the real motivation is.
> 
> I don't know about the original motivation, but the reason I like that
> patch after-the-fact is that I've actually been in situations where I
> test out self-built compilers without installing them.

Then you probably know that that is quite hard to do correctly.  And
installing the compiler (into a temporary dir that you can just blow
away after you are done with it) is trivial (see for example
<https://gcc.gnu.org/install/finalinstall.html> line 11 or so).

Also, the standard headers are *part of* the compiler.  Including those
(like <stdarg.h> here) that are required for freestanding
implementations.

> Then it's convenient to have a completely standalone kernel tree.

Yes, and you certainly do not want to mix in anything userspace,
accidentally or not.  But these "freestanding" headers already have to
make sure they do not do that, and they are used by many OSes and
embedded-style things, so you can have some confidence that this
actually works.

And the C standard requires you to use these headers to use some
features of the C language (variable arguments in this specific case).
You can of course mimic whatever some implementation does and hope that
will work on some other implementations, and on future versions of that
first implementation as well.  But that is imo not a good idea, just
using the standard headers (which are required, and are there on all
implementations I have heard of, without bugs) is a much simpler idea,
much more future-proof, much less maintenance.

> Nobody cares about things like <stdatomic.h> They are completely
> irrelevant for the kernel, exactly because we've always just done our
> own, or used __builtin_xyz() for things.

The Linux kernel needs (or wants) stronger primitives than provided
there, yeah, so you could not even use it as the underlying
implementation for the semantics the kernel wants (which it could do
with <stdint.h> to implement u64 etc.)

> <stdarg.h> is the only actual core header file that we have always
> taken from the installed system headers - because historically it
> really was required. Everything else we can just do ourselves.

You also need <stdint.h> and <stddef.h>.  These are much simpler to
implement of course, but see for example the c46bbf5d2def commit I
mentioned before.  Some of these compiler headers might have been buggy
(or non-existent) historically, but that is very long ago, you really
can expect at least C99 to be there (and work correctly) nowadays :-)


Segher

  reply	other threads:[~2021-09-04 19:19 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAK7LNAQ0Q6CdXaD-dVGj_e3O3JYs_crpejWKpXHYQJYxyk-1VQ@mail.gmail.com>
     [not found] ` <CAHk-=wgoX0pVqNMMOcrhq=nuOfoZB_3qihyHB3y1S8qo=MDs6w@mail.gmail.com>
2021-09-03 23:04   ` [GIT PULL v2] Kbuild updates for v5.15-rc1 Nathan Chancellor
2021-09-04  8:01     ` Florian Weimer
2021-09-04 13:19       ` Segher Boessenkool
2021-09-04 15:19         ` Florian Weimer
2021-09-04 16:19           ` Segher Boessenkool
2021-09-04 17:22           ` Linus Torvalds
2021-09-04 19:15             ` Segher Boessenkool [this message]
2021-09-04 19:58               ` Linus Torvalds
2021-09-06 15:46                 ` Segher Boessenkool
2021-09-06 16:30                   ` Linus Torvalds
2021-09-06 17:27                     ` Segher Boessenkool
2021-09-06 18:11                       ` Linus Torvalds
2021-09-06 18:27                         ` Florian Weimer
2021-09-06 19:48                           ` Segher Boessenkool
2021-09-06 20:14                             ` Jakub Jelinek
2021-09-06 21:08                               ` Linus Torvalds
2021-09-06 21:24                                 ` Linus Torvalds
2021-09-07 14:41                                   ` Segher Boessenkool
2021-09-06 21:52                                 ` Jakub Jelinek
2021-09-06 22:24                                   ` Linus Torvalds
2021-09-07 15:26                                     ` Segher Boessenkool
2021-09-07 14:52                                   ` Segher Boessenkool
2021-09-09  5:14                                     ` Masahiro Yamada
2021-09-07 14:29                                 ` Segher Boessenkool
2021-09-06  6:54             ` Florian Weimer
2021-09-06 16:02               ` Alexey Dobriyan
2021-09-08  3:09                 ` Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210904191531.GS1583@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=clang-built-linux@googlegroups.com \
    --cc=fweimer@redhat.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-toolchains@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=torvalds@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).