Stories
Slash Boxes
Comments

News for nerds, stuff that matters

Slashdot Log In

Log In

Create Account  |  Retrieve Password

GCC Compiler Finally Supplanted by PCC?

Posted by ScuttleMonkey on Mon Sep 17, 2007 11:03 AM
from the all-good-things-must-end dept.
Sunnz writes "The leaner, lighter, faster, and most importantly, BSD Licensed, Compiler PCC has been imported into OpenBSD's CVS and NetBSD's pkgsrc. The compiler is based on the original Portable C Compiler by S. C. Johnson, written in the late 70's. Even though much of the compiler has been rewritten, some of the basics still remain. It is currently not bug-free, but it compiles on x86 platform, and work is being done on it to take on GCC's job."
+ -
story

Related Stories

This discussion has been archived. No new comments can be posted.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More
Loading... please wait.
  • by RLiegh (247921) on Monday September 17 2007, @11:06AM (#20637571) Homepage Journal
    I notice that TFS doesn't say that anyone is actually able to compile anything (other than PCC) with it. The BSD folks would love to have a BSD-licensed drop-in replacement for GCC; but it doesn't sound like this is it. Not yet at least.

    Wake me up when you're able to use PCC instead of GCC to do a 'make world' (or ./build.sh or whatever).
    • Re: (Score:3, Insightful)

      ...Wake me up when you're able to use PCC instead of GCC to do a 'make bzImage'
    • Interesting... (Score:5, Insightful)

      by cromar (1103585) on Monday September 17 2007, @11:12AM (#20637669)
      I really don't see any point in implementing a new C compiler under the BSD lisence. There's no reason to duplicate effort: it's not like the compiled binaries would be under the GPL. And any GPL libraries you link to, you wouldn't need to distribute (thus avoiding the GPL). So, really, there's no point in duplicating effort on a BSD lisenced compiler. Correct me if I'm wrong.
      • Re:Interesting... (Score:5, Insightful)

        by everphilski (877346) on Monday September 17 2007, @11:20AM (#20637807) Journal
        Principle?

        I don't know, I'm not a BSD user, but as much as RMS likes to claim that 'linux' is GNU/linux, maybe BSD users want their OS to be self reliant?

        Would you like to compile Linux using a microsoft compiler? :)
        • Re:Interesting... (Score:5, Insightful)

          by Anonymous Coward on Monday September 17 2007, @11:29AM (#20637983)

          Would you like to compile Linux using a microsoft compiler? :)
          If it produced the best code, why not? People already compile Linux using the Intel compiler.

            • Re:Interesting... (Score:5, Interesting)

              by sunwukong (412560) on Monday September 17 2007, @11:51AM (#20638399)
              I believe it was de Raadt that once mentioned he'd prefer a non-optimizing compiler that produced simple, bullet-proof, bug-free code, i.e., in terms of the OS and its base tools, he prefers correct to fast.
              • by Anonymous Coward on Monday September 17 2007, @11:58AM (#20638547)
                And he continues to write code in C...why?
                • Re:Interesting... (Score:5, Interesting)

                  by j-pimp (177072) <jdeari01.longisland@poly@@edu> on Monday September 17 2007, @12:16PM (#20638923) Homepage Journal

                  And he continues to write code in C...why?

                  Auctually if I could write in C as well as him, I would do so more often. The problem is not him writing in C, its other people writing in C that are not as good as him. Do to the scope of his work, him writing in C does not lead to more bad C being written. So I'm auctually thankful he is coding in C.

                  That being said, he should encourage lesser programmers (including myself) to specifically not code in C.

                  • Re:Interesting... (Score:5, Insightful)

                    by Anonymous Coward on Monday September 17 2007, @01:36PM (#20640415)

                    I am the GPP, incidentally, and while I'm pleased I got modded up, I certainly wasn't going for funny :). I'm sorry, but C is just a poor choice for ensuring correctness.

                    First of all, open up your copy of the C standard (any of them will do) and grep for the phrase "undefined behaviour". C was standardized in a time when everyone and their dog had their own C compiler. Each C compiler did things in a different way, often in contradictory ways. The C standard came along and said "hey, you know what? You're ALL right". I'm being facetious, and the C standard has done a great job in promoting C, but the C standard has really not evolved very far in terms of guaranteeing semantics.

                    I don't mean to bring this up to say that "you can't write correct code" in C or such nonsense. Obviously it's easy with good habits (I recommend comp.lang.c as the best place to pick up these habits) to write conforming and well-defined code. But, if you're trying to verify code that's already been written, either by hand or via some automated tool like a static analyzer, it is painful.

                    The second problem with C is that it allows a lot of features that make verification of semantics difficult. Pointer aliasing, global variables (even "extern" global variables!!), etc. make static analysis dreadful. If you want to perform static analysis properly on C programs, it's hard to get around whole-program analysis, which is why no one uses static analysis with C code :). Seriously, what does C have beyond lint? How many people even use lint? It's not very useful.

                    Of course static analysis is not the end-all be-all of ensuring correct code. There's good coding habits and testing and profiling and whatnot too. But, I would argue that whatever effort can be put into verifying C code can be better put into code in other languages. The semantics of C are sometimes loosely defined, and very often far-reaching, preventing the use of modular reasoning. Whole-program analysis is not your friend.

                    What would be really cool is to see from someone like the OpenBSD crowd, if they're so keen on C, develop some verification tools that maybe only work on a very, very restricted subset of C. Any code which does not conform to this restricted "more easily verifiable" subset of C in the core OS would be rejected. I don't know how practical it would be, but it would be cool to see :). I mean as an academic, obviously I think we should all be using Z [wikipedia.org], but I understand this doesn't make good sense in a lot of real-world projects. But you want to get serious about correctness, don't pussy foot around: get serious about correctness.

              • Re:Interesting... (Score:4, Insightful)

                by Austerity Empowers (669817) on Monday September 17 2007, @01:05PM (#20639837)
                But modifying, even forking GCC is practical and rational, whereas making your own, new, compiler and supporting it for all eternity is not. I can understand much of the BSD bent on licenses, but in this case...I don't see it. Compilers are never "done", and writing one with a license that does not ensure other people's updates make it in is just ensuring that the author is perpetually supporting this himself.

                I can understand some applications having closed source licenses...but a compiler is a means, not an end...it really just seems painful.

          • Re:Interesting... (Score:4, Insightful)

            by Tim C (15259) on Monday September 17 2007, @11:47AM (#20638329)
            The GNU/Linux thing was kind of retarded given that Linux distributions feature code from a lot of different licenses, and GNU is the only one that's mentioned?

            The justification I've usually seen for that is that GNU is the single biggest "contributor", as it were, particularly with respect to gcc, the command tools, etc. More than just that, though, it could be argued that without GNU, Linux would just be a kernel, with no user space to run. Of course, it could equally be argued that without Linux, the GNU user space tools would just be a nice collection of tools with no OS to run on...
            • Re:Interesting... (Score:5, Insightful)

              by Omnifarious (11933) * on Monday September 17 2007, @12:13PM (#20638871) Homepage Journal

              The real reason that Stallman wants this is that he early on correctly perceived that Linus is totally ideology agnostic, and so he wanted to put the idea of GNU/Linux out there so people would talk about the ideology. I don't think this is bad or anything. I think the ideology needs to be heard more widely.

              It could also be argued that without the GNU project, Linus wouldn't have had a license ready to use for Linux, and I think that contribution by the GNU project weighs at least as much as all the userspace tools which someone would likely have eventually written anyway.

            • Re:Interesting... (Score:5, Insightful)

              by Nevyn (5505) * on Monday September 17 2007, @01:47PM (#20640607) Homepage Journal

              Let's at least get RMS's position right:

              Better idea, let's just get history correct.

              The GNU project was founded in 1984 to create a free operating system.

              Ok, true enough.

              In 1991, they were almost completely finished - they had written every essential component of a Unix-like operating system except for a kernel.

              Sure, and I've almost created a free engery device ... I've done everything apart from this one bit that creates energy for free. Also, GNU did not "create" everything else apart from the kernel ... they created some pieces and were doing the distribution work, so other people "donated" their work.

              Linus came along, wrote the Linux kernel,

              True enough.

              combined it with the almost-complete GNU system, and called the whole thing Linux.

              Not even close to true, Linux has only ever distributed the kernel ... other people combined it and called the whole things like "Red Hat Linux" or "Slackware Linux", GNU should/could have done this but had not bothered to do the work to make a usable distribution (as more than a collection of tarballs) and were happily ignoring Linux and telling everyone else to ignore it and use GNU-Hurd when it would be ready "any time now". This was pretty obvious naming at the time, we didn't call Solaris "GNU/Solaris" when we installed GCC, GNU-tar etc. on it.

              The GNU people were rightly upset that they were getting no credit for their work (to build a complete Unix-like OS).

              They got a huge amount of credit, for the work they did. They just didn't get their name in lights ... because they refused to do the work required for that. Then they complained and wanted more recognition than anyone else got who'd done the same amount of work as they had (like Perl or Xorg etc.) ... this created a "slight" backlash by people who actually know what happened.

      • "So, really, there's no point in duplicating effort on a BSD lisenced compiler. Correct me if I'm wrong."

        From the discussion of TFA:

        The licence is just the top of the iceberg [undeadly.org]

          • by Anonymous Conrad (600139) on Monday September 17 2007, @11:52AM (#20638401)

            The whole design of GCC is perverted so that someone cannot easily extract a front-end or back-end. This is broken by design, as the GPL people do believe this would make it easier for commercial entities to `steal' a front-end or back-end and attach it to a proprietary code-generator (or language).
            That's entirely wrong. RMS has been worried about this, and he (through the FSF who own the copyright) have previously objected to any patches that serialize the GCC's intermediate state for just this reason. (Although GCC's new link-time optimization work will change this.)

            GCC's intermediate formats GIMPLE and GENERIC are based on a research compiler, not a deliberate perversion. There's no technical steps to stop reuse, and indeed it has been done - Sun distribute the GCC 4.0.4 front-end altered to use their own SPARC code generator as a back-end.
          • by julesh (229690) on Monday September 17 2007, @11:53AM (#20638443)
            Well that explains a lot. And here I was thinking that all modern compilers were designed correctly with a front-end and back-end. So much for academics.

            Actually, the post you're replying to is total bollocks. GCC has had a clear divide between front and back end (not to mention a source-language independent middle layer for performing optimizations) since I first looked at it in about 1996. Each layer is hideously complex, but they are all there.
      • Re:Interesting... (Score:5, Interesting)

        by Anonymous Coward on Monday September 17 2007, @11:28AM (#20637951)
        It has less to do with the license and more to do with GCC's increasingly spotty support for some of the hardware platforms that NetBSD and OpenBSD run on. That and GCC internals are a maintenance nightmare, and its development process is getting even less commmunity-driven than it was before (which was never that much). Asking for a new compiler warning might take anywhere from a day to years just to get a response. The license is definitely gravy though.

        The BSD license that PCC is under, I understand, is actually a problem even to the BSD folks: PCC is actually extremely old (it was originally written for the PDP11!) and apparently it still carries the advertising clause.
      • Re:Interesting... (Score:4, Insightful)

        by Brandybuck (704397) on Monday September 17 2007, @11:33AM (#20638077) Homepage Journal
        Reason 1) Avoid a monoculture

        Reason 2) Competition

        Reason 3) Choice

        Reason 4) Tweak Stallman's nose
        • Re: (Score:3, Insightful)

          or
          3. they object to the restriction on their freedom?

          Look, I am a Linux user and Hacker, but even I understand BSD need to have their code be free.
    • Re: (Score:3, Insightful)

      With respect to

      "The BSD folks would love to have a BSD-licensed drop-in replacement for GCC"

      could somebody provide a reference to verify that "the BSD folks" do in fact have such a desire?

      Thanks!
      • by TheRaven64 (641858) on Monday September 17 2007, @11:46AM (#20638303) Homepage Journal
        This has been on Undeadly for a few days now. There was a very informative post by Marc Espie [undeadly.org] (who maintains GCC on OpenBSD) explaining this.

        This has been a long time coming. If you've ever looked at GCC code, you'll be familiar with the feeling of wanting to claw your eyes out (I had to for an article on the new Objective-C extensions *shudder*). I am somewhat surprised it's PCC not LLVM, but it makes sense. OpenBSD wants a C compiler in the base system, that can compile the base system and produces correct code. Support for C++, Objective-C, Java and Fortran would all be better off in ports. PCC is faster than GCC, smaller than GCC, more portable than GCC, easier to audit than GCC, and already compiles the OpenBSD userspace. I wouldn't be surprised if it replaces GCC in the OpenBSD base system soon. If it does, GCC (or maybe LLVM) will still probably be one of the first things I install from ports, but I'd still regard it as a good idea.

        • by synthespian (563437) on Monday September 17 2007, @01:26PM (#20640215)
          Here's the content (just so it stays in this Slashdot thread and gets archived here).

          Re: BSD Licensed PCC Compiler Imported (mod 21/25)
          by Marc Espie (213.41.185.88) (espie@openbsd.org) on Sun Sep 16 13:28:48 2007 (GMT)
                      > > I am saying think this through and carefully. Rewriting a giant suite of programs just because you don't agree with the philosophy behind it sounds awful to people who have no stakes in BSD licenses.
          >
          > It's not just the licence that is a concern about the GCC suite, it's dropping support for hardware that OpenBSD supports, it's fluctuating compilation quality and it's licence are all matters for concern to users.

          The licence is just the top of the iceberg.

          GCC is developed by people who have vastly different goals from us. If you go back and read the GCC lists, you'll notice several messages by me where I violently disagree with the direction it's following. Here is some *more* flame material.

          - GCC is mostly a commercial compiler, these days. Cygnus software has been bought by redhat. Most GCC development is done by commercial linux distributors, and also Apple. They mostly target *fast* i386 architectures and PowerPC. A lot of work has been done on specmarks, *but* the compiler is getting bigger and bigger, and slower and slower (very much so).

          - GCC warnings are not *really* useful. The -Wall flag shows many right things, and quite a few wrong issues.

          - There is a lot of churn in GCC which ends up with it no longer supporting some architectures that are still relevant to us.

          - The whole design of GCC is perverted so that someone cannot easily extract a front-end or back-end. This is broken by design, as the GPL people do believe this would make it easier for commercial entities to `steal' a front-end or back-end and attach it to a proprietary code-generator (or language). This is probably true. This also makes it impossible to write interesting tools, such as intermediate analyzers. This also makes it impossible to plug old legacy back-ends for old architectures into newer compilers.

          - As a result, you cannot have the new interesting stuff from newer GCC without also losing stuff... every GCC update is an engineering nightmare, because there is NO simple choice. You gain some capabilities, and you also lose some important stuff.

          - it's also very hard to do GCC development. Their branching system makes it very likely that some important work is falling between the cracks (and this happens all the time). If you develop code for GCC, you must do it on the most recent branch, which is kind of hard to do if your platform is currently broken (happens *all the time* if you're not running linux/i386). Even when you conform, it's hard to write code to the GNU coding standards, which are probably the most illegible coding guidelines for C. It's so obvious it was written by a lisp programmer. As a result, I've even lost interest into rewriting and getting in the GCC repository a few pieces.

          - some of their most recent advances do not have a chance to work on OpenBSD, like preparsed includes, which depend on mmap() at a fixed location.

          - there are quite a few places in GCC and G++ where you cannot have full functionality without having a glibc-equivalent around.

          - some of the optimisation choices are downright dangerous, and wrong for us (like optimizing memory fills away, even if they deal with crypto keys).

          - don't forget the total nightmare of autoconf/libtool/automake. Heck, even the GCC people have taken years to update their infrastructure to a recent autoconf. And GCC is *the only program in the ports tree* that actually uses its own libtool. Its configuration and reconfiguration fails abysmally when you try to use a system-wide libtool.

          I could actually go on for pages...

          I've actually been de facto maintainer of GCC on OpenBSD for a few years by now, and I will happily switch to another compiler, so frustrating has been the road with GCC.
  • Kind of depends... (Score:5, Insightful)

    by KingSkippus (799657) * on Monday September 17 2007, @11:07AM (#20637585) Homepage Journal

    ...and most importantly, BSD Licensed...

    Kind of depends on who you ask, doesn't it?

  • by gambolt (1146363) on Monday September 17 2007, @11:09AM (#20637621)
    OK, so it compiles C on x86. What do I use when I want to compile objective C on my microwave?
    • by Aladrin (926209) on Monday September 17 2007, @11:28AM (#20637961)
      This got modded funny, but I'm sure it deserves insightful instead.

      GCC compiles on a LOT of different architectures. Does PCC? Does it do as good a job at compiling? Can we plop our current GCC-compiled source on PCC and have it compile without huge headaches?

      And what about these bugs that are even referenced in the summary? How could it POSSIBLY supplant GCC if it's that buggy? In fact, how could it have supplanted GCC if it hasn't taken GCC's place AT ALL yet?

      Try these headlines:

      GCC Compiler Finally Has 'Free' Competition
      New Compiler To Supplant Gnu Compiler?
      Battle of the licenses: Does the license of your compiler MATTER AT ALL!?
      • by TheRaven64 (641858) on Monday September 17 2007, @11:51AM (#20638389) Homepage Journal

        Actually, support for different architectures is one of the main reasons OpenBSD is looking at it. GCC has a habit of dropping architectures because 'nobody uses them,' which causes some OpenBSD (and NetBSD) ports to remain stuck with old versions of GCC. The x86 backend for PCC was written in three weeks by one person, so it seems reasonable to assume it should be possible to add support for the other required platforms relatively easily.

        It's worth remembering that in BSD-land, things are divided into the base system and third party packages. The base system needs a C compiler that is capable of compiling the userland (which PCC already does for OpenBSD), is small, portable, and easy to audit. Packages have quite different requirements; they need support for more languages, etc. PCC is likely to replace GCC in the BSD base systems, but that doesn't mean that people won't install GCC or LLVM for compiling other things.

  • Quick! (Score:5, Funny)

    by perbu (624267) on Monday September 17 2007, @11:10AM (#20637639)
    Someone relicense it under the GPL!
  • Answer (Score:4, Insightful)

    by christurkel (520220) on Monday September 17 2007, @11:12AM (#20637665) Homepage Journal
    GCC Compiler Finally Supplanted by PCC?

    No. Next question.
  • by th0mas.sixbit.org (780570) on Monday September 17 2007, @11:12AM (#20637677)
    Seriously. Let's duplicate the wheel twice: once for GPL, once for BSD, and then bicker amongst ourselves. Stuff like this stands in the way of actual progress being made. Neither side is right, I don't have a solution, but this is just dumb.
    • by sinnergy (4787) on Monday September 17 2007, @11:16AM (#20637733) Homepage
      Your argument holds no water. If that were the case, one could make the same arguments about operating systems. Why bother developing Linux in an attempt to "keep up with the Jones'" when Windows already exists.

      I'm just sayin'...
            • by YU Nicks NE Way (129084) on Monday September 17 2007, @01:22PM (#20640135)
              No: taking the BSD license OFF the code drives us nuts. You're free to incorporate our code and give us no credit. We object if you take that right from a downstream user. If you dual license, you don't take that freedom away. If you replace the license, you do.

              We want to encourage people to use our code if it's the best code for the task. Period. You want to undermine copyright. Well, you're free to do that, but some of us don't think that's a good idea, and others of us don't think it's that important.
  • *yawn* (Score:5, Funny)

    by blackcoot (124938) on Monday September 17 2007, @11:13AM (#20637687)
    call me when pcc does something useful, like, say, working.
  • That's dumb. (Score:5, Interesting)

    by imbaczek (690596) <imbaczek AT poczta DOT fm> on Monday September 17 2007, @11:18AM (#20637775) Journal
    pcc will take YEARS to get the functionality and optimizations that gcc has. Even if it compiles slowly and sometimes generates dumb code.

    Either way, they'd much, much better off if they imported LLVM and redirected their compiler brain power to clang [llvm.org].
  • LLVM / clang (Score:5, Interesting)

    by sabre (79070) on Monday September 17 2007, @11:18AM (#20637787) Homepage
    PCC is interesting, but it's based on technology from the 70's, doesn't support a lot of interesting architectures, and has no optimizer to speak of.

    If you're interested in advanced compiler technology, check out LLVM [llvm.org], which is an ground up redesign of an optimizer and retargettable code generator. LLVM supports interprocedural cross-file optimizations, can be used for jit compilation (or not, at your choice) and has many other capabilities. The LLVM optimizer/code generator can already beat the performance of GCC compiled code in many cases, sometimes substantially.

    For front-ends, LLVM supports two major ones for C family of languages: 1) llvm-gcc, which uses the GCC front-end to compile C/C++/ObjC code. This gives LLVM full compatibility with a broad range of crazy GNU extensions as well as full support for C++ and ObjC. 2) clang [llvm.org], which is a ground-up rewrite of a C/ObjC frontend (C++ will come later) that provides many advantages over GCC, including dramatically faster compilation and better warning/error information.

    While LLVM is technologically ahead of both PCC and GCC, the biggest thing it has going is both size of community and the commercial contributors [llvm.org] that are sponsoring work on the project.

    -Chris
        • by IamTheRealMike (537420) on Monday September 17 2007, @11:39AM (#20638173) Homepage
          The reason they look increasingly extremist is because the FSF tends to make up policies and rules which bind GCC development in order to avoid the theoretical risk of making GPL violations easier. As compiler technology advances these restrictions have become increasingly burdensome, in particular, several of the technical advantages of LLVM are things the GCC team would have liked to do but RMS nixed because it would have made it too easy to circumvent the license.
  • by joe_n_bloe (244407) on Monday September 17 2007, @11:27AM (#20637929) Homepage
    Let me get this straight. A compiler that has been production-quality for over 15 years, compiles everything on every architecture, and has been continuously improved every minute of its existence needs to be replaced by ... Son of pcc? Because of a license?

    Sure, I prefer BSD-style licenses, and so do some other people, but what drives gcc development is the GNU license. I think I'll stick to the compiler that's debugged. Oh, that's right, I forgot, it comes with a debugger too. If you like that sort of thing.
    • by DreadSpoon (653424) on Monday September 17 2007, @12:26PM (#20639115) Homepage Journal
      The biggest reason for the new compiler (despite the jackass article submitter's position) is that GCC does *NOT* support every architecture. GCC drops architectures frequently as the core contributors lose interest, which hurts OSes like NetBSD that try to support more than the mainstream architectures. NetBSD relies on a combination of GCC 2, 3, and 4 to compile the OS on all of the architectures it supports.

      The idea with PCC is not that it will be BSD licensed (nobody really gives a fuck what license the compiler is under), but that it will be supported directly by the BSD community, including the NetBSD hackers who have their bazillion architectures to support.
    • by evilviper (135110) on Monday September 17 2007, @02:17PM (#20641129) Journal

      A compiler that has been production-quality for over 15 years, compiles everything on every architecture, and has been continuously improved every minute of its existence needs to be replaced by ... Son of pcc? Because of a license?

      You couldn't have gotten that statement any MORE WRONG if you had tried.

      GCC's "production quality" is an on-again, off-again thing. Through most of v3.x it had too many bugs to count, and was inherently unreliable. It couldn't even compile ITSELF with the most basic optimizations or the resulting binary would generate incorrect code. Up until v4 it also misaligned stack variable. It had, and still has, MANY bugs. That GCC successfully compiles code at all is almost entirely due to it being so popular that everyone knows it, and works around its bugs without even thinking about it.

      It has never had GOOD support for any other platforms than x86. Remember the RedHat GCC2.96 fiasco? They forked it because they needed it to support more platforms than it currently did. And even through v3.x the non-x86 ports of GCC had even more bugs than on x86, commonly falling apart if you attempt to use any optimizations. Now, they're DROPPING support for those platform entirely, which is a big problem for developers of operating systems for those platforms.

      "Improved" is pretty vague. HURD has probably been "improved" for every minute of it's existence as well... Meanwhile the far younger ICC (Intel's compiler) beats the pants off of GCC without even trying.

      What's more, GCC's "improvements" come at great cost. If you're a full-time developer, for the final release you want optimized code, but while developing, you want to compile and be able to test code frequently, and so as quickly as humanly possible. GCCv3+, even with all optimizations disabled, takes far, far longer to compile binaries than even older versions of GCC, and as it says, something like 10X slower than PCC.

      The license issue is only incidental. These (and other) problems pushed them away from using GCC. Since they happen to be BSD developers, they'd prefer their work to be BSD licensed, and so it is.
  • by DreadSpoon (653424) on Monday September 17 2007, @12:37PM (#20639321) Homepage Journal
    First: PCC has not YET supplanted GCC. The BSDs are hoping it will in the future.

    Second: The biggest attraction of PCC is NOT the license. The article submitter who stated otherwise is a jackass.

    Third: There are techical reasons why GCC is actaully unusable by some BSDs, such as NetBSD, which aims to support many architectures that GCC has dropped. NetBSD uses a combination of GCC 2, 3, and 4 to compile all of its different architectures. The NetBSD developers would rather have a single compiler that handles them all. Obviously PCC is nowhere near that level yet, of course.

    Fourth: GCC politics are a pain in the ass for many BSD developers who just want to submit patches to a compiler without the overhead of GNU's policies and GCC's management.

    Fifth: GCC produces crappy code more often than anyone would like. GCC bugs are far from unheard of, performance of generated code is often unpredictable between releases, and in many less commonly used architectures or sources GCC will produce incorrect code. Yes, these cases are very rare, but the BSD folks have hit the problem often enough for it to be a concern. PCC, being simpler and less bloated with cruft from multiple rewrites of the internals will hopefully produce correct and predictable code more often than GCC.

    Sixth: PCC actually works today. It can compile most of the NetBSD userspace, as I recall, and the kernel will be ready to roll soon after some inline assembler problems are fixed. This isn't some theoretical hacky project - it works right now. It's not ready to replace GCC just yet, by any means, but it's a lot more than some Slashdotters seem to think it is.
  • Think about it. Getting a new compiler into free UNIX and the open source community is going to be as hard as getting a new platform on the desktop to compete with Windows. And for similar reasons.

    You're not going to supplant GCC until you get all the code that depends on GCC-specific features modified to be standard portable C. That's a barrier to entry as steep as Microsoft's application barrier to entry. Now it's not as bad as it was in the early '90s when GCC was sprouting new C extensions everywhere (like the ability to have declarations not at the start of blocks, or the ability to leave the second element out of the trinary conditional operator, or things like alloca), and a lot of those features have now become common and even standardized (and others, like the shortcut trinary, have been deprecated). But it's not as easy as just having a good compiler, or even a good language translating ecosystem like Tendra... the playing field is anything but level.
    • Re: (Score:3, Insightful)

      Not really; you already have the sun and intel compilers for Linux (I've been told that the intel compiler has even been tweaked so you can build a bzImage with it).

      But you're still stuck with using glibc if you want to be able to compile anything. You do have different libcs floating around, uclibc, etc; but they're all gnu and they're all meant for embedded market. I doubt you'd be able to recompile the linux kernel with any of them.
    • Re:Why? (Score:5, Informative)

      by TheRaven64 (641858) on Monday September 17 2007, @11:56AM (#20638485) Homepage Journal
      License aside, the biggest benefit is that it's small. The OpenBSD (for example) base system is a self-contained operating system, including everything required to build it from source. It has the following requirements from its compiler:
      • Must compile C code (GCC does this).
      • Must support all of the platforms OpenBSD targets (GCC has a habit of dropping support for various platforms).
      • Must be easy to add new backends for new architectures (GCC makes this really hard).
      • Must be easy to audit for security (GCC is a tangled mess).
      Maybe a few I've missed. GCC is like Linux; it's a fairly good solution for a lot of problems, but it's rarely the best solution for any given problem. PCC is a better fit for the needs of the OpenBSD base system.
      • by Mr Z (6791) on Monday September 17 2007, @12:47PM (#20639525) Homepage Journal

        while the person you're responding to *is* a troll, I guess it's worth pointing out that GCC and other highly optimizing compilers will "break" some apps that a simpler compiler won't break. Why?

        Many optimizations rely on careful reading of the standard, and explicitly taking the liberties that the standard lets you take. For instance, the following loop terminates on a simple compiler, but becomes infinite on some optimizing compilers:

        int i = 1;

        while (i > 0)
        . . . i = i * 2;

        The ANSI C standard states specifically that signed integer overflow behavior is implementation defined. If you were expecting 'i' to go negative after 30 iterations, and for that to terminate the loop, you could be in for a nasty surprise.

        Suppose an application relied on this behavior, and now it misbehaves when compiled with GCC. Did GCC "break" that application? In some sense, yes: The app functions correctly with compiler (a) but not with compiler (b), so the app must be compiled with compiler (a). The breakage, however, happened because the application its not strictly conforming. It uses compiler dependent semantics, and that's hardly GCC's fault.

        Simpler compilers also don't reorder code as much, and don't optimize away as much "dead code." Stuff that really should have memory barriers, explicit synchronization and perhaps the volatile keyword applied to them run just fine without all those things when compiled with a simple compiler and run on a scalar, in-order CPU. The source code is also easier to read, because in the end the semantics are much more restricted--meaning the compiled output more closely resembles the source input. Give that code to a highly optimizing compiler, though, and run it on a super-scalar, out-of-order machine, and it'll break left, right and center. Is it the compiler's fault? Is it the CPU's fault? It's really the gap between the semantics the programmer thought he had (and happened to have in the simpler environment), and what C actually guarantees.

        Simpler compilers implement simpler semantics that are easier to understand, but only because they're compiling a very restricted form of C that offers way more implicit guarantees than the C standard actually does. Personally, unless that's made explicit (and therefore truly guaranteed forevermore by the compiler), I suspect it's actually a recipe for disaster. If nothing else, it could lead to code that's significantly harder to move to different platforms, since it'll start to rely on these simpler, "easier" semantics. Of course, then again, super-scalar out-of-order CPUs still strip a bunch of that away, so who knows, it might not be that bad.

        --Joe