[TUHS] Looking for final C compiler by Dennis Ritchie
mobile at majumdar.org.uk
Sat Jul 21 05:57:43 AEST 2018
On 20 July 2018 at 11:04, Paul Ruizendaal <pnr at planet.nl> wrote:
>> I will try to port the C compiler to amd64 - while preserving as much of
>> the original code as I can. But not sure if this is even feasible.
> If that is your goal, you might want to start with the version included with 2.11BSD. It is essentially the same as the version from V7, but with 15 more years of bug fixes. I used that source to port V6 Unix to the TI990 architecture back in 2014/2015 and the good thing about it is that it still compiles with a modern gcc.
Thank you for the tip - very helpful.
> For your project, I think you would be able to use the first pass ‘c0’ almost unchanged. The second pass ‘c1’ would need major restructuring. It mainly builds a tree for each expression and then performs various transformations, many of which are PDP11 specific (but also portable ones, like handling of constant expressions). It then covers the tree with code fragments selected from a library. This library (‘optable') would need a full rewrite as well. The last pass ‘c2’ is the optimiser and is also highly PDP11 specific. It reads the assembler output of ‘c1’ function by function, building an instruction list. It then performs some portable optimisations (eliminating unnecessary jumps, etc.) and also more PDP11 specific optimisations (the most complex being removing redundant register loads - the concept of which would be reusable).
> There are about 12,000 lines of code and as a rough guess I would say that some 40% needs rewriting. A new code fragment library would probably be some 2 to 3 thousand lines.
Thank you again for all this info.
> I recall reading about a project to revive the Ritchie C compiler one or two years ago, but a quick web search came up dry. Anybody else remember reading that?
I thought that the revival only meant being able to run code in PDP11 emulator?
Thanks and Regards
More information about the TUHS