GCC for new contributors
I’m a relative newcomer to GCC, so I thought it was worth documenting some of the hurdles I ran into when I started working on GCC, to try to make it easier for others to start hacking on GCC. Hence this guide."
Posted Mar 29, 2017 15:08 UTC (Wed)
by epa (subscriber, #39769)
[Link] (13 responses)
Posted Mar 29, 2017 20:44 UTC (Wed)
by joib (subscriber, #8541)
[Link] (12 responses)
I think the "ideal" language for implementing compilers would be something with 1) decent performance 2) memory/type/etc. safety 3) high level features (pattern matching, first-class functions, etc.). Rust, maybe, but OTOH a compiler tends to a) not have real-time requirements and b) lots of variously interconnected graphs, so I think a language with GC would be a better match than Rust's ownership based memory management. Haskell is maybe a bit too esoteric. Maybe OCaml, or Swift, or D (no personal experience here)?
That being said, if one looks at the current GCC code, it looks like trying to program Lisp in C (e.g. trees are all the same generic type from the C perspective, with a tag field specifying which type it really is), getting the worst of both worlds. So in that spirit, why not just bite the bullet and write the thing in a proper Lisp then? :)
Posted Mar 29, 2017 21:11 UTC (Wed)
by smoogen (subscriber, #97)
[Link] (6 responses)
The last 20% is where the compiler needs to work on a lot of different computers, many of the architectures haven't been built in 20-40 years... all of them having interesting quirks that are known to induce the eventual hearing of discordant flutes and drums in compiler engineers.
The final 10% (yes that makes 110%, long lived compilers are always non euclidean in volume) are the various optimizations that can be performed on every one of those architectures.. except when they can't be. Did I mention the drums?
Posted Mar 30, 2017 9:52 UTC (Thu)
by epa (subscriber, #39769)
[Link] (2 responses)
Posted Mar 30, 2017 15:25 UTC (Thu)
by kpfleming (subscriber, #23250)
[Link]
Posted Mar 31, 2017 10:16 UTC (Fri)
by joib (subscriber, #8541)
[Link]
Posted Mar 31, 2017 10:56 UTC (Fri)
by joib (subscriber, #8541)
[Link] (2 responses)
Now, certainly in the real world (as opposed to the "ideal" question I was originally answering) there are considerations like bootstrapping, dogfooding, portability etc.. So yes, for a primarily C or C++ compiler, you can certainly find reasons for implementing it in C or C++.
Posted Mar 31, 2017 16:09 UTC (Fri)
by smoogen (subscriber, #97)
[Link] (1 responses)
That said, I don't disagree that the bootstrap problem is what keeps gcc being written in C/C++ versus a saner language like LISP. However the days of native running LISP machines seem to becoming pale shadows as I have never actually directly used one myself but was told of their Halcyon days when I was getting into computers in the late 1980's.
[Of course I expect someone will start a kickstarter to make a new Symbolics on a chip.. to plug into a raspberry pi.. but there is a limit to how far I will follow the mad fluters of Azathoth.]
Posted Mar 31, 2017 16:50 UTC (Fri)
by joib (subscriber, #8541)
[Link]
The performance Lisp compilers are able to achieve is pretty amazing considering how dynamic Lisp is. Not as fast as C of course, but leagues ahead of similarly dynamic languages like python, ruby. Something in the range of javascript performance in general, depending on the benchmark of course, which is still pretty amazing considering the amount of $$$ poured into JS compilers in the past decade.
Posted Mar 29, 2017 21:50 UTC (Wed)
by nix (subscriber, #2304)
[Link] (4 responses)
GC is really useful for a lot of parts of a compiler (the cross-pass parts with independently-variable lifespans, mostly). It is not so useful for those bits that live and die in one pass or that have coupled lifespans: a poolized allocator is a better fit there.
Of course, not all language-level GCs are applied to each object independently, but a great many seem to be, or are applied in a way that is not particularly predictable to the developer (hello, Haskell!). Such things are problematic for compilers with architectures similar to GCC's -- though obviously it is *possible* to write compilers in such languages. You just have to get your speed back somewhere else. :)
Posted Mar 30, 2017 19:21 UTC (Thu)
by smckay (guest, #103253)
[Link] (3 responses)
Posted Mar 31, 2017 8:49 UTC (Fri)
by roc (subscriber, #30627)
[Link] (2 responses)
Posted Mar 31, 2017 16:57 UTC (Fri)
by smckay (guest, #103253)
[Link] (1 responses)
Posted Apr 6, 2017 1:22 UTC (Thu)
by nix (subscriber, #2304)
[Link]
GCC's dialect of C++
GCC's dialect of C++
GCC's dialect of C++
GCC's dialect of C++
GCC's dialect of C++
GCC's dialect of C++
GCC's dialect of C++
GCC's dialect of C++
GCC's dialect of C++
GCC's dialect of C++
GCC's dialect of C++
GCC's dialect of C++
GCC's dialect of C++
GCC's dialect of C++