9 ms·
How Much Does a Compiler Cost?
- msla 9y ago> For a commercial system, the compiler has to be completely reliable—whatever the source code, it should produce correct, high performance binaries. Well, that's certainly the ideal case. I can only wonder what historic defect rates have been for commercial compilers.
- eesmith 9y agoNot that it answers the question, but here are some VC++ bugs found in Chromium development: https://randomascii.wordpress.com/2016/03/24/compiler-bugs-found-when-porting-chromium-to-vc-2015/ https://randomascii.wordpress.com/2016/03/24/compiler-bugs-f... . HN discussion at https://news.ycombinator.com/item?id=11361151 https://news.ycombinator.com/item?id=11361151 .
- gnufx 9y agoRed Hat tend to hide bug reports on their commercial (free software) compilers in bugzilla, unfortunately; I don't know what Adacore, for instance, or other commercial providers do, and such bug reports will be only a small part of it. You could obviously study the defects in released versions of GCC on which commercialized versions are based, though, to the extent they have PRs. A great benefit of GCC was always enabling learning and research, though there are more opportunities these days.
- catpolice 9y ago> LLVM is smaller at 1.6 million lines, but is newer, supports only C and C++ by default Unless I'm misunderstanding "by default", this isn't true. LLVM is language agnostic and supports many languages - even the primary C-like frontend Clang supports more than just C/C++.
- webkike 9y agoYou are correct. The article is misinformed
- pebers 9y agoPerhaps they mean that within those 1.6 million lines, the only frontend is Clang? But the line count for gcc includes e.g. gfortran as well?
- valarauca1 9y agoThe GCC addons (gcc-fortran, gcc-cobal, and gcc-go) just convert the existing language into C that is just ingested into the standard GCC. It was only around 2008 that gcc-c++ stopped doing the internal translation/name mangling dance and gained native first party support [1]. Much like how the older versions of GCC used to just produce ASM files to be ingested into GAS to create the binary objects. [1] https://lwn.net/Articles/542457/ https://lwn.net/Articles/542457/
- a_humean 9y agoYeah, I thought that part of the point of the LLVM project was that front end language compilers (entirely language agnostic) could target non-platform specific LLVM IR code, and then let the backend LLVM compiler compile to multiple backend targets. It simplifies front-end compiler development by having a single IR target over multiple native target.
- wolfgke 9y ago> LLVM is language agnostic There exists no such thing as "language agnostic". Every intermediate representation contains properties (very often implicitly) that are specific at least to a class of programming languages.
- whatshisface 9y agoIf the intermediate representation is no more language-specific than x86, then it isn't really the compiler that's language-specific: it's modern computer architecture.
- FeepingCreature 9y agoLLVM IR is fairly C specific. For instance, you better not be trying to write a language where null pointer access is defined...
- pipio21 9y agoWe have worked with LLVM a lot for own own compilers and DSPs. LLVM Intermediate representation in practice is C++, AST is C++. LLVM do not support many languages,many languages support LLVM, which is different. That is many people, or languages' designers, have made the necessary work to make their languages compatible with LLVM IR. If the language is similar to C++, this is a simple task, if it is very different, it is very hard. LLVM does not support other languages, in fact, codebase changes a lot making maintenance painful.
- Arnt 9y agoCould you elaborate on the C++ resemblance? Specifically, in my limited experience LLVM IR resembles typical hardware rather than C++. Modeling the hardware is a design goal for C++, of course, so anything hardware-like must be C++-like. Can you describe some ways in which IR resembles C++ that are not plausible ways to resemble hardware? I'm really curious.
- ggambetta 9y agoHeh. Remember when you had to actually buy a compiler? :)
- bradstewart 9y agoPeople still buy compilers. IAR is [1] still the gold standard in the embedded space. [1] At least it was 18 months ago when I still working in the space, can't imagine that's changed since.
- yitchelle 9y agoIAR is still very popular. However, if you need to support esoteric microcontrollers, there is usually no other options but to purchase it.
- peatmoss 9y agoIn the scientific / numeric space it’s not unheard of to buy Intel Fortran/C compilers for performance reasons. Also, it’s been a few years since I touched IBM’s POWER hardware with AIX, but I’m pretty sure XLC and whatever the Fortran compilers were didn’t come free.
- wycy 9y agoMy organization uses the Intel Fortran compiler. I did a few rough benchmarks at one point and found it produced code nearly 3x faster than the same code in gfortran.
- peatmoss 9y agoI suspect the exact speedup depends a lot on the workload, but the last time I supported scientists on HPC, they reported pretty substantial performance gains with ifort over gfortran as well. But then Intel has deeper pockets to pay for this kind of thing than the FSF. I think I also recall something about gfortran deliberately choosing some more conservative optimization strategies, which could also explain some differences. Or I could be misremembering absolutely everything :-)
- phkahler 9y agoI find it odd that they did an LLVM port and even another blog about dealing with 16bit char types, but none of the target specific changes are going upstream. I can understand a company not wanting to help their competitors, but it sounds like they're still going to try to get the 16bit char changes pushed upstream, which is likely one of the more useful pieces for a competing DSP vendor with a different instruction set. In 5 years we'll all be using risc-v with a nice DSP extension anyway... And after typing that I felt the need to google: https://riscv.org/wp-content/uploads/2016/07/Wed1000_dsp_isa_extensions_for_an_OpenSource_RISCV_implementation_Schiavone.pdf https://riscv.org/wp-content/uploads/2016/07/Wed1000_dsp_isa...
- gumby 9y agoIn a decade Cygnus spent well over $250 million on GCC and its related tools -- well our customers did. Not sure what that is in today's dollars.
- solarkraft 9y agoCan break down where the money likely went, how it was spent?
- pacaro 9y agoI remember writing code for Psion (later Symbian) Epoc32 in the late 90s and early thousands. It was a big deal that Cygnus had done the work to make gcc support ARM because the vendor compiler was (IIRC) some weird combiniation of expensive and not very good. We now assume ARM as being a default necessary platform to support, 20 years ago it really wasn’t clear
- gumby 9y agoThis was between 1989 (when we started in my living room) and 1999 when I left. By 1999 we had about 160-170 developers working on gcc, gdb, binutils, glibc, Cygwin etc. The money was a mixture of 1> ports (typically paid for by the manufacturer), 2> maintenance (mostly paid for by the corporate end user -- for $100K/year we'd fix your bug whether we spent $100 to make a trivial fix or $300K on a major problem) 3> maintenance on very old versions that people had to freeze on for one reason or another and 4> the public tree (we wouldn't work on non-free software, apart from a few abortive experiments after I had left). Making sure everything we wrote was compatible with the public tree was expensive. In the end, one of the last things I did saved a lot of money and improved code quality for everyone: I forked gcc from the FSF (and made the egcs tre the de facto, and eventually de jure version). Nowadays forking is considered routine, and even beneficial, and projects have steering committees that are responsible for master releases. At that time, forks were considered a tragedy, and it took me over 6 months of discussion with various people to build a reasonable consensus (you can see the people's name at the bottom of the letter I wrote announcing it ( https://gcc.gnu.org/news/announcement.html https://gcc.gnu.org/news/announcement.html ). It's been a good model. Note that RMS's name is not on the letter -- he was furious and was sure this would destroy the FSF. Instead it has strengthened it. By the way, to compare these numbers: Red Hat went public with, AFAIK less than 10 engineers and when Cygnus and Red Hat merged, though both companies had about 200 people, Cygnus had over 160 engineers while Red hat had a couple of dozen. Of course we had a lot more revenue, and in the years since RHAT has invested heavily in free software development. But their company value at that time was something like 3X ours -- a very valuable lesson.
- deleted 9y ago[deleted]
- bernardino 9y agoDoes anyone know of any resources to learning about compilers and building a small, simple compiler for beginners?
- dredmorbius 9y agohttps://en.m.wikipedia.org/wiki/Principles_of_Compiler_Design https://en.m.wikipedia.org/wiki/Principles_of_Compiler_Desig...
- ndh2 9y agoI watched a couple videos from this and was good to go. https://lagunita.stanford.edu/courses/Engineering/Compilers/Fall2014/about https://lagunita.stanford.edu/courses/Engineering/Compilers/... My strategy was to start with a very small grammar and grow it.
- filereaper 9y agoAs a previous compiler developer, its a pretty bad idea to look at the final lines of code to determine its cost. Typically in compiler development, there's massive R&D time, many hours spent analyzing memory & CPU patterns to figure out which code to emit. You also take a look at disassembly of generated code and nowdays perform data-mining to figure out which patterns of optimize for (typically on non-kernel or hotspot-heavy type workloads). The end result of alot of investigation can be few lines of code which have to be absolutely robust and production ready at the time of release under standard configurations (i.e -O1, -O2 etc...) Its a costly piece of engineering which is why some companies still charge money for it. I'd say the article's estimates are accurate for a simple compiler that emits results at say -O0 or -O1 level of efficiency, but anything higher will start to require more and more resources with diminishing gains over time. But this can be said about most things in engineering.
- sesteel 9y agoI was hoping this was an analysis on how much time and money is spent while waiting for n number of lines of code to compile by various compilers. I find waiting for things to build, deploy, install dependencies, etc as the most mind numbing aspects of the field. I can hardly stand it.
- neokantian 9y agoC/C++ compilers are different from other compilers. They are forced to support all kinds of complicated, too-many-cooks-spoil-the-broth, design-by-committee standards. If you just wanted to do another portable assembler, your new compiler would take just a fraction of the effort.
- jokoon 9y agoI wonder, are there languages that are cheaper yet have similar features? For example, how much is rust? python? It's weird how a compiler can cost so much, yet it can still produce unsafe code because the language is not safe by design. In that optic, rust might save a lot of money.
- gambiting 9y agoYou cannot produce a Rust or a Python compiler without a working C/C++ compiler first anyway, so the point is slightly moot. If there exists a C/C++ compiler for the platform you want to build for, just build Python for it and you're good to go.
- z29LiTp5qUC30n 9y agoPosts like this make me think of this: https://github.com/oriansj/M2-Planet https://github.com/oriansj/M2-Planet A C compiler with support for inline assembly, gotos, structs and weighs under 2000lines and is self hosting.