[rfc] built-in native compiler for Linux?




* Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

I think it was Ingo that let out the idea, and I'm starting to
like it.

Perhaps we should fork off gcc and ship Linux with its own
compiler. This way we can optimize it for the kernel and not worry
about any userland optimizations.

I didnt suggest forking GCC. A kernel-special GCC would likely just
become an inferior fork of GCC over time and would fizzle out.
There's 100 times more user-space code than kernel-space code and
GCC is too large and too legacy-laden to really be appropriate for
that purpose.

What i think makes sense is to build a _new_ precompiler / compiler
/ assembler / linker combo for Linux, from scratch, hosted in the
kernel proper.

In the past 15 years of Linux we've invested a lot of time and
effort into working around and dealing with compiler crap. We wasted
a lot of opportunities waiting years for sane compiler features to
show up. We might as well have invested that effort into building
our own compiler and could stop bothering about externalities. The
Linux kernel project certainly involves the right kind of people who
could make something like this happen.

A good technical basis for that would be Sparse, and it could start
by acting as a drop-in replacement for CPP and it could feed its
output to GCC with little changes. Sparse is small, has a very tidy
code base and is already useful today as an extended static source
code checker.

The Sparse codebase could move into the kernel proper, under
linux/sparse/ or so - so the preprocessor/compiler and the kernel
could be in precise feature and bugfix lock-step with no artificial
external synchronization.

We have a lot of annoying preprocessor limitations that Sparse could
help with straight away. We'd also get Sparse type checking by
default. So it's helpful even without any code generator support.

Then, if this model works out, we could experiment with adding a
code generator backend to Sparse. I think Jeff Garzik experimented
with that in the past with some surprisingly quick (but incomplete)
results.

Since most of the performance-critical code in Linux is
hand-optimized already, we dont even need all that many complex,
exotic optimizations - we want to encourage common-sense coding
practices. Furthermore, a lot of optimizations in GCC are driven by
SPECint and SPECfp benchmarketing, with little practical relevance
to 99% of the apps, including the kernel.

There would always be an 'output to GCC' kind of compatible build
channel as well, for CPU architectures that dont have native code
generator support yet. We'd also do that to generally keep our
options open, in case we are wrong about it all or in case some even
better compiler project pops up.

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • [RFC][PATCH-2.6] Clean up and merge compiler-*.h
    ... the kernel headers in include/linux to include/linux-abi. ... * Common definitions for all gcc versions go here. ... -/* Some compiler specific definitions are overwritten here ...
    (Linux-Kernel)
  • Re: Testing ham radio software on Sun hardware.
    ... Is that like the way Micro$oft adheres to the W3C standards? ... It sometimes means code built with gcc will not compile on better compilers. ... The other issue is that people often write code that works on Linux, but makes use of Linux specific header files. ... If anyone has some open-source UNIX or Linux code they would like to test on a Sun, using a commercially produced C compiler, let me know. ...
    (uk.radio.amateur)
  • Re: how to install ruby in home folder ?.
    ... i am using linux ubuntu 7.04. ... configure:1892: checking build system type ... configure:2245: checking for gcc ... configure:2563: checking for C compiler default output file name ...
    (comp.lang.ruby)
  • Re: Linux distro request
    ... ZipSlack was my first introduction to Linux. ... Smart Boot Manager?? ... earlier kernel that will be easier on memory. ... more to gcc than gcc! ...
    (alt.lang.asm)
  • Re: Use of C99 int types
    ... > those that actually are part of the C-implementation for Linux. ... the kernel definitions are part of /usr/include). ... The kernel uses __foobar stuff provided by the compiler because it has ... > the Gimp and GCC run on completely different architectures aswell. ...
    (Linux-Kernel)