Announcement

Collapse
No announcement yet.

8cc: A Small C11 Compiler

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #11
    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.

    Comment


    • #12
      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.

      Comment


      • #13
        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.

        Comment


        • #14
          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.

          Comment


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

            Comment


            • #16
              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.

              Comment


              • #17
                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.

                Comment

                Working...
                X