Zapcc – A faster C++ compiler
baptiste-wicht.com
baptiste-wicht.com
<tangent>
Are the any working open source C++ compilers which aren't based on gcc or clang? I know of TenDRA, which appears to have ceased to exist and was always kind of incomprehensible and non-working and apparently it never got as far as STL support; there Path64, whose github page no longer contains the compiler repo; there's Open64, whose website no longer exists (although there does seem to be a daughter project, OpenUH, which did a release last year)...
Is there anything else?
For C++? No. Too hard of a language to waste phd students maintaining :)
Over the years there have been a few more (openC++ is a good example, ROOT used to be one too), but they are all dead now AFAIK. One reason is that research in compilers is pretty much not in the frontends anymore. For any research still being done that uses C++ as a base, gcc/clang/llvm pretty much work fine. LLVM in particular has an IR that works for most researchers, is not hard to understand, etc. For people who want to try to build larger solutions, they usually start with C (see, for example, libfirm and friends).
Commercial folks use EDG or, actually, a lot are also starting to use clang now as a frontend.
(IBM was the other major company that had their own C++ parser for a longer time)
* All variables were hoisted up to function scope. This meant that you couldn't use "int i" in one loop, and "unsigned int i" in the next. This also caused destructors to be incorrectly delayed until the end of the function call.
* Use of templates required pre-compiled dictionaries for each type the template might be instantiated for. Any templates occurring in interpreted code would be silently ignored.
* Incomplete standard library implementation. std::abs(long) is missing, for example.
* const is silently ignored.
Not entirely relevant to the current discussion, but good heavens, I am glad that monstrosity is gone.
There's a really high barrier to entry for C++ compilers, and between Clang, GCC, and all the proprietary compilers there's not a huge need for another one.
http://www.softwarepreservation.org/projects/c_plus_plus/ind...
I think the reason why there are so many C/C-like compilers, but very few C++ (I personally don't know of any open-source ones besides gcc and clang) is due to the complexity of the language; C is simple enough that a single person can easily write a compiler for one in a short time and have it compile both itself and large quantities of existing standard and not-so-standard code:
https://news.ycombinator.com/item?id=10731002
https://news.ycombinator.com/item?id=11903674
https://news.ycombinator.com/item?id=9125912
In contrast, C++ is at least an order of magnitude more complex, with far more features that need to be working to get to something which could usefully be considered 'C++'. For example, templates are pretty integral to the language and implementing them correctly is not trivial.
The number of people who can write a whole C compiler, while relatively many, is still a tiny fraction of all programmers. (I do wish there were more, since I personally think the concepts aren't so hard once you see the essence of the tiny compilers like tcc or C4.) And a much tinier fraction of them will want to try writing one for even a subset of C++.
Academic researchers can get a free library license, but not a compiler license.
I was pretty skeptical of D for a while, mainly because of the GC, but I've started to take a liking to it. It's a very useful tool.
DMC++ is still awesome, because it's the only ISO C++ compiler out there that can target any kind of DOS platform and binary format, from 16-bit .COM files (!!!) to 32-bit DOS extender.
The main reason it's slow is that it does a lot of analysis, even at -O1.
This is good. Apparently it improves compile speed by a factor of 2..10 for a wide use range without compromising on the output quality. For many C++ developers it will be like a nitro injection.
https://en.wikipedia.org/wiki/PathScale
Sounds like it was more talk than real intention.
This doesn't have the compiler: https://github.com/path64
p.s. if you wonder why I'm so vehement about this topic, it's because you're basically accusing real people of being unethical based on your inability to find things now that we were required to give away in the past.
http://www.pathscale.com/ekopath4-open-source-announcement
Either you are talking about something else completely, or I'm really confused.
Another such example is compiler made by Sun. They planned to open it up, but Oracle's takeover ruined those plans.
>3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
>a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange
Do you know if the source is downloadable, legally from anywhere? Or was it only distributed to original customers?
[1]: https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
https://www.phoronix.com/forums/forum/software/general-linux...
The tl;dr from reading between the lines is that having the open source version was crippling their commercial sales, so they tried to make it go away.
There's a nightly download from http://www.pathscale.com/ekopath-compiler-suite makes you click through a GPLv2 license (the GPL is not an EULA, dammit!) but there's no source included or any link to source.
But I did eventually track down a clone of the original github version here:
For testing his template-heavy library. A very small data set, and while templates are one of the problems when it comes to C++ compilation speed, it's certainly not the only one.
Let's see the differences when compiling Firefox or the whole KDE suite.
(and in fact, is, based on what i've seen. But i still hope these guys get to market and make some money before that takes over the world, because i know how hard it is to do what they are doing :P)
Linking involves far more complexity, with the input files harder to determine. There's no equivalent of -E or -fdirectives-only for linking. A ccache for linking would have to identify and hash all library, object file, and linker script inputs, including those pulled in indirectly by linker scripts, in addition to the toolchain, the command line, and any linker plugins.
It's absolutely possible, and I'd love to see someone do so, but it seems significantly harder than caching compilation.
You'd also want to time the result, and figure out how long the reading and hashing takes compared to linking. ccache misses take only slightly longer than a normal compilation; link-cache misses may take much longer than normal.
On top of that, unlike a compilation cache that seems very likely to hit on the 99% of files not changed in a build, a linker cache would only hit when absolutely nothing has changed in the entire build. It might help for a project that links numerous tiny libraries or binaries (which seems relatively uncommon), but for a project that primarily builds a single library or binary, it'd only help if you rebuild entirely identical sources twice.
(It might, however, speed up Linux kernel builds if you've only changed the code for a couple of modules and not anything in the core kernel.)
* Build-time went from 58s to 37s with zapcc. I didn't use zapcc with ccache and shouldn't.
* Run-time went from 371s down to 204s. Almost double speed!
So it's clearly an effect of clang-4 over gcc-6, and not so much zapcc.
Then I crosschecked with clang-4. The run-time is entirely based on clang-4, confirmed. But the build-time with clang-4 was 44s, still 20% slower than with zapcc.
What I learned:
* ccache is horrible. zapcc is much better.
* clang-4 is fantastic, even if their lto is still too broken to be usable, regarding visibility and inlining.
I found great bugs with new clang-4 warnings.
I had no time yet to use it on C++, where the real advantages come up. On pure C there are just side-effects.
If zappcc creates slower executables but spitting them out faster, it could be used during development to speed up iterations. And if the executables are faster, I'm very curious as to how they achieved both faster compilation and faster runtimes.
Another example of ultrafast compilation is Delphi, but once again the generated code looks more like a dumb line-by-line translation with plenty of redundant and unnecessary instructions (making decompiling interesting in that it easily produces something quite close to the original source.)
clang-4/zapcc is massively faster than gcc-6 for my usecases, and significantly faster than clang-3.9. perl is 2x faster than with gcc-6 -O3.
The value of a caching compiler should really become apparent in incremental builds, as in rebuilding after changing a single file. Yet the author talks about "not seeing any improvements".
Like he said, he might be doing something wrong.
The speedup observed anyway might come from the compilers having to rebuild/instantiate templated code everytime it's included.
There are millions of reasons this may not be true in C++. For starters, the use of time and date macros, etc.
Without precise dependency tracking of what source lines are dependent on what macros (which is super hard, and i don't think they do), which is not usually what is done (dependency tracking is often much more coarse grained), you may not see an improvement.
VisualAge C++ was one of the best incremental C++ implementations i ever saw, and even it did not get to this level.
How did it compare with Energize C++?
I only know both from magazines during those days, even though someone uploaded an Energize video to YouTube.
In regards to VisualAge C++ I think only those of us that were active back then can remeber anything about it. Besides the magazines I had with the product review, I never seen much information being posted on the Internet.
I remember looking at the code to visualage C++ when i was at ibm about 12 years ago.
It was fairly impressive (it built a database of the program with fairly fine grained dependency tracking), at least to younger me.
I don't know if people today would have thought it was a mess or not :)
How will you license Zapcc?
Zapcc will be available under a commercial license from Ceemple Software Ltd.
It's not clear that it will help with template instantiation, because it's fairly hard to parallelize.
Certainly, possible, but very hard to do "optimally" (IE by sharing work instead of duplicating it). Given any initial work is likely to have to do duplicate work per thread, this usually cuts into your speedup quite a lot.
Codegen, on the other hand, is pretty much fully parallelizable. This is the whole reason thinlto exists.
http://clang.llvm.org/docs/UsersManual.html#precompiled-head...
Precompiled headers are currently ignored by Zapcc.
in the perfect world I would like that everyone who uses clang would freely benefit from this improvement. should some big and good corporations just buy out those guys?
So don't worship MIT/BSD and complain later about it when companies prevent you to get the code.
But as it stands now, this is a closed source product, that you to buy: https://www.zapcc.com/buy-zapcc/
The only thing left will be the Linux kernel and a few major projects like Emacs.
The circle will be complete and we will be back to the 90's with freeware like licenses.
Not everyone has the luxury to switch jobs all the time to use the programming languages they want to use.
Unless they're writing APL.
What they care is who support their tools, who they are going to call, how SLAs are enforced.
I mean, I've genuinely unsure.
-SQL Stored Procedure Languages, .NET (used to be), Delphi, Coldfusion, Objective-C, RPG, NEWP, and AOT Java are valid examples, IMHO.
-C++ Builder kind of qualifies, as the UI language is unique. So I guess we could count most UI designers as this.
-Ada, (most) embedded C/C++ compilers, and COBOL don't count, because open-source implementations do exist.
Quite common in embedded space.
And thanks to the fact that they did this, we now know it is possible. Competition will hopefully motivate the Clang developers to develop similar performance improvements in the mainline of Clang. Everyone will benefit.
A Clang user is certainly no worse off than they were yesterday.