Index Home About Blog
From: Al Viro <viro@ZenIV.linux.org.uk>
Newsgroups: fa.linux.kernel
Subject: Re: [rfc] built-in native compiler for Linux?
Date: Mon, 27 Apr 2009 17:34:44 UTC
Message-ID: <fa.ECrRs+sZyGWtUVwBxLGIVlnQPC0@ifi.uio.no>

On Mon, Apr 27, 2009 at 09:52:46AM -0400, Christoph Lameter wrote:
> On Sat, 25 Apr 2009, Eric W. Biederman wrote:
>
> > If this was about teaching sparse to run lockdep at compile time, or
> > generally about making the kernel compilation much faster and able to
> > catch many more bugs there might be a point where the effort is worth
> > the investment.
>
> The preprocessor and its interaction with regular C code is quite
> nasty. If sparse could get rid of the complexities and idiosyncrasies at
> that level then it may be useful as a "pre" compiler.

Explain, please.  BTW, at the risk of being called an elitist bastard, could
I ask the participants of that thread to read C99 standard?  It's not hard
to find (http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf, for one
thing - that's C99 + errata) and at least chapter 5 and 6.10 are really
must-read if we are talking about that stuff.

In particular, C preprocessor does *NOT* work on text-to-text level and
hasn't since way back.  It works on token stream.

That's actually one of the areas where C99 is a huge improvement over
earlier language - instead of more or less nasty kludges still trying
to pretend that preprocessor was a filter with text output piped into
compiler, it gives reasonably clear semantics approximating what the
earlier variants had in common.

I'd done fairly complete rewrite of macro expansion (and a bunch of other
places in preprocessor) in sparse, and places where it used to deviate from
standard were by far the worst in terms of convoluted logics and corner
cases.  Switching to what C99 asked had simplified the things a *lot*;
it's surprisingly well thought through in that area (unlike e.g. the unholy
mess around 'restrict' qualifier semantics).

Index Home About Blog