<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 30, 2019 at 6:04 AM Lubos Lunak <<a href="mailto:l.lunak@centrum.cz">l.lunak@centrum.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thursday 30 of May 2019, Lubos Lunak via cfe-dev wrote:<br>
> On Wednesday 29 of May 2019, David Blaikie wrote:<br>
> > In any case, talking to Richard Smith about all this, here's some things:<br>
> ><br>
> > * Clang header modules don't have the pending instantiation performance<br>
> > problem described here - because they handle the pending instantiations<br>
> > at the end of building the module, rather than in every consumer.<br>
> > * It's possible moving PCH to the modules semantics<br>
<br>
<br>
Oh, wait, "semantics". I originally understood this as a kind of "do not use <br>
PCHs, use modules", but I might have misunderstood. If this actually means <br>
that PCHs should internally handle templates etc. the same way modules do, <br>
but to the outside world they would still keep looking like normal PCHs, then <br>
yeah, sure, as long as it works.<br></blockquote><div><br>Right - that's what I was suggesting. Sorry for the confusion.<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> > might be valid in <br>
> > general, or good enough to put behind a flag. (doing this in general<br>
> > would of course be easier, code-wise - fewer supported code paths, etc)<br>
><br>
> Two questions come to mind here:<br>
> - is it reasonably ready for use?<br>
> - how much work would it be to use it?<br>
><br>
> I tried Clang modules after they were mentioned in the first reply, and I<br>
> got the impression that they need preparation for every header file used by<br>
> the project, even external ones. Unless that can be automated, I don't<br>
> quite see that happening for something the size and complexity of<br>
> LibreOffice (we don't manually create our headers-to-become-PCHs either).<br>
> And an unofficial tongue-in-cheek motton of LibreOffice is "proudly<br>
> breaking your toolchain since 1985", so unless modules are reasonably<br>
> usable, we'll run into all the bugs there and nobody will want to use it.<br>
><br>
> If doing this is good technically, long-term, fine, do it. But I'd like to<br>
> have something that works this summer, and my rather simple patch can<br>
> deliver that.<br><br>
And so this part would be irrelevant in that case I hope?<br></blockquote><div><br>Right. (I mean, a separate question is whether you'd want to use modules - but yes, at the very least it does involve standardizing your headers on "well behaved" sort of restraints (basically "you can include the header anywhere, any time, and it always behaves the same way" - so not having headers that depend on macros locally defined to different values in different translation units, etc) - but yeah, it's a lot more work than the PCH situation)<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> > * Moving the pending instantiation processing to the end of the PCH would<br>
> > make PCH generation a little slower, but given a project would only have<br>
> > one PCH that might not be a huge problem.<br>
><br>
> I think that would be very well worth it.<br><br>
This should be the same either way.<br></blockquote><div><br>Yeah, I think I'd misunderstood your proposal - I had assumed there was a separation between PCH generation and the PCH->Object step (& in that latter step, the pending instantiations would be done). Sounds like your .h->PCH step also generates the object?<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> > * In addition to that, we could support -fmodules-codegen/debuginfo -<br>
> > which would implement the "building an object from the PCH" step you've<br>
> > described using existing infrastructure in Clang (& that would then<br>
> > include other non-template inline functions, so it'd be a bit broader)<br>
> > * Then we could potentially do something more like what you're proposing<br>
> > here - if modules-codegen is used, defer pending instantiations from the<br>
> > initial module/PCH creation step, to the module/PCH-to-object step, to<br>
> > speed up module/PCH generation & unblock the downstream compilations that<br>
> > use it<br>
><br>
> That could work for me too. And I'd be probably willing to help, if my<br>
> Clang skill would be up to that. How much time/work would this be?<br>
<br>
<br>
This part supported my understanding as "use modules instead of PCHs", so I'm <br>
not sure which interpretation you meant, but that's not the correct one, then <br>
I think these flags are not really needed, at least for PCHs. The step of <br>
creating an object file accompanying the PCH can be easily achieved <br>
using "clang++ -c empty.cpp -include-pch <br>
whatever.h.pch -Xclang -building-pch-with-obj", internally the <br>
BuildingPCHWithObjectFile flag can be used for controlling special handling <br>
as such the need to force emitting the shared code, and doing it as another <br>
separate step would help with build parallelization. So, in fact, this way <br>
there would be no need to move the processing of pending instantiations to <br>
the end of PCH if BuildingPCHWithObjectFile is set.<br></blockquote><div><br>I didn't realize there was already a building-pch-with-obj option - I see now that there is. Sorry for the confusion there.<br><br>But I still suspect whatever that implements isn't quite modules-codegen, but I could be wrong.<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
-- <br>
Lubos Lunak<br>
</blockquote></div></div>