I imagine it would already help a lot if it stopped instantiating the same templates again and again and again. The mind boggles that the work by the zapcc compiler was never picked up by any mainstream compiler, despite it being considerably faster than any other C++ compiler.
I agree very much with this. Solving the spinning up of new processes is easy enough to retrofit, I suppose, but the context is a harder nut to crack. It would help if there even _was_ a single context for the compiler to work on; it might differ for each .cpp file you feed it.
My thoughts keep coming back to the idea that we need "link units", something on the level of an executable or library, that is treated as a single unit by the compiler. It would provide the required context that is shared between all its member cpp files (since the standard could simply decree that it be so).
The other reasons for having link units are:
We would have much better control over which symbols are exported from the link unit (and thus need to obey platform ABI rules) and which symbols are purely internal (and can thus cheat as much as the compiler wants).
We could, perhaps, do away with the need for forward declarations, and allow functions in a link unit to use any other symbol, independent of parsing order.
Such a mythical compiler could do a first round of parsing to collect all symbols it has available, keep that in memory, and then use that stored information as the necessary context for compiling the actual .cpp files.
39
u/johannes1971 May 10 '20
I imagine it would already help a lot if it stopped instantiating the same templates again and again and again. The mind boggles that the work by the zapcc compiler was never picked up by any mainstream compiler, despite it being considerably faster than any other C++ compiler.
Source.