Announcement

Collapse
No announcement yet.

8cc: A Small C11 Compiler

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
    DrYak
    Senior Member

  • DrYak
    replied
    Security Application

    There's also a security-related application of this:
    - a very simple C compiler, is much more easy to code review compared to more performant but larger behemoths like GCC
    - thus it is easy to exclude compiler backdoors/attacks from it
    - on the other hand, by being C11, it's quite useful because it can compile a lot of modern code
    - you can therefore use it to do some deterministic compilation, differential compilation, etc.

    Leave a comment:

  • goTouch
    Phoronix Member

  • goTouch
    replied
    Originally posted by carewolf View Post
    ?? I do know the subject at hand. I was wondering what made this particular compiler interesting. The subject didn't sell it very well.
    It is still useful to see how a compiler can be created by example of simple code.
    It would be more interesting to see if someone write a tool to convert C/C++ to Rust, isolate unsafe from safe code.

    Leave a comment:

  • carewolf
    Senior Member

  • carewolf
    replied
    ?? I do know the subject at hand. I was wondering what made this particular compiler interesting. The subject didn't sell it very well.

    Leave a comment:

  • caligula
    Senior Member

  • caligula
    replied
    Originally posted by carewolf View Post
    The more interesting design choices comes up when you want good optimizations. For instance it is not hard to make an intermediate representation, the hard part is making one that can carry all the information of the source languages, can facilitate all the optimizations you have and can be efficiently and optimally converted to the target instruction set. This is usually not coverered by text-book because they don't deal with ugly real languages as C, or ugly real targets as x86.
    You can start with these books
    http://www.amazon.com/Compilers-Prin.../dp/0321486811
    http://www.amazon.com/Engineering-Co.../dp/012088478X
    http://www.amazon.com/Optimizing-Com.../dp/1558602860
    Agner Fog has x86 related information on his pages

    The books DO deal with Fortran and C. x86 isn't especially special unless you need to harness the full 100% of the arch power. E.g. I wouldn't call automatic parallelization a standard compilation technique yet. For what it's worth, the single core (non-VLIW, non-threaded) optimizations are pretty much covered by current books. If you have some crazy new optimization it's probably designed for dynamic languages, not C.

    Leave a comment:

  • carewolf
    Senior Member

  • carewolf
    replied
    Originally posted by caligula View Post
    Eh what? How are optimizations not from textbooks? You probably haven't ever written compilers. Most of the stages are pretty well documented. Unfortunately most textbooks like the dragon book focus mostly on parsing. The semantic stuff and backend stuff (especially for exotic architectures with prefetchers and VLIW) are more interesting. For parsing, you usually pick one of the main frameworks like parser generators or PEG. Now.. the language semantics is something that's more interesting. You can do it in so many ways and especially the modern functional languages prove their usefulness here.
    The more interesting design choices comes up when you want good optimizations. For instance it is not hard to make an intermediate representation, the hard part is making one that can carry all the information of the source languages, can facilitate all the optimizations you have and can be efficiently and optimally converted to the target instruction set. This is usually not coverered by text-book because they don't deal with ugly real languages as C, or ugly real targets as x86.

    Leave a comment:

  • caligula
    Senior Member

  • caligula
    replied
    Originally posted by carewolf View Post
    The optimizations is the interesting thing about compilers. Everything else is just textbook.
    Eh what? How are optimizations not from textbooks? You probably haven't ever written compilers. Most of the stages are pretty well documented. Unfortunately most textbooks like the dragon book focus mostly on parsing. The semantic stuff and backend stuff (especially for exotic architectures with prefetchers and VLIW) are more interesting. For parsing, you usually pick one of the main frameworks like parser generators or PEG. Now.. the language semantics is something that's more interesting. You can do it in so many ways and especially the modern functional languages prove their usefulness here.

    Leave a comment:

  • Michael_S
    Senior Member

  • Michael_S
    replied
    Originally posted by uid313 View Post
    Why not?
    What is wrong with the MIT License?
    Yeah, I don't understand that complaint at all. I prefer copyleft myself, but I'm still happy to use software licensed Apache, BSD, or MIT. Anything open source trumps proprietary by a million miles.

    Leave a comment:

  • opensource
    Phoronix Member

  • opensource
    replied
    Nice project. I like that "It's intended to support all C11 language features while keeping the code as small and simple as possible.".

    Leave a comment:

  • BradN
    Junior Member

  • BradN
    replied
    Originally posted by log0 View Post
    Ugh, static variables everywhere (yes it is a hobbyist project, but still...).
    Maybe it's just an optimization technique... you know, cuz the compiler won't do it for them.

    Leave a comment:

  • wizard69
    Senior Member

  • wizard69
    replied
    Originally posted by uid313 View Post
    Why not?
    What is wrong with the MIT License?
    It causes people to confront reality and the ugliness of GPL3.

    Leave a comment:

Working...
X