[cfe-dev] Controlling instantiation of templates from PCH

Hans Wennborg via cfe-dev cfe-dev at lists.llvm.org
Wed May 29 02:42:24 PDT 2019


On Tue, May 28, 2019 at 9:38 PM Lubos Lunak via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
>
> On Tuesday 28 of May 2019, Nico Weber wrote:
> > That's a cool observation!
> >
> > A question independent to the other discussions happening on this thread:
> > Since you're comparing build times between MSVC and clang, do you use
> > clang-cl in Windows builds?
>
>  We do have support for clang-cl AFAIK, but I don't know how much it's used.
> The release binaries are built with MSVC and I think most developers are on
> Unix-likes anyway. I've never used clang-cl myself.
>
> > The clang-cl / cl.exe PCH flags (/Yc, /Yu)
> > would allow implementing your suggested optimization without a need for any
> > new driver flags.
>
>  /Yc /Yu could act that way without extra flags, but I think they don't. I've
> just skimmed over the sources, so I may be mistaken, but it seems to me
> the /Yc mode is not different there. Unless /Yc somehow already instantiates
> everything in the PCH and avoids such instantiations in TUs using the PCH,
> there is still going to be the cost of Sema::PerformPendingInstantiations()
> doing something that's not needed. Remember that this is actually about
> improving the build time, not necessarily the build result.
>
> > This seems similar to doing
> > http://blog.llvm.org/2018/11/30-faster-windows-builds-with-clang-cl_14.html
> > for all inlines, not just for dllexported ones.
>
>  I think that's different. That one is like -fvisibility-inlines-hidden, which
> only causes inlines not to be exported. But they will still be processed.

I think this is more in the vein of
http://llvm.org/viewvc/llvm-project?view=revision&revision=335466

We could know that the definitions of the instantiated templates are
in the PCH .obj file, and could hopefully skip it in other users of
the PCH. And that's probably how MSVC does it.



More information about the cfe-dev mailing list