Slashdot Mirror


FreeBSD 10 To Use Clang Compiler, Deprecate GCC

An anonymous reader writes "Shared in last quarter's FreeBSD status report are developer plans to have LLVM/Clang become the default compiler and to deprecate GCC. Clang can now build most packages and suit well for their BSD needs. They also plan to have a full BSD-licensed C++11 stack in FreeBSD 10." Says the article, too: "Some vendors have also been playing around with the idea of using Clang to build the Linux kernel (it's possible to do with certain kernel configurations, patches, and other headaches)."

41 of 711 comments (clear)

  1. What's wrong with GCC? by jomcty · · Score: 5, Interesting

    What's wrong with GCC?

    1. Re:What's wrong with GCC? by jps25 · · Score: 5, Informative

      The GPL.

    2. Re:What's wrong with GCC? by vlm · · Score: 4, Informative

      Aside from the more or less irrelevant licensing issue, clang is all about the source analysis tools, refactoring, rewriting support. Uses less memory and time. Both caused by lack of optimization.

      --
      "Science flies us to the moon. Religion flies us into buildings." - Victor Stenger
    3. Re:What's wrong with GCC? by bonch · · Score: 5, Informative

      Clang and FreeBSD aren't proprietary software. They're BSD-licensed open source. That code doesn't magically disappear when a company uses it.

    4. Re:What's wrong with GCC? by BasilBrush · · Score: 5, Informative

      Avoiding te GPL is the main reason. But Clang also has many technical superiorities to GCC too. Wikipedia gives a quick outline of them.
      http://en.wikipedia.org/wiki/Clang

    5. Re:What's wrong with GCC? by Alex+Belits · · Score: 5, Interesting

      And WHY would a company want to avoid GPL compiler, unless it intends to distribute a sabotaged version of the compiler?

      --
      Contrary to the popular belief, there indeed is no God.
    6. Re:What's wrong with GCC? by beelsebob · · Score: 4, Informative

      1) It compiles slower than clang at -O0
      2) It produces slower code than clang at -O3 and -Os
      3) It's error and warning messages are not as good
      4) It's not as modular as clang, which can be used in parts, to produce useful tools like CSA
      5) The GPL.

    7. Re:What's wrong with GCC? by Fred+Ferrigno · · Score: 4, Insightful

      The derivative works companies build using BSD-licensed software are effectively proprietary software. And if they control the hardware, they can make sure it only runs binaries signed by them, so you can't even run the original unmodified code.

    8. Re:What's wrong with GCC? by Pinky's+Brain · · Score: 4, Insightful

      The GPL has never really been the issue, LLVM was offered for GPL-Next ... but the GCC maintainers have always insisted upon a monolithic compiler without standardized intermediary representations to prevent other compiler builders just using GCC as a front end and thus refused, but that's on the maintainers and not the GPL.

    9. Re:What's wrong with GCC? by bonch · · Score: 4, Interesting

      After all these years of BSD code existing and thriving without issue, it's amazing that people still spread this kind of fearmongering despite the fact that this scenario has never come true.

      The original code and its contributors don't magically disappear the moment a company makes a closed change. And if a company makes contributions it doesn't show anyone, you're free to make your own open contribution that competes with it. In fact, it's in company's best interests to rely on open contributions, because they don't want to waste time and manpower on, say, maintaining a compiler. This has proven to be the case with Clang. There hasn't been some evil proprietary fork that somehow ruined the world--and even if there was, people would just contribute free versions of the fork's features to the main tree. Companies are smart enough to know that this would happen and therefore realize that closed contributions of major features would be wasted effort.

    10. Re:What's wrong with GCC? by rubycodez · · Score: 4, Informative

      the topic of this thread is "What's Wrong With GCC?", not "What's Wrong with the GPL"

    11. Re:What's wrong with GCC? by ommerson · · Score: 5, Informative

      One of the key design objectives of Clang is that it is highly modular, and implemented in such a way that various compilation stages are self-contained, and have clean APIs and data structures. This allows development tools such as IDEs to link directly against the stages of the compilation pipeline then need to implement syntax highlighting, code completion, refactoring tools and so on.

      Apple's XCode does precisely this, and licensing and lack of modularity in the GCC source tree would have been major factors in their choice to support Clang and LLVM development.

      The traditional way of implementing these functions in IDEs has been to effectively re-implement the front-end of the compiler (often not completely). This is a big deal when developing in C++ against the STL/Boost/TR1 when you find that code completion can't grok template properly. This is something that XCode and Visual Studio (which takes a similar approach) are both capable of doing.

    12. Re:What's wrong with GCC? by ommerson · · Score: 4, Insightful

      Precisely who do you think has done a lot of the development on Clang/LLVM over the last few years and contributed it to the wider community?

    13. Re:What's wrong with GCC? by zixxt · · Score: 5, Informative

      1) It compiles slower than clang at -O0
      2) It produces slower code than clang at -O3 and -Os
      3) It's error and warning messages are not as good
      4) It's not as modular as clang, which can be used in parts, to produce useful tools like CSA
      5) The GPL.

      Got facts to back this up? Every benchmark I have seen as showed GCC producing faster code than Clang on 90% of the time, Phoronix benchmarks has in the last week showed this to be true.

      --
      ---- GENERATION 26: The first time you see this, copy it into your sig on any forum and add 1 to the generation.
    14. Re:What's wrong with GCC? by TheRaven64 · · Score: 4, Informative

      I'm just on my way back from BSDCan and the FreeBSD DevSummit. At the DevSummit, there was a Vendor Summit, for companies that use FreeBSD in their products. Not all were there (Sony, for example, was absent), but companies like Fusion IO, Yahoo, IX Systems, Juniper, Apple, and so on all sent people. There were about 40 companies represented in total, for a developer meeting with about 70 attendees.

      --
      I am TheRaven on Soylent News
    15. Re:What's wrong with GCC? by hairyfeet · · Score: 5, Insightful

      I normally don't respond to ACs but this is one thing I've noticed and found interesting....anybody notice how the Anti-BSD GPLers sound a HELL of a lot like the RIAA? Both act as if copying is stealing, both come up with these giant FUD scenarios of doom which never seem to happen, and both act as if THEIR way is the only 'right" choice and frankly you are an idiot or "one of THEM!" if your views don't stay in lock step with their own.

      I just find it fascinating that those that constantly scream they are for "freedom" sound a hell of a lot like the most restrictive bunch out there.

      --
      ACs don't waste your time replying, your posts are never seen by me.
  2. in other words by phantomfive · · Score: 4, Insightful

    and suit well for their BSD needs

    In other words, it has the license they want. GCC was a thorn in the side of the collective BSD conscience, they didn't like it.

    --
    "First they came for the slanderers and i said nothing."
    1. Re:in other words by bonch · · Score: 5, Interesting

      One of the FreeBSD developers gave a talk about this. FreeBSD has commercial users, and the new GCC just wouldn't have been an option for them. The older license-compatible version still in FreeBSD wasn't receiving updates, and it was beginning to affect developers too greatly.

      Whether this compiler switch is a good thing or not depends on how much you hate the idea of commercial vendors using open source. GCC's strictness is admiral from an ideological perspective, but certainly not from a practical one. It should be noted that even Linus Torvalds adheres to a more pragmatic worldview:

      There are "extremists" in the free software world, but that's one major reason why I don't call what I do "free software" any more. I don't want to be associated with the people for whom it's about exclusion and hatred.

      It's pretty damning when Linus himself no longer refers to Linux as free software because he doesn't like the extremism of the free software movement. And why should he? He's an engineer, not a religious fundamentalist.

    2. Re:in other words by cupantae · · Score: 5, Insightful

      It's not quite as simple as that. The development of Clang is being funded by Apple. They need a BSD license so that they have the freedom to make further modifications down the line (without leaving them open). Yes, I'm a GPL advocate. No, I don't agree with Apple's ideology. But it's the case anyway.

      In any case, it doesn't do us any harm to have an underdog in the world of open source C compilers. If you only have one option, then people start treating even the programme's eccentricities as standards. The need for compatibility encourages people to document. Not to mention that the different attitude taken in Clang from the offset means that it may be more suitable for certain applications. This page makes for some interesting reading.

      --
      --
  3. GPLv3 by bonch · · Score: 5, Insightful

    Having all this great open source compiler technology competing with each other is great, but one does wonder if the alienation caused by GPLv3 was worth it, as it is the primary reason both Apple and FreeBSD embraced Clang (in fact, Apple started the Clang project). As a result, GCC wasn't updated past GPLv2 on either platform. Apple couldn't integrate GCC with their IDE like they wanted, nor could FreeBSD's commercial clients work with it. Flexibility and pragmatism usually wins out over rigidness and ideology.

  4. Re:Code quality will suffer by bonch · · Score: 4, Interesting

    I've heard positive and negative claims regarding this. Certainly, Apple thinks it's production-ready (I think it was Xcode 4.2 that they stopped shipping GCC). Do you have a link showing that generated code is significantly worse? Which versions were compared?

  5. Linux dev's experimenting with LLVM/Clang too by perpenso · · Score: 4, Informative

    What's wrong with GCC?

    Some people argue that LLVM/Clang offers better code generation, compile time warnings, and code analysis. Some compiler developers think the gcc code has become too bloated and complicated. Even gcc devs have described the gcc code as "cumbersome".

    There are various efforts to get Linux building under LLVM/Clang. Especially for embedded environments.

  6. Re:deliberately obscured internals by Stallman et. by dragisha · · Score: 4, Interesting

    Stallman and others deliberately fought having APIs, proper documentation and to allow plugins for all parts of the GCC toolchain, to keep control of the thing.

    Mostly result of dispute with DEC SRC when GCC and parent FSF failed to enforce GPL on Modula-3. Moving target known as GCC internals has been problem ever since, mostly to "legitimate" GNU compiler developers.

    LLVM, on the other hand, made ingenious move with standard and open IR. Overall modular design is another boon.

    GCC was in blind alleys before. No real reason for them not to survive this one. Another EGC can happen, to pull GCC in future.

    --
    http://opencm3.net, http://www.nongnu.org/gm2/
  7. Not a bad idea by gman003 · · Score: 5, Insightful

    I've found that code that will compile properly under a variety of compilers tends to be of better quality.

    One of my current projects started out on an old 2.x branch of GCC. When I finally got around to updating to a current GCC, I had to fix quite a few bugs before it would actually work - the different compiler was catching problems I hadn't noticed before.

    Same when I tried compiling it under Visual Studio, or Clang - the more compilers I made it work under, the less bugs there were in the code.

    Now, if a given program actually uses some special feature of GCC, that's fine - if only one compiler will do what you need, that's fine. Or if it's too much work to maintain a "port" - I stopped maintaining the VS project files a while ago, since I no longer used it. But if you have a chance to at least test it against a different compiler, go ahead and give it a shot.

    1. Re:Not a bad idea by rubycodez · · Score: 4, Informative

      Linux depends on gcc-specific extensions, and not just typedefs but exact layout in memory (which C doesn't specify), in-line assembly syntax http://www.ibm.com/developerworks/linux/library/l-gcc-hacks/

  8. Gotta clang 'em all by tepples · · Score: 4, Funny

    But Clang also has many technical superiorities to GCC too. Wikipedia gives a quick outline of them.
    http://en.wikipedia.org/wiki/Clang

    And at the top right of that page is this picture. Which Pokemon is that?

  9. Gcc falls short on some technical merits by perpenso · · Score: 4, Interesting

    ... Which is hilarious because it is the BSD fundamentalists who are re-implementing huge projects just to avoid a license they don't like for no reason other than political correctness ...

    Untrue. Gcc is handicapped by political decisions in it technical design. It intentionally does not allow "others" to plug into some "internals". "Internals" that would facilitate other tool builders, especially those creating a graphical integrated development environment.

    LLVM/Clang doesn't come with such technical baggage. Its modular rather than monolithic. It is a newer code base that is far easier to work with, even gcc devs moan about the bloat/complexity of their code base. Nearly all long lived project reach a point where it is better to toss the legacy code out and start from scratch, gcc may have very well surpassed that point.

    And on some platforms LLVM/Clang simply generates better code.

  10. Re:Dropping the GPL ~= worse. by itsdapead · · Score: 4, Insightful

    Complaining about the GPL is like complaining that you can't play dirty pool with code licensing(see Tivoization).

    I haven't heard Apple complaining about the GPL or trying to circumvent it - they're just switching to alternative projects.

    Of course, its a pity, because even if if you Tivoized GPLv2 code you still had to share your source so people could learn from it, or use and modify it on other (or jailbroken) hardware, whereas now people are moving to BSD-style licenses with no such benefits... but if the FSF want to let the perfect be the enemy of the good, declare jihad on Tivoization and have a tilt at the patent windmill, that is their right.

    --
    In a survey of 100 programmers, 111111 thought that duck-typing was a good idea.
  11. Re:Dropping the GPL ~= worse. by mister_playboy · · Score: 5, Informative

    There's a reason even the shining monument of GPL (Linux) uses GPLv2...

    Even if Linus did want to move the kernel to GPLv3 (he doesn't), he would have to get every kernel contributor to agree to the license change, AFAIK.

    --
    Do what thou wilt shall be the whole of the Law ::: Love is the law, love under will
  12. Re:Dropping the GPL ~= worse. by asdf7890 · · Score: 5, Insightful

    Complaining about the GPL

    He wasn't complaining about the GPL, he was stating (correctly) that it is one of the key reasons some groups choose not to use GCC, particularly GPL version 3 (note that FreeBSD has not used and of the recent GCC release specifically for that reason - they were fine using GPLv2).

    It is a case of choosing the right tool for the job. Until recently their choice was to redefine the job (change the parts of their projects and licensing policy that GPLv3 conflicted with), keep the old tool (using older, GPLv2 licensed, releases of GCC only), or use something less stable/proven/compatible. They chose the middle option. Now option three is replaced by "use something else that is now stable/proven/compatible enough to be an alternative" they have taken that choice. Again this isn't complaining about GPLv3, it is simply refusing to use it because it is incompatible with some of their chosen goals.

    I'm told there are technical reasons why Clang and the related tool chain are preferable to GCC in some circumstances too, though I'm out of the loop on that one so I don't know what they are or if they are significant to FreeBSD.

    While his answer was rather terse and it would have helped to be less so (it made him appear to some, to you at least, like an anti-GPL troll), what you appear to have done in your response is set up a strawman to attack. This is the sort of thing that anti-GPL people (both within the open-source arena and external to it) will jump on as "proof" that GPL advocates are rabid loonies, so by defending the GPL in such a manner you may be harming the cause rather then helping it. You might want to be more careful not to come across that way (it may not have been you intention on this occasion, but it does seem that way by my reading).

  13. Re:Dropping the GPL ~= worse. by Stormwatch · · Score: 5, Insightful

    Many people wants _real_ freedom for their software

    No, they don't. If they did, they'd use GNU GPL v3.

    But I think you mean the opposite of what you said: people want to be free to do whatever they want with the software, including taking away the software's freedom.

    That's the thing. Free software is not about your freedom, it's about the software's freedom. It is not for the benefit of anyone in particular, it is for the benefit of the whole humanity. When you think about where rms came from, and when you read his writings, you realize that his ideal is not an indifferent "here's some code, use as you wish". It is an ideologically grounded "here's some code, it's for everyone to use, and if you build upon it, the result is also for everyone to use".

  14. Re:Dropping the GPL ~= worse. by arth1 · · Score: 4, Interesting

    In a couple of years time, there will be a proliferation of different, incompatible versions of CLang/LLVM that will be increasingly expensive to maintain. Furthermore, I can foresee vendors making incompatible changes to the code produced by CLang, subtle ABI breakage and the like. The upper levels will suffer too : vendor A's version will not be able to compile source code with vendor B's extensions and vice versa.

    Hindsight is invariably more accurate than foresight. And in this case, hindsight tells us that there are plenty of non-GPL free packages that you use every day that haven't succumbed to either of your fears. In fact you use at least a couple of them when you read this.

    This sounds like the 1980s/ealy 1990s all over again

    That wouldn't be bad. The productivity per user has never been higher, and most of what we use now was invented then. I'd rather see that again that these modern days where ideas are scarce and productivity per user base at an all time low.

  15. Re:Dropping the GPL ~= worse. by hairyfeet · · Score: 4, Insightful

    Here is what I personally don't get, maybe someone can explain it to me, but WTF was it with RMS and the TiVo? It was ONE device that had NO choice but to be made the way it was. It wasn't like TiVo was being run by Cobra Commander here, they knew that if there was a way to get the content off the device (which is EXACTLY what running custom versions would have allowed) it would have been banhammered in the west quicker than you can say "copyright infringement".

    Would he have been more happy if it had used WinCE? Because that is what it feels like to me, that RMS wants ONLY true followers of "the way' to use anything GPL. And since there is multiple other OSes out there including BSD and Windows Embedded it just seems stupid to attack one specific corp and make other businesses afraid of being next on RMS' shit list and all over a device that frankly could have been made no other way without only being sold at China Mart and other "pro piracy" hardware sites.

    --
    ACs don't waste your time replying, your posts are never seen by me.
  16. Re:Dropping the GPL ~= worse. by TheRaven64 · · Score: 4, Insightful

    In a couple of years time, there will be a proliferation of different, incompatible versions of CLang/LLVM that will be increasingly expensive to maintain.

    It's already happened. This is why so many companies are now actively involved in the LLVM community: it's cheaper. I'm currently on my way back from BSDCan (where I was talking a bit about the progress in switching to clang) and I was at EuroLLVM a couple of weeks earlier. Both conferences were full of corporate contributors to LLVM and FreeBSD (two projects that I work on). They like the fact that the license means that they don't need to run everything that they possibly want to do past their legal team and, over the past decade, they've all discovered (at different speeds) that it's much cheaper to engage the community and push work upstream than it is to maintain a private fork.

    You get much better support from companies that join your community because they regard it as being good for them than if they dump code on you because they are legally obliged to. We don't want drive-by code dumps, we want long-term commitments to maintenance.

    --
    I am TheRaven on Soylent News
  17. Re:Code quality will suffer by TheRaven64 · · Score: 4, Informative
    At -O2 and -O3, clang and gcc are within 10% for the vast majority of code, with no overall winner. There are a few corner cases, however:
    • The autovectorisation support in LLVM is a very elegant design, but is very new code and so still performs worse than GCC in a lot of cases (about 70% of the autovectorisation test suite is faster with GCC).
    • Clang has no in-tree support for OpenMP, so anything using OpenMP (vaguely competently) will be faster with gcc because clang will fall back to the single-threaded version.
    • GCC's Objective-C support is just embarrassing, and (on non-Apple platforms) performance can be an order of magnitude better with clang, with a 20-50% speedup being pretty common.
    --
    I am TheRaven on Soylent News
  18. Re:Dropping the GPL ~= worse. by russotto · · Score: 4, Informative

    Here is what I personally don't get, maybe someone can explain it to me, but WTF was it with RMS and the TiVo?

    Tivo did exactly what RMS started the Free Software Foundation to prevent (The Printer Story). What did you expect would happen?

  19. Re:Dropping the GPL ~= worse. by asdf7890 · · Score: 4, Insightful

    Here is what I personally don't get, maybe someone can explain it to me, but WTF was it with RMS and the TiVo? It was ONE device that had NO choice but to be made the way it was.

    If it had not been TiVo it would have been something else. His problem was the use of GPLed software in that manner. While it wasn't found to break the letter of the license it broke the clearly stated spirit of the license, so that wording was updated in v3 to patch the hole.

    Would he have been more happy if it had used WinCE?

    Yes, basically. Or some form of BSD (the licenses used there would allow this sort of use IIRC). Or anything else not GPL licensed. They had those choices available to them.

    RMS is an absolutist on this and similar matters (some would say extremist, but I feel that label to be rather too strong here): if you want to use Free, keep it Free with your use, otherwise use something else (paying for it if need be).

    it just seems stupid to attack one specific corp

    He wasn't going after one specific corp, just the first one that did it (visibly) first and shoring up the hole before others tried. Remember that TiVo could keep using GPLv2 software as they had already done, they'd just have to start maintaining by other means once later versions switched to GPLv3, so the switch to GPLv3 did not explicitly stop them distributing their product.

    and make other businesses afraid of being next on RMS' shit list and all over a device that frankly could have been made no other way without only being sold at China Mart and other "pro piracy" hardware sites.

    That is where it falls down of course, but so does every other license commercial or otherwise - if you can't enforce the license in a territory people wanting to do something against the (letter of the) licence in that territory are at an advantage to those elsewhere. "Pro piracy" regimes are not a GPL specific problem and not really relevant here - you could just as easily state that VMWare's recent licensing model changes are an attack on compliant companies.

    There are many people who think RMS is wrong on the matter, of course. Linus for instance still explicitly uses GPLv2 as evidenced by it being the license git is released under (the kernel is a different matter: that could not be switched even if he wanted because of how many contributions there have been where rights were not explicitly handed over to the project).

  20. All of this bickering misses the point by Jeff- · · Score: 4, Insightful

    I'm a 10 year+ FreeBSD contributor. You're all missing the point. Linux and BSD target different markets and are optimized in all ways, organization, release process, license, code, to fit these different needs. One isn't better or worse. Obviously Linux is larger in all ways than BSD but larger doesn't mean better or we'd all just be using windows. This isn't a question of llvm being better than gcc, bsd being better than linux, or bsd license being better than gpl. They are just different and do different things. Use what's appropriate for your needs and leave it at that.

    I can say as a long time contributor to opensource software I am disgusted at reading the comments of blowhard 'enthusiasts' who denigrate the hard work and contributions of hundreds of people when they get in these pissing matches. I am friend with Linux kernel contributors and I can guarantee we don't flame each other in this manner.

  21. History by TopSpin · · Score: 4, Interesting

    At the moment I write this there are 297 comments mostly debating the merits of LLVM/Clang vs. GCC. There is not one mention of EGCS.

    Fifteen years ago GCC was forked. A group of people we're frustrated with GCC and its leadership because they had contributions to make and talent to offer that was not welcome. They called their fork EGCS.

    Why are we doing this? It's become increasingly clear in the course of hacking events that the FSF's needs for gcc2 are at odds with the objectives of many in the community who have done lots of hacking and improvment [sic] over the years.

    The GCC you use today is EGCS. A few years later EGCS was adopted as GCC 2.95 after the merits of EGCS became undeniable.

    Looks like we've come full circle. The cool kids are off in the weeds making cool stuff. Better stuff, and the `Powers That Be' are not interested. The `needs' of the FSF today are no longer in sync with the `needs' of the developers of today.

    The bottom line is that GCC as it is with it's leadership, code base and license agenda doesn't cut it for those who have the talent, motivation and capital to create a tool chain that does cut it. You don't get to impede that, however righteous you think you are.

    Freedom. Deal with it.

    --
    Lurking at the bottom of the gravity well, getting old
  22. Re:Go to definition of selected symbol by dgatwood · · Score: 4, Insightful

    Have you ever actually tried to parse a declaration reliably using regular expressions? I have. They just kept getting more and more horrible the more complex the input became, and at some point, after fixing a bunch of bugs, I concluded that it was an insane way of doing things, threw out all the regular expressions, and started over with a tokenizing parser.

    Trust me when I say that parsing declarations with even Perl-compatible regular expressions, much less BRE or ERE, is not something you want to attempt if you value your sanity in the slightest.

    --

    Check out my sci-fi/humor trilogy at PatriotsBooks.

  23. Re:Dropping the GPL ~= worse. by jbolden · · Score: 5, Informative

    We don't have to guess which model works best, at this point we have historical data. Your model failed with respect to X. MIT created and maintained an X that they released via. the MIT license. All the UNIX vendors then took this MIT code and intermixed it with their custom code creating value add X's that were specific to their platform, and closed source. The effect was that the X that existed in the public domain was worthless for end users, and the X's that were worthwhile were closed. X itself couldn't progress because it fragmented so all the interesting stuff existed in other layers. Years later when there was a desire for a workable open X, the XFree86 project had to start, essentially from scratch and this took years. We still haven't gotten all the features that existed in those proprietary Xs 2 decades ago.

    That is the classic example of why BSD style licensing doesn't work. The primary maintainer is not unchanging.

    Conversely the GPL has a long history of successful multi corporate contributions over time. The historical data simply refutes your theory of what should work.